Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing: selection filtering #69

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});