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

Add tests for using the browser window's selection as the default search query #15992

Open
krassowski opened this issue Mar 14, 2024 · 0 comments

Comments

@krassowski
Copy link
Member

krassowski commented Mar 14, 2024

We need to add an integration test for the improvements added by #15834

The current test is defined here:

test('Populate search box with selected text', async ({ page }) => {
// Enter first cell
await page.notebook.enterCellEditingMode(0);
// Go to first line
await page.keyboard.press('PageUp');
// Select first line
await page.keyboard.press('Shift+End');
// Open search box
await page.keyboard.press('Control+f');
// Expect it to be populated with the first line
const inputWithFirstLine = page.locator(
'[placeholder="Find"] >> text="Test with one notebook withr"'
);
await expect(inputWithFirstLine).toBeVisible();
await expect(inputWithFirstLine).toBeFocused();
// Expect the newly set text to be selected
expect(await inputWithFirstLine.evaluate(getSelectionRange)).toStrictEqual({
start: 0,
end: 28
});
// Expect the first match to be highlighted
await page.waitForSelector('text=1/2');
// Enter first cell again
await page.notebook.enterCellEditingMode(0);
// Go to last line
await page.keyboard.press('PageDown');
// Select last line
await page.keyboard.press('Shift+Home');
// Update search box
await page.keyboard.press('Control+f');
// Expect it to be populated with the last line
const inputWithLastLine = page.locator(
'[placeholder="Find"] >> text="This is a multi line with hits with"'
);
await expect(inputWithLastLine).toBeVisible();
await expect(inputWithLastLine).toBeFocused();
// Expect the newly set text to be selected
expect(await inputWithLastLine.evaluate(getSelectionRange)).toStrictEqual({
start: 0,
end: 35
});
await expect(page.locator('.jp-DocumentSearch-overlay')).toBeVisible();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants