From 6ce56dde49cbd209423673ef62a7e148b1f9e79a Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Fri, 30 Apr 2021 10:19:37 -0700 Subject: [PATCH] test(accessibility): remove and update tests for new chromium (#6372) --- tests/config/android.config.ts | 2 +- tests/config/androidTest.ts | 2 ++ tests/config/default.config.ts | 4 ++- tests/config/electron.config.ts | 1 + tests/config/electronTest.ts | 2 ++ tests/config/pageTest.ts | 1 + tests/interception.spec.ts | 4 +-- tests/page-accessibility.spec.ts | 43 +++----------------------------- tests/selectors-misc.spec.ts | 4 +-- 9 files changed, 17 insertions(+), 46 deletions(-) diff --git a/tests/config/android.config.ts b/tests/config/android.config.ts index 3ca7920d4d..37855f9173 100644 --- a/tests/config/android.config.ts +++ b/tests/config/android.config.ts @@ -51,7 +51,7 @@ class AndroidPageEnv extends AndroidEnv { async beforeEach(args: any, testInfo: folio.TestInfo) { const result = await super.beforeEach(args, testInfo); const page = await this._context!.newPage(); - return { ...result, browserVersion: this._browserVersion, page }; + return { ...result, browserVersion: this._browserVersion, browserMajorVersion: this._browserMajorVersion, page }; } async afterEach({}, testInfo: folio.TestInfo) { diff --git a/tests/config/androidTest.ts b/tests/config/androidTest.ts index 94a8cd3b60..7044c8838d 100644 --- a/tests/config/androidTest.ts +++ b/tests/config/androidTest.ts @@ -26,6 +26,7 @@ type AndroidTestArgs = { export class AndroidEnv { protected _device?: AndroidDevice; protected _browserVersion: string; + protected _browserMajorVersion: number; async beforeAll(args: CommonWorkerArgs, workerInfo: folio.WorkerInfo) { this._device = (await args.playwright._android.devices())[0]; @@ -37,6 +38,7 @@ export class AndroidEnv { .find(line => line.includes('versionName=')) .trim() .split('=')[1]; + this._browserMajorVersion = Number(this._browserVersion.split('.')[0]); this._device.setDefaultTimeout(90000); } diff --git a/tests/config/default.config.ts b/tests/config/default.config.ts index 6d86f2e7b2..5e7e37f5e4 100644 --- a/tests/config/default.config.ts +++ b/tests/config/default.config.ts @@ -56,6 +56,7 @@ type AllOptions = WorkerOptionsFor; class PageEnv { private _browser: Browser private _browserVersion: string; + private _browserMajorVersion: number; private _context: BrowserContext | undefined; async beforeAll(args: AllOptions & CommonWorkerArgs, workerInfo: folio.WorkerInfo) { @@ -67,6 +68,7 @@ class PageEnv { handleSIGINT: false, } as any); this._browserVersion = this._browser.version(); + this._browserMajorVersion = Number(this._browserVersion.split('.')[0]); return {}; } @@ -77,7 +79,7 @@ class PageEnv { ...args.contextOptions, }); const page = await this._context.newPage(); - return { context: this._context, page, browserVersion: this._browserVersion }; + return { context: this._context, page, browserVersion: this._browserVersion, browserMajorVersion: this._browserMajorVersion }; } async afterEach({}) { diff --git a/tests/config/electron.config.ts b/tests/config/electron.config.ts index ce201fe6a6..41afae1287 100644 --- a/tests/config/electron.config.ts +++ b/tests/config/electron.config.ts @@ -46,6 +46,7 @@ class ElectronPageEnv extends ElectronEnv { return { ...result, browserVersion: this._browserVersion, + browserMajorVersion: this._browserMajorVersion, page, }; } diff --git a/tests/config/electronTest.ts b/tests/config/electronTest.ts index 6dae12fffc..99875cc0b2 100644 --- a/tests/config/electronTest.ts +++ b/tests/config/electronTest.ts @@ -29,6 +29,7 @@ export class ElectronEnv { private _electronApp: ElectronApplication | undefined; private _windows: Page[] = []; protected _browserVersion: string; + protected _browserMajorVersion: number; private async _newWindow() { const [ window ] = await Promise.all([ @@ -52,6 +53,7 @@ export class ElectronEnv { // This env prevents 'Electron Security Policy' console message. process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'; this._browserVersion = require('electron/package.json').version; + this._browserMajorVersion = Number(this._browserVersion.split('.')[0]); return {}; } diff --git a/tests/config/pageTest.ts b/tests/config/pageTest.ts index 21bef6558d..e5a6ac1daa 100644 --- a/tests/config/pageTest.ts +++ b/tests/config/pageTest.ts @@ -21,6 +21,7 @@ export { expect } from 'folio'; // Page test does not guarantee an isolated context, just a new page (because Android). export type PageTestArgs = { browserVersion: string; + browserMajorVersion: number; page: Page; }; diff --git a/tests/interception.spec.ts b/tests/interception.spec.ts index ac36037243..c49bd51634 100644 --- a/tests/interception.spec.ts +++ b/tests/interception.spec.ts @@ -156,8 +156,8 @@ it('should work with regular expression passed from a different context', async expect(intercepted).toBe(true); }); -it('should not break remote worker importScripts', async ({ page, server, isChromium, browserVersion }) => { - it.fixme(isChromium && +browserVersion.split('.')[0] < 91); +it('should not break remote worker importScripts', async ({ page, server, isChromium, browserMajorVersion }) => { + it.fixme(isChromium && browserMajorVersion < 91); await page.route('**', async route => { await route.continue(); diff --git a/tests/page-accessibility.spec.ts b/tests/page-accessibility.spec.ts index 3e281affee..88f61a3ff1 100644 --- a/tests/page-accessibility.spec.ts +++ b/tests/page-accessibility.spec.ts @@ -172,8 +172,8 @@ it('rich text editable fields should have children', async function({page, isFir expect(snapshot.children[0]).toEqual(golden); }); -it('rich text editable fields with role should have children', async function({page, isFirefox, browserName}) { - it.skip(browserName === 'webkit', 'WebKit rich text accessibility is iffy'); +it('rich text editable fields with role should have children', async function({page, isFirefox, isWebKit, isChromium, browserMajorVersion}) { + it.skip(isWebKit, 'WebKit rich text accessibility is iffy'); await page.setContent(`
@@ -190,6 +190,7 @@ it('rich text editable fields with role should have children', async function({p } : { role: 'textbox', name: '', + multiline: (isChromium && browserMajorVersion >= 92) ? true : undefined, value: 'Edit this image: ', children: [{ role: 'text', @@ -203,44 +204,6 @@ it('rich text editable fields with role should have children', async function({p expect(snapshot.children[0]).toEqual(golden); }); -it.describe('contenteditable', () => { - it.beforeEach(async ({browserName}) => { - it.skip(browserName === 'firefox', 'Firefox does not support contenteditable="plaintext-only"'); - it.skip(browserName === 'webkit', 'WebKit rich text accessibility is iffy'); - }); - - it('plain text field with role should not have children', async function({page}) { - await page.setContent(` -
Edit this image:my fake image
`); - const snapshot = await page.accessibility.snapshot(); - expect(snapshot.children[0]).toEqual({ - role: 'textbox', - name: '', - value: 'Edit this image:' - }); - }); - - it('plain text field without role should not have content', async function({page}) { - await page.setContent(` -
Edit this image:my fake image
`); - const snapshot = await page.accessibility.snapshot(); - expect(snapshot.children[0]).toEqual({ - role: 'generic', - name: '' - }); - }); - - it('plain text field with tabindex and without role should not have content', async function({page}) { - await page.setContent(` -
Edit this image:my fake image
`); - const snapshot = await page.accessibility.snapshot(); - expect(snapshot.children[0]).toEqual({ - role: 'generic', - name: '' - }); - }); -}); - it('non editable textbox with role and tabIndex and label should not have children', async function({page, isChromium, isFirefox}) { await page.setContent(`
diff --git a/tests/selectors-misc.spec.ts b/tests/selectors-misc.spec.ts index 18764a60c8..d83696af9d 100644 --- a/tests/selectors-misc.spec.ts +++ b/tests/selectors-misc.spec.ts @@ -27,8 +27,8 @@ it('should work for open shadow roots', async ({page, server}) => { expect(await page.$$(`data-testid:light=foo`)).toEqual([]); }); -it('should click on links in shadow dom', async ({page, server, browserName, browserVersion, isElectron, isAndroid}) => { - it.fixme(browserName === 'chromium' && Number(browserVersion.split('.')[0]) < 91, 'Remove when crrev.com/864024 gets to the stable channel'); +it('should click on links in shadow dom', async ({page, server, browserName, browserMajorVersion, isElectron, isAndroid}) => { + it.fixme(browserName === 'chromium' && browserMajorVersion < 91, 'Remove when crrev.com/864024 gets to the stable channel'); it.fixme(isAndroid); it.fixme(isElectron);