test: cover publishing, authentication and storage persistence

This commit is contained in:
2026-09-15 21:48:15 +03:30
parent ee9f49e4b7
commit c17b4b57b2
11 changed files with 294 additions and 23 deletions

View File

@@ -16,6 +16,9 @@ test('a pointer click on the card CTA opens a route-backed drawer and restores t
});
const card = page.getByRole('article', { name: 'Qlockify' });
const cta = card.getByRole('link', { name: 'View case study' });
// Measure the viewport from which the user actually clicks, after any
// automatic scroll needed to bring the link into view.
await cta.scrollIntoViewIfNeeded();
const portfolioScroll = await page.evaluate(() => window.scrollY);
await cta.click();
@@ -48,6 +51,9 @@ test('a shared route opens over the portfolio and adjacent navigation replaces h
});
test('share fallback, copy feedback, focus containment, and the localized RTL route work', async ({ page, context }) => {
// This test exercises the fallback. Native mobile share sheets are outside
// the DOM and are covered separately through the supported-share branch.
await page.addInitScript(() => Object.defineProperty(navigator, 'share', { configurable: true, value: undefined }));
await context.grantPermissions(['clipboard-read', 'clipboard-write']);
await page.goto('/fa/projects/qlockify', { waitUntil: 'domcontentloaded' });
const dialog = await expectDrawerOpen(page);
@@ -68,7 +74,16 @@ test('share fallback, copy feedback, focus containment, and the localized RTL ro
expect(await page.evaluate(() => document.activeElement?.closest('dialog') !== null)).toBe(true);
});
test('the gallery serves original media and opens an accessible full-screen viewer', async ({ page }) => {
test('mobile uses native sharing when it is available', async ({ page, isMobile }) => {
test.skip(!isMobile, 'Native sharing is used on compact layouts');
await page.addInitScript(() => Object.defineProperty(navigator, 'share', { configurable: true, value: async (data: ShareData) => { document.documentElement.dataset.sharedUrl = data.url; } }));
await page.goto(caseStudyPath, { waitUntil: 'domcontentloaded' });
const dialog = await expectDrawerOpen(page);
await dialog.getByRole('button', { name: 'Share this case study' }).click();
await expect(page.locator('html')).toHaveAttribute('data-shared-url', new RegExp(`${caseStudyPath}$`));
});
test('the gallery serves original media and opens an accessible full-screen viewer', async ({ page, isMobile }) => {
await page.goto(caseStudyPath, { waitUntil: 'domcontentloaded' });
const drawer = await expectDrawerOpen(page);
const stage = drawer.getByRole('button', { name: /Open full-screen image/ });
@@ -79,7 +94,11 @@ test('the gallery serves original media and opens an accessible full-screen view
const viewer = page.getByRole('dialog', { name: 'Full-screen project gallery' });
await expect(viewer).toBeVisible();
await expect(viewer.getByText('1 of 8')).toBeVisible();
await viewer.getByRole('button', { name: 'Next image' }).click();
if (isMobile) {
await viewer.getByRole('button', { name: /^Show image 2:/ }).click();
} else {
await viewer.getByRole('button', { name: 'Next image' }).click();
}
await expect(viewer.getByText('2 of 8')).toBeVisible();
await viewer.getByRole('button', { name: 'Close full-screen image' }).click();
await expect(stage).toBeFocused();