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

test: add a test for custom engine that does not respect root #4777

Merged
merged 1 commit into from
Dec 19, 2020
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
18 changes: 18 additions & 0 deletions test/selectors-register.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,21 @@ it('should handle errors', async ({playwright, page}) => {
error = await playwright.selectors.register('css', createDummySelector).catch(e => e);
expect(error.message).toBe('"css" is a predefined selector engine');
});

it('should not rely on engines working from the root', async ({ playwright, page }) => {
const createValueEngine = () => ({
create(root, target) {
return undefined;
},
query(root, selector) {
return root && root.value.includes(selector) ? root : undefined;
},
queryAll(root, selector) {
return root && root.value.includes(selector) ? [root] : [];
},
});

await playwright.selectors.register('__value', createValueEngine);
await page.setContent(`<input id=input1 value=value1><input id=input2 value=value2>`);
expect(await page.$eval('input >> __value=value2', e => e.id)).toBe('input2');
});