-
Notifications
You must be signed in to change notification settings - Fork 301
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
WSL E2E tests: add more new locators #5315
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,83 +210,94 @@ test.describe('WSL Integrations', () => { | |
expect(wslIntegrationList.getByText('alpha')).not.toBeNull(); | ||
expect(wslIntegrationList.getByText('beta')).not.toBeNull(); | ||
expect(wslIntegrationList.getByText('gamma')).not.toBeNull(); | ||
}); | ||
|
||
/* | ||
test('should show checkbox states', (async() => { | ||
const integrations = wslPage.wslIntegrations; | ||
const alpha = integrations.find(item => item.name === 'alpha'); | ||
const beta = wslPage.getIntegration('beta'); | ||
const gamma = wslPage.getIntegration('gamma'); | ||
|
||
await expect(alpha.locator).toHaveCount(1); | ||
await expect(alpha.checkbox).not.toBeChecked(); | ||
await expect(alpha.name).toHaveText('alpha'); | ||
await expect(alpha.error).not.toBeVisible(); | ||
|
||
await expect(beta.locator).toHaveCount(1); | ||
await expect(beta.checkbox).toBeChecked(); | ||
await expect(beta.name).toHaveText('beta'); | ||
await expect(beta.error).not.toBeVisible(); | ||
|
||
await expect(gamma.locator).toHaveCount(1); | ||
await expect(gamma.checkbox).not.toBeChecked(); | ||
await expect(gamma.name).toHaveText('gamma'); | ||
await expect(gamma.error).toHaveText('some error'); | ||
expect(await wslPage.alpha.isChecked()).toBeFalsy(); | ||
expect(await wslPage.beta.isChecked()).toBeTruthy(); | ||
expect(await wslPage.gamma.isChecked()).toBeFalsy(); | ||
|
||
const craftyErrorMessage = 'Error: some error'; | ||
let parent = wslPage.page.locator('[data-test="item-alpha-parent"]'); | ||
|
||
await expect(parent.filter({ hasText: craftyErrorMessage })).toHaveCount(0); | ||
parent = wslPage.page.locator('[data-test="item-beta-parent"]'); | ||
await expect(parent.filter({ hasText: craftyErrorMessage })).toHaveCount(0); | ||
parent = wslPage.page.locator('[data-test="item-gamma-parent"]'); | ||
await expect(parent.filter({ hasText: craftyErrorMessage })).toHaveCount(1); | ||
}); | ||
|
||
test('should allow enabling integration', async() => { | ||
// This is how we do a reload... | ||
const { wsl: wslPage } = new PreferencesPage(preferencesWindow); | ||
await wslPage.reload(); | ||
const integrations = wslPage.integrations; | ||
|
||
await expect(integrations).toHaveCount(1, { timeout: 10_000 }); | ||
await wslPage.tabIntegrations.click(); | ||
await expect(wslPage.wslIntegrations).toBeVisible(); | ||
|
||
const alpha = wslPage.getIntegration('alpha'); | ||
await expect(wslPage.wslIntegrations).toHaveCount(1, { timeout: 10_000 }); | ||
let alpha = wslPage.alpha; | ||
|
||
await expect(alpha.checkbox).not.toBeChecked(); | ||
await alpha.assertEnabled(); | ||
await alpha.click(); | ||
await alpha.assertDisabled(); | ||
expect(await alpha.isChecked()).toBeFalsy(); | ||
expect(await alpha.isEnabled()).toBeTruthy(); | ||
// Don't know why force-true is necessary, playwright times out without it. | ||
await alpha.click({ force: true }); | ||
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. Note that this is forcing a click on the |
||
await writeConfig({ alpha: true }); | ||
await alpha.assertEnabled(); | ||
await expect(alpha.checkbox).toBeChecked(); | ||
// Now 'relocate' alpha | ||
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. This comment is a bit too punny and obscures what it's actually trying to explain… It's probably better to rewrite it to be clearer. Or maybe just drop the local variable and always use |
||
alpha = wslPage.alpha; | ||
expect(await alpha.isChecked()).toBeTruthy(); | ||
expect(await alpha.isEnabled()).toBeTruthy(); | ||
}); | ||
|
||
test('should allow disabling integration', async() => { | ||
await wslPage.reload(); | ||
const integrations = wslPage.integrations; | ||
// This is how we do a reload... | ||
const { wsl: wslPage } = new PreferencesPage(preferencesWindow); | ||
|
||
await expect(integrations).toHaveCount(1, { timeout: 10_000 }); | ||
await wslPage.tabIntegrations.click(); | ||
await expect(wslPage.wslIntegrations).toBeVisible(); | ||
await expect(wslPage.wslIntegrations).toHaveCount(1, { timeout: 10_000 }); | ||
|
||
const beta = wslPage.getIntegration('beta'); | ||
let beta = wslPage.beta; | ||
|
||
await expect(beta.checkbox).toBeChecked(); | ||
await beta.assertEnabled(); | ||
await beta.click(); | ||
await beta.assertDisabled(); | ||
expect(await beta.isChecked()).toBeTruthy(); | ||
expect(await beta.isEnabled()).toBeTruthy(); | ||
await beta.click({ force: true }); | ||
await writeConfig({ beta: false }); | ||
await beta.assertEnabled(); | ||
await expect(beta.checkbox).not.toBeChecked(); | ||
// Now 'relocate' beta | ||
beta = wslPage.beta; | ||
expect(await beta.isChecked()).toBeFalsy(); | ||
expect(await beta.isEnabled()).toBeTruthy(); | ||
}); | ||
|
||
test('should update invalid reason', async() => { | ||
await wslPage.reload(); | ||
const integrations = wslPage.integrations; | ||
const { wsl: wslPage } = new PreferencesPage(preferencesWindow); | ||
const newErrorMessage = 'some other error'; | ||
|
||
await expect(integrations).toHaveCount(1, { timeout: 10_000 }); | ||
await wslPage.tabIntegrations.click(); | ||
await expect(wslPage.wslIntegrations).toBeVisible(); | ||
await expect(wslPage.wslIntegrations).toHaveCount(1, { timeout: 10_000 }); | ||
|
||
const gamma = wslPage.getIntegration('gamma'); | ||
const gamma = wslPage.gamma; | ||
|
||
expect(await gamma.isChecked()).toBeFalsy(); | ||
await writeConfig({ gamma: newErrorMessage }); | ||
}); | ||
|
||
await gamma.assertDisabled(); | ||
await expect(gamma.error).toHaveText('some error'); | ||
await writeConfig({ gamma: 'some other error' }); | ||
test('should see new invalid reason', async() => { | ||
const { wsl: wslPage } = new PreferencesPage(preferencesWindow); | ||
const newErrorMessage = 'some other error'; | ||
|
||
await page.reload(); | ||
const newGamma = (await navPage.navigateTo('WSLIntegrations')).getIntegration('gamma'); | ||
await wslPage.tabIntegrations.click(); | ||
await expect(wslPage.wslIntegrations).toBeVisible(); | ||
await expect(wslPage.wslIntegrations).toHaveCount(1, { timeout: 10_000 }); | ||
|
||
await expect(newGamma.error).toHaveText('some other error'); | ||
await newGamma.assertDisabled(); | ||
// The `isDisabled` locator simply doesn't work -- possibly because the actual DOM is | ||
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. See above re: |
||
// div.checkbox-outer-container data-test=item-gamma | ||
// label.checkbox-container disabled | ||
// input type=checkbox value=true | ||
// span.checkbox-custom role=checkbox | ||
// | ||
// and playwright doesn't give a way to get from `data-test=item-gamma` or the checkbox input elt to that label elt | ||
// expect(await newGamma.isDisabled()).toBeTruthy(); | ||
const parent = wslPage.page.locator('[data-test="item-gamma-parent"]'); | ||
|
||
await expect(parent.filter({ hasText: newErrorMessage })).toHaveCount(0); | ||
}); | ||
*/ | ||
}); |
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.
I don't think we're doing a reload here, just casting
preferencesWindow
(which is aPage
) to aPage
subclass that knows how to handle the specifics of that window, and then grabbing thewslPage
off it.