-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
test: add test setup for dev overlay #8932
Changes from 4 commits
26ae35a
f913f11
589b8db
3c90f75
4ae3a59
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { expect } from '@playwright/test'; | ||
import { testFactory } from './test-utils.js'; | ||
|
||
const test = testFactory({ | ||
root: './fixtures/dev-overlay/', | ||
}); | ||
|
||
let devServer; | ||
|
||
test.beforeAll(async ({ astro }) => { | ||
devServer = await astro.startDevServer(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await devServer.stop(); | ||
}); | ||
|
||
test.describe('Dev Overlay zzz', () => { | ||
test('dev overlay exists in the page', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
const devOVerlay = page.locator('astro-dev-overlay'); | ||
await expect(devOVerlay).toHaveCount(1); | ||
}); | ||
|
||
test('can open Astro plugin', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
const overlay = page.locator('astro-dev-overlay'); | ||
const pluginButton = overlay.locator('button[data-plugin-id="astro"]'); | ||
await pluginButton.click(); | ||
|
||
const astroPluginCanvas = overlay.locator( | ||
'astro-dev-overlay-plugin-canvas[data-plugin-id="astro"]' | ||
); | ||
const astroWindow = astroPluginCanvas.locator('astro-dev-overlay-window'); | ||
await expect(astroWindow).toHaveCount(1); | ||
await expect(astroWindow).toBeVisible(); | ||
|
||
// Toggle plugin off | ||
await pluginButton.click(); | ||
await expect(astroWindow).not.toBeVisible(); | ||
}); | ||
|
||
test('xray shows highlights and tooltips', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
const overlay = page.locator('astro-dev-overlay'); | ||
const pluginButton = overlay.locator('button[data-plugin-id="astro:xray"]'); | ||
await pluginButton.click(); | ||
|
||
const xrayCanvas = overlay.locator( | ||
'astro-dev-overlay-plugin-canvas[data-plugin-id="astro:xray"]' | ||
); | ||
const xrayHighlight = xrayCanvas.locator('astro-dev-overlay-highlight'); | ||
await expect(xrayHighlight).toBeVisible(); | ||
|
||
await xrayHighlight.hover(); | ||
const xrayHighlightTooltip = xrayHighlight.locator('astro-dev-overlay-tooltip'); | ||
await expect(xrayHighlightTooltip).toBeVisible(); | ||
|
||
// Toggle plugin off | ||
await pluginButton.click(); | ||
await expect(xrayHighlight).not.toBeVisible(); | ||
await expect(xrayHighlightTooltip).not.toBeVisible(); | ||
}); | ||
|
||
test('audit shows higlights and tooltips', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
const overlay = page.locator('astro-dev-overlay'); | ||
const pluginButton = overlay.locator('button[data-plugin-id="astro:audit"]'); | ||
await pluginButton.click(); | ||
|
||
const auditCanvas = overlay.locator( | ||
'astro-dev-overlay-plugin-canvas[data-plugin-id="astro:audit"]' | ||
); | ||
const auditHighlight = auditCanvas.locator('astro-dev-overlay-highlight'); | ||
await expect(auditHighlight).toBeVisible(); | ||
|
||
await auditHighlight.hover(); | ||
const auditHighlightTooltip = auditHighlight.locator('astro-dev-overlay-tooltip'); | ||
await expect(auditHighlightTooltip).toBeVisible(); | ||
|
||
// Toggle plugin off | ||
await pluginButton.click(); | ||
await expect(auditHighlight).not.toBeVisible(); | ||
await expect(auditHighlightTooltip).not.toBeVisible(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import preact from '@astrojs/preact'; | ||
|
||
export default { | ||
integrations: [preact()], | ||
experimental: { | ||
devOverlay: true | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@e2e/dev-overlay", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/preact": "workspace:*", | ||
"astro": "workspace:*", | ||
"preact": "^10.17.1" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function HelloWorld({ name }) { | ||
return <div>Hello {name}! I'm a component!</div>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
import { HelloWorld } from "../components/HelloWorld"; | ||
--- | ||
|
||
<HelloWorld name={"Dev Overlay"} client:load /> | ||
|
||
<img src="https://astro.build/assets/press/astro-logo-dark.svg" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ export class DevOverlayWindow extends HTMLElement { | |
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; | ||
color: rgba(204, 206, 216, 1); | ||
position: fixed; | ||
z-index: 9999999999; | ||
z-index: 999999999; | ||
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. This caused the window to appear over the dev overlay, which made it impossible to click. 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. Might be nice to extract each If there's a good reason you're not already doing that, ignore me! 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's no reason not to, I think. Will refactor in a separate PR! |
||
top: 55%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The virtual Playwright window is quite small, and somehow in some cases it couldn't see the tooltip. This is generally just a good change, because the tooltip could get quite long (ex: the docs sidebars)