test: unflake "should have correct snapshot size" (#9099)

This commit is contained in:
Dmitry Gozman 2021-09-23 11:40:55 -07:00 committed by GitHub
parent 89aace688f
commit 1fb9d21223
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,6 +27,7 @@ class TraceViewerPage {
consoleStacks: Locator;
stackFrames: Locator;
networkRequests: Locator;
snapshotContainer: Locator;
constructor(public page: Page) {
this.actionTitles = page.locator('.action-title');
@ -36,6 +37,7 @@ class TraceViewerPage {
this.consoleStacks = page.locator('.console-stack');
this.stackFrames = page.locator('.stack-trace-frame');
this.networkRequests = page.locator('.network-request-title');
this.snapshotContainer = page.locator('.snapshot-container');
}
async actionIconsText(action: string) {
@ -79,13 +81,6 @@ class TraceViewerPage {
const result = [...set];
return result.sort();
}
async snapshotSize() {
return this.page.$eval('.snapshot-container', e => {
const style = window.getComputedStyle(e);
return { width: style.width, height: style.height };
});
}
}
const test = playwrightTest.extend<{ showTraceViewer: (trace: string) => Promise<TraceViewerPage> }>({
@ -213,13 +208,15 @@ test('should show params and return value', async ({ showTraceViewer, browserNam
]);
});
test('should have correct snapshot size', async ({ showTraceViewer }) => {
test('should have correct snapshot size', async ({ showTraceViewer }, testInfo) => {
const traceViewer = await showTraceViewer(traceFile);
await traceViewer.selectAction('page.setViewport');
await traceViewer.selectSnapshot('Before');
expect(await traceViewer.snapshotSize()).toEqual({ width: '1280px', height: '720px' });
await expect(traceViewer.snapshotContainer).toHaveCSS('width', '1280px');
await expect(traceViewer.snapshotContainer).toHaveCSS('height', '720px');
await traceViewer.selectSnapshot('After');
expect(await traceViewer.snapshotSize()).toEqual({ width: '500px', height: '600px' });
await expect(traceViewer.snapshotContainer).toHaveCSS('width', '500px');
await expect(traceViewer.snapshotContainer).toHaveCSS('height', '600px');
});
test('should have correct stack trace', async ({ showTraceViewer }) => {