-
Notifications
You must be signed in to change notification settings - Fork 108
e2e test - zoom plot #8370
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
e2e test - zoom plot #8370
Changes from all commits
a63402a
91b6a64
971219a
611b6df
335b381
5a05193
2215759
6d460d8
61b97df
5983b5a
e386dc5
1648f98
4f5177f
cb23857
1a4f902
1d3d802
da94551
adc5d96
395ab06
737a7ad
4b9679f
2eb8a0e
331bcaf
6ceef60
57d394b
263c969
cd0b469
f90c000
c042048
a700f94
61bc3db
dc46124
68b099f
3615e10
66ef3c4
11fac55
3f89b05
06c1865
5bacc6c
056ed16
27d941c
6d532cb
83cf3b6
a36cf0d
7d1fc88
4471693
c390d8c
8216acb
d265821
63d2231
c834665
51f247b
e6500cd
087209d
14d06ce
cf2cf44
40bcbbf
0f21180
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 |
---|---|---|
|
@@ -281,6 +281,44 @@ test.describe('Plots', { tag: [tags.PLOTS, tags.EDITOR] }, () => { | |
const data = await resembleCompareImages(bufferAfterZoom, bufferBeforeZoom, options); | ||
expect(data.rawMisMatchPercentage).toBeGreaterThan(0.0); | ||
}); | ||
|
||
test('Python - Verify Plot Zoom works (Fit vs. 200%)', async function ({ app, contextMenu, openFile, python, page }, testInfo) { | ||
await openFile(path.join('workspaces', 'python-plots', 'matplotlib-zoom-example.py')); | ||
await test.step('Run Python File in Console', async () => { | ||
await app.workbench.editor.playButton.click(); | ||
await app.workbench.plots.waitForCurrentPlot(); | ||
}); | ||
const imgLocator = page.getByRole('img', { name: /%run/ }); | ||
await contextMenu.triggerAndClick({ | ||
menuTrigger: page.getByLabel('Fit'), | ||
menuItemLabel: 'Fit' | ||
}); | ||
await page.waitForTimeout(300); | ||
const bufferFit1 = await imgLocator.screenshot(); | ||
await contextMenu.triggerAndClick({ | ||
menuTrigger: page.getByLabel('Fit'), | ||
menuItemLabel: '200%' | ||
}); | ||
await page.waitForTimeout(2000); | ||
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. Is there a way to check for the plot instead of a wait? These can just be very brittle, but sometimes I know they are unavoidable. 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. There is a way, which I had adopted before pushing this. The problem is that the "plot" appears and then there is a lagging-shimmering effect that occurs (hence messing up with screenshot). Do you think it'd be better to add the wait and then the timeout afterwards, just to be safe (and to have more specific error if it occurs)? 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. Ha. Great minds think alike. 🤓 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. Is it acceptable for the test to check image size instead? The zoom level affects the image scaling and that should be a resilient check over comparing to reference images. I could also add some class attributes to the 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. Just as a note: this doesn't actually use reference images, but rather the buffers returned from page.screenshot(). Thats not to say that using the sizes wouldn't also work... just not sure what the size of a truncated image is in playwright. |
||
const bufferZoom = await imgLocator.screenshot(); | ||
// Compare: Fit vs 200% | ||
const resultZoom = await resembleCompareImages(bufferFit1, bufferZoom, options); | ||
await testInfo.attach('fit-vs-zoom', { | ||
body: resultZoom.getBuffer(true), | ||
contentType: 'image/png' | ||
}); | ||
expect(resultZoom.rawMisMatchPercentage).toBeGreaterThan(2); // should be large diff | ||
await contextMenu.triggerAndClick({ | ||
menuTrigger: page.getByLabel('200%'), | ||
menuItemLabel: 'Fit' | ||
}); | ||
await page.waitForTimeout(2000); | ||
const bufferFit2 = await imgLocator.screenshot(); | ||
// Compare: Fit vs Fit again | ||
const resultBack = await resembleCompareImages(bufferFit1, bufferFit2, options); | ||
expect(resultBack.rawMisMatchPercentage).toBeLessThan(0.5); // should be small diff | ||
}); | ||
|
||
}); | ||
|
||
test.describe('R Plots', { | ||
|
Uh oh!
There was an error while loading. Please reload this page.