-
Notifications
You must be signed in to change notification settings - Fork 11
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
New batch of fixes + integration test improvements #489
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,15 +10,19 @@ import {constants} from '../mocks.js' | |
export function genericPage (page) { | ||
class GenericPage { | ||
async passwordFieldShowsFillKey (selector = '#password') { | ||
// don't make assertions until the element is both found + has a none-empty 'style' attribute | ||
await page.waitForFunction(selector => Boolean(document.querySelector(selector)?.getAttribute('style')), selector) | ||
// don't make assertions until the element has been scanned | ||
const field = page.locator(selector) | ||
await expect(field).toHaveAttribute('data-ddg-inputtype') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've switched this to use the locator with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👌 |
||
|
||
const passwordStyle = await page.locator(selector).getAttribute('style') | ||
expect(passwordStyle).toContain(constants.iconMatchers.keyFill) | ||
} | ||
|
||
async passwordFieldShowsGenKey (selector = '#password') { | ||
// don't make assertions until the element is both found + has a none-empty 'style' attribute | ||
await page.waitForFunction(selector => Boolean(document.querySelector(selector)?.getAttribute('style')), selector) | ||
// don't make assertions until the element has been scanned | ||
const field = page.locator(selector) | ||
await expect(field).toHaveAttribute('data-ddg-inputtype') | ||
|
||
const passwordStyle = await page.locator(selector).getAttribute('style') | ||
expect(passwordStyle).toContain(constants.iconMatchers.keyGen) | ||
} | ||
|
@@ -28,9 +32,14 @@ export function genericPage (page) { | |
expect(passwordStyle || '').not.toContain('data:image/svg+xml;base64,') | ||
} | ||
|
||
async clickThePasswordField (selector = '#password') { | ||
const input = page.locator(selector) | ||
await input.click({force: true}) | ||
} | ||
|
||
async selectGeneratedPassword (selector = '#password') { | ||
const input = page.locator(selector) | ||
await input.click() | ||
await input.click({force: true}) | ||
|
||
const passwordBtn = page.locator('button:has-text("Generated password")') | ||
await expect(passwordBtn).toContainText('Password will be saved for this website') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {constants} from '../mocks.js' | ||
|
||
import {genericPage} from './genericPage.js' | ||
|
||
/** | ||
* @param {import("@playwright/test").Page} page | ||
*/ | ||
export function shadowDomPage (page) { | ||
class ShadowDomPage { | ||
async navigate () { | ||
await page.goto(constants.pages['shadowDom']) | ||
} | ||
|
||
async showTheForm () { | ||
const toggleBtn = page.locator(`button:has-text("Click here to sign up")`) | ||
await toggleBtn.click() | ||
} | ||
|
||
async clickThePasswordField () { | ||
return genericPage(page).clickThePasswordField() | ||
} | ||
|
||
passwordHasNoIcon () { | ||
return genericPage(page).passwordHasNoIcon() | ||
} | ||
|
||
passwordFieldShowsGenKey () { | ||
return genericPage(page).passwordFieldShowsGenKey() | ||
} | ||
|
||
selectGeneratedPassword () { | ||
return genericPage(page).selectGeneratedPassword() | ||
} | ||
} | ||
|
||
return new ShadowDomPage() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {createAutofillScript, forwardConsoleMessages} from '../helpers/harness.js' | ||
import {createWebkitMocks, macosContentScopeReplacements} from '../helpers/mocks.webkit.js' | ||
import {test as base} from '@playwright/test' | ||
import {createAvailableInputTypes} from '../helpers/utils.js' | ||
import {constants} from '../helpers/mocks.js' | ||
import {shadowDomPage} from '../helpers/pages/shadowDomPage.js' | ||
|
||
/** | ||
* Tests for various auto-fill scenarios on macos | ||
*/ | ||
const test = base.extend({}) | ||
|
||
const {personalAddress} = constants.fields.email | ||
const password = '123456' | ||
|
||
test.describe('Page with form in shadow DOM', () => { | ||
async function applyScript (page) { | ||
await createAutofillScript() | ||
.replaceAll(macosContentScopeReplacements()) | ||
.platform('macos') | ||
.applyTo(page) | ||
} | ||
|
||
test('form is scanned on click', async ({page}) => { | ||
// enable in-terminal exceptions | ||
await forwardConsoleMessages(page) | ||
await createWebkitMocks() | ||
.withAvailableInputTypes(createAvailableInputTypes()) | ||
.withCredentials({ | ||
id: '01', | ||
username: personalAddress, | ||
password, | ||
credentialsProvider: 'duckduckgo' | ||
}) | ||
.applyTo(page) | ||
|
||
// Load the autofill.js script with replacements | ||
await await applyScript(page) | ||
|
||
const shadowDom = shadowDomPage(page) | ||
await shadowDom.navigate() | ||
|
||
await shadowDom.showTheForm() | ||
|
||
await shadowDom.passwordHasNoIcon() | ||
|
||
await shadowDom.clickThePasswordField() | ||
|
||
await shadowDom.passwordFieldShowsGenKey() | ||
|
||
await shadowDom.selectGeneratedPassword() | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referencing either the local path or the privacy test pages path. I will migrate more and more over time.