Skip to content

Commit

Permalink
test: add a test for focused input screenshot (#5060)
Browse files Browse the repository at this point in the history
Fails in various configurations.
  • Loading branch information
dgozman committed Jan 22, 2021
1 parent a9b7536 commit 018727d
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 1 deletion.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 29 additions & 1 deletion test/headful.spec.ts
Expand Up @@ -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 });
Expand Down Expand Up @@ -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');
});

0 comments on commit 018727d

Please sign in to comment.