Skip to content

Add playwright image comparison tests #37

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

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ci/single_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export default defineConfig({
command: 'npm run serve',
url: 'http://localhost:$PORT',
reuseExistingServer: !process.env.CI
}
},
snapshotPathTemplate: '{testDir}/../../../../tests/snapshots/{arg}{ext}'
});
EOF

Expand Down
9 changes: 6 additions & 3 deletions ci/tests/example.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('loads bokehjs', async ({ page }) => {
test('is interactive', async ({ page }) => {
await page.goto('/');

// Take screenshot
await expect(page).toHaveScreenshot('initial.png');

const boxZoom = await page.getByTitle('Box Zoom').click();
const bbox = await page.locator('.bk-CartesianFrame').boundingBox();
Expand All @@ -28,9 +28,12 @@ test('is interactive', async ({ page }) => {
await page.mouse.move(bbox!.x + bbox!.width*0.8, bbox!.y + bbox!.height*0.8);
await page.mouse.up();
await page.waitForTimeout(100);
// Take screenshot

await expect(page).toHaveScreenshot('zoom.png');

const reset = await page.getByTitle('Reset').click();
await page.waitForTimeout(100);
// Take screenshot

// Reset image is the same as initial image except for tool selection
await expect(page).toHaveScreenshot('reset.png');
});
Binary file added ci/tests/snapshots/initial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ci/tests/snapshots/reset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ci/tests/snapshots/zoom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ci/typescript/create_vanilla_vite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function create_bokehjs_plot(): Bokeh.Plotting.Figure {

return plot;
}
document.querySelector<HTMLDivElement>('#app')!.innerHTML = \`<div id='target'>Hello</div>\`;
document.querySelector<HTMLDivElement>('#app')!.innerHTML = \`<div id='target'></div>\`;

Bokeh.Plotting.show(create_bokehjs_plot(), "#target");
EOF
Expand Down
2 changes: 1 addition & 1 deletion recipes/src/recipes/typescript/vanilla_vite_recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class VanillaViteRecipe extends Recipe {
baseTypeScriptExample.import + "\n" +
baseTypeScriptExample.version + "\n" +
baseTypeScriptExample.function + "\n" +
"document.querySelector<HTMLDivElement>('#app')!.innerHTML = \\`<div id='target'>Hello</div>\\`;\n\n" +
"document.querySelector<HTMLDivElement>('#app')!.innerHTML = \\`<div id='target'></div>\\`;\n\n" +
baseTypeScriptExample.show()
));

Expand Down
2 changes: 1 addition & 1 deletion typescript/vanilla_vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Create an initial basic project using `create-vite`.

return plot;
}
document.querySelector<HTMLDivElement>('#app')!.innerHTML = `<div id='target'>Hello</div>`;
document.querySelector<HTMLDivElement>('#app')!.innerHTML = `<div id='target'></div>`;

Bokeh.Plotting.show(create_bokehjs_plot(), "#target");

Expand Down