release: v0.12.0 (#520)
Forty-one commits since v0.11.0. See CHANGELOG.md for the full list and the upgrade notes.
This commit is contained in:
64
e2e/lightbox-fullscreen.spec.ts
Normal file
64
e2e/lightbox-fullscreen.spec.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* `f` is only worth having if it reaches the real Fullscreen API — a CSS
|
||||
* overlay already covered the viewport before this, and the whole point is the
|
||||
* browser chrome that CSS cannot touch. So these assert on
|
||||
* `document.fullscreenElement`, not on a class name.
|
||||
*/
|
||||
test.describe('Lightbox fullscreen', () => {
|
||||
const GRID_URL = '/deutschland/kloster-chorin';
|
||||
|
||||
/** Open the first photo and wait for the viewer. */
|
||||
async function openLightbox(page: import('@playwright/test').Page) {
|
||||
await page.goto(GRID_URL);
|
||||
const item = page.locator('.photo-grid .photo-grid__item').first();
|
||||
await item.scrollIntoViewIfNeeded();
|
||||
await item.click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
}
|
||||
|
||||
const fullscreenTag = (page: import('@playwright/test').Page) =>
|
||||
page.evaluate(() => document.fullscreenElement?.tagName ?? null);
|
||||
|
||||
test('f enters fullscreen and f leaves it again', async ({ page }) => {
|
||||
await openLightbox(page);
|
||||
expect(await fullscreenTag(page)).toBeNull();
|
||||
|
||||
await page.keyboard.press('f');
|
||||
await expect.poll(() => fullscreenTag(page)).toBe('DIV');
|
||||
|
||||
await page.keyboard.press('f');
|
||||
await expect.poll(() => fullscreenTag(page)).toBeNull();
|
||||
});
|
||||
|
||||
test('Esc leaves fullscreen before it closes the viewer', async ({ page }) => {
|
||||
await openLightbox(page);
|
||||
await page.keyboard.press('f');
|
||||
await expect.poll(() => fullscreenTag(page)).toBe('DIV');
|
||||
|
||||
await page.keyboard.press('Escape');
|
||||
await expect.poll(() => fullscreenTag(page)).toBeNull();
|
||||
// One layer at a time: the viewer is still open.
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(page.getByRole('dialog')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('closing the viewer does not strand the page in fullscreen', async ({ page }) => {
|
||||
await openLightbox(page);
|
||||
await page.keyboard.press('f');
|
||||
await expect.poll(() => fullscreenTag(page)).toBe('DIV');
|
||||
|
||||
await page.getByRole('button', { name: /close/i }).click();
|
||||
await expect(page.getByRole('dialog')).toHaveCount(0);
|
||||
await expect.poll(() => fullscreenTag(page)).toBeNull();
|
||||
});
|
||||
|
||||
test('the shortcut panel advertises the key', async ({ page }) => {
|
||||
await openLightbox(page);
|
||||
await page.keyboard.press('?');
|
||||
await expect(page.getByText(/fullscreen|vollbild/i).first()).toBeVisible();
|
||||
});
|
||||
});
|
||||
55
e2e/lightbox-shortcuts.spec.ts
Normal file
55
e2e/lightbox-shortcuts.spec.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* The shortcut panel is deliberately unadvertised: no button, no first-run
|
||||
* nudge. These pin both halves of that — the keys work, and nothing is on
|
||||
* screen until one of them is pressed.
|
||||
*/
|
||||
test.describe('Lightbox shortcuts', () => {
|
||||
const GRID_URL = '/deutschland/kloster-chorin';
|
||||
|
||||
async function openLightbox(page: import('@playwright/test').Page) {
|
||||
await page.goto(GRID_URL);
|
||||
const item = page.locator('.photo-grid .photo-grid__item').first();
|
||||
await item.scrollIntoViewIfNeeded();
|
||||
await item.click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
}
|
||||
|
||||
const panel = (page: import('@playwright/test').Page) => page.locator('#lightbox-shortcuts');
|
||||
|
||||
test('nothing advertises the panel', async ({ page }) => {
|
||||
await openLightbox(page);
|
||||
await expect(panel(page)).toHaveCount(0);
|
||||
// The old trigger and its one-time nudge are gone for good.
|
||||
await expect(page.getByRole('button', { name: /keyboard shortcuts/i })).toHaveCount(0);
|
||||
await expect(page.getByText(/press \? for keyboard shortcuts/i)).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('? opens it and closes it again', async ({ page }) => {
|
||||
await openLightbox(page);
|
||||
await page.keyboard.press('?');
|
||||
await expect(panel(page)).toBeVisible();
|
||||
await page.keyboard.press('?');
|
||||
await expect(panel(page)).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('h opens it too', async ({ page }) => {
|
||||
await openLightbox(page);
|
||||
await page.keyboard.press('h');
|
||||
await expect(panel(page)).toBeVisible();
|
||||
});
|
||||
|
||||
test('Esc closes the panel before the viewer', async ({ page }) => {
|
||||
await openLightbox(page);
|
||||
await page.keyboard.press('h');
|
||||
await expect(panel(page)).toBeVisible();
|
||||
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(panel(page)).toHaveCount(0);
|
||||
await expect(page.getByRole('dialog')).toBeVisible();
|
||||
|
||||
await page.keyboard.press('Escape');
|
||||
await expect(page.getByRole('dialog')).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user