harden media
This commit is contained in:
@@ -277,6 +277,32 @@ async function runWebsiteSmokeScenario(args: {
|
||||
consoleErrors.length,
|
||||
`Console errors on route ${resolvedPath} (auth=${scenario.auth}):\n${consoleErrors.join('\n')}`,
|
||||
).toBe(0);
|
||||
|
||||
// Verify images with /media/* paths are shown correctly
|
||||
const mediaImages = await page.locator('img[src*="/media/"]').all();
|
||||
|
||||
for (const img of mediaImages) {
|
||||
const src = await img.getAttribute('src');
|
||||
const alt = await img.getAttribute('alt');
|
||||
const isVisible = await img.isVisible();
|
||||
|
||||
// Check that src starts with /media/
|
||||
expect(src, `Image src should start with /media/ on route ${resolvedPath}`).toMatch(/^\/media\//);
|
||||
|
||||
// Check that alt text exists (for accessibility)
|
||||
expect(alt, `Image should have alt text on route ${resolvedPath}`).toBeTruthy();
|
||||
|
||||
// Check that image is visible
|
||||
expect(isVisible, `Image with src="${src}" should be visible on route ${resolvedPath}`).toBe(true);
|
||||
|
||||
// Check that image loads without errors
|
||||
const naturalWidth = await img.evaluate((el: HTMLImageElement) => el.naturalWidth);
|
||||
const naturalHeight = await img.evaluate((el: HTMLImageElement) => el.naturalHeight);
|
||||
|
||||
// Image should have loaded (natural dimensions > 0)
|
||||
expect(naturalWidth, `Image with src="${src}" should have loaded properly`).toBeGreaterThan(0);
|
||||
expect(naturalHeight, `Image with src="${src}" should have loaded properly`).toBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
test.describe('Website smoke - all pages render', () => {
|
||||
|
||||
Reference in New Issue
Block a user