Skip to content

Commit

Permalink
Testing: selection filtering (#69)
Browse files Browse the repository at this point in the history
Expand coverage for commands related to selection filtering.
  • Loading branch information
haberdashPI authored Nov 20, 2024
1 parent 0c58b24 commit 56c9115
Showing 1 changed file with 120 additions and 0 deletions.
120 changes: 120 additions & 0 deletions test/specs/filterSelections.ux.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import '@wdio/globals';
import 'wdio-vscode-service';
import {cleanWhitespace, setupEditor, storeCoverageStats} from './utils.mts';
import {sleep, TextEditor} from 'wdio-vscode-service';

describe('Number changes', () => {
let editor: TextEditor;

async function setupCursors() {
await browser.executeWorkbench(vscode => {
vscode.commands.executeCommand('selection-utilities.cancelSelection');
});

await editor.moveCursor(1, 1);

for (let i = 0; i < 3; i++) {
await browser.executeWorkbench(async vscode => {
await vscode.commands.executeCommand('editor.action.insertCursorBelow');
});
sleep(100);
}

await browser.executeWorkbench(vscode => {
vscode.commands.executeCommand('selection-utilities.moveBy', {
unit: 'word',
value: 1,
boundary: 'both',
selectWhole: true,
});
});
}

async function setup() {
editor = await setupEditor(`joe
moe
bill
phill
`);

await setupCursors();
await sleep(100);
}

it('can filter by inclusion', async () => {
await setup();
await browser.executeWorkbench(async vscode => {
await vscode.commands.executeCommand('selection-utilities.includeBy', {
text: 'oe',
});
await vscode.commands.executeCommand('deleteRight');
});

expect(await editor.getText()).toEqual(
cleanWhitespace(`
bill
phill
`)
);
});

it('can filter by exclusion', async () => {
await setup();
await setup();
await browser.executeWorkbench(async vscode => {
await vscode.commands.executeCommand('selection-utilities.excludeBy', {
text: 'oe',
});
await vscode.commands.executeCommand('deleteRight');
});

expect(await editor.getText()).toEqual(
cleanWhitespace(`joe
moe
`)
);
});

it('can filter by regex inclusion', async () => {
await setup();
await browser.executeWorkbench(async vscode => {
await vscode.commands.executeCommand('selection-utilities.includeByRegex', {
text: '^[jb]',
});
await vscode.commands.executeCommand('deleteRight');
});

expect(await editor.getText()).toEqual(
cleanWhitespace(`
moe
phill
`)
);
});

it('can filter by regex exclusion', async () => {
await setup();
await browser.executeWorkbench(async vscode => {
await vscode.commands.executeCommand('selection-utilities.excludeByRegex', {
text: '^[jb]',
});
await vscode.commands.executeCommand('deleteRight');
});

expect(await editor.getText()).toEqual(
cleanWhitespace(`joe
bill
`)
);
});

after(async () => {
await storeCoverageStats('filterSelections');
});
});

0 comments on commit 56c9115

Please sign in to comment.