test: add a test for focused input screenshot (#5060)

Fails in various configurations.
This commit is contained in:
Dmitry Gozman 2021-01-22 06:51:59 -08:00 committed by GitHub
parent a9b75365eb
commit 018727db8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 29 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View file

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { it, expect } from './fixtures';
import { it, expect, folio } from './fixtures';
it('should have default url when launching browser', async ({browserType, browserOptions, createUserDataDir}) => {
const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), {...browserOptions, headless: false });
@ -168,3 +168,31 @@ it('Page.bringToFront should work', async ({browserType, browserOptions}) => {
);
await browser.close();
});
const fixtures = folio.extend();
fixtures.testParametersPathSegment.override(async ({ browserName, platform }, run) => {
await run(browserName + '-' + platform);
});
fixtures.build().it('focused input should produce the same screenshot', (test, { browserName, platform }) => {
test.fail(browserName === 'firefox' && platform === 'darwin', 'headless has thinner outline');
test.fail(browserName === 'firefox' && platform === 'linux', 'headless has no outline');
test.skip(browserName === 'webkit' && platform === 'linux', 'gtk vs wpe');
test.fail(browserName === 'chromium', 'Different outline color');
}, async ({browserType, browserOptions}) => {
const headful = await browserType.launch({...browserOptions, headless: false });
const headfulPage = await headful.newPage();
await headfulPage.setContent('<input>');
await headfulPage.focus('input');
const headfulScreenshot = await headfulPage.screenshot();
await headful.close();
const headless = await browserType.launch({...browserOptions, headless: true });
const headlessPage = await headless.newPage();
await headlessPage.setContent('<input>');
await headlessPage.focus('input');
const headlessScreenshot = await headlessPage.screenshot();
await headless.close();
expect(headfulScreenshot).toMatchSnapshot('focused-input.png');
expect(headlessScreenshot).toMatchSnapshot('focused-input.png');
});