diff --git a/test/e2e/tests/helpers.ts b/test/e2e/tests/helpers.ts index 9d39bc9..694dac3 100644 --- a/test/e2e/tests/helpers.ts +++ b/test/e2e/tests/helpers.ts @@ -4,8 +4,13 @@ import path from "path"; /** * Uploads a photo to the server, redirects to the photo page * @param page {Page} + * @param photo {object} - The photo object to upload, overrides the default values + * @returns {Promise<{photo: object, goToPhoto: Function}>} - The uploaded photo object and a function to navigate to the photo page if needed */ -export const uploadPhoto = async (page: Page, photo: any = {}) => { +export const uploadPhoto = async ( + page: Page, + photo: any = {} +): Promise<{ photo: object; goToPhoto: Function }> => { await page.goto("/fh"); photo = Object.assign( @@ -30,7 +35,11 @@ export const uploadPhoto = async (page: Page, photo: any = {}) => { await expect(uploadForm).toContainText(photo.title); await page.fill("#photo_tags", photo.tags.join(", ")); await page.locator("button[type=submit]", { hasText: "submit" }).click(); - return { photo }; + + return { + photo, + goToPhoto: async () => await page.goto(page.url()), + }; }; export const openDeletePhotoModal = async (page: Page) => { diff --git a/test/e2e/tests/photo.spec.ts b/test/e2e/tests/photo.spec.ts index 16844e2..dbd077f 100644 --- a/test/e2e/tests/photo.spec.ts +++ b/test/e2e/tests/photo.spec.ts @@ -34,6 +34,7 @@ test.describe("Photo Page: Static", () => { }); test("can download photo", async ({ page, context }) => { + await uploadPhoto(page); const downloadPromise = page.waitForEvent("download"); await page.locator("a", { hasText: "Download" }).click(); diff --git a/test/e2e/tests/recipe.spec.ts b/test/e2e/tests/recipe.spec.ts index 32872b7..7663057 100644 --- a/test/e2e/tests/recipe.spec.ts +++ b/test/e2e/tests/recipe.spec.ts @@ -1,11 +1,10 @@ import { test, expect } from "../fixtures/axe-test"; import { recipeManagementEnabled, userFixture } from "./helpers"; -test.describe("User Settings page", () => { +test.describe("Recipe page", () => { test.beforeEach(async ({ page }) => { if (recipeManagementEnabled) { - // TODO - test.fail(); + await page.goto("/fh/en_US/recipes/1"); } else { console.info( `Skipping Recipe tests because environment variables are not set.` @@ -13,4 +12,22 @@ test.describe("User Settings page", () => { test.skip(); } }); + + test("should not have any automatically detectable accessibility issues", async ({ + makeAxeBuilder, + }) => { + test.slow(); + const accessibilityScanResults = await makeAxeBuilder().analyze(); + expect(accessibilityScanResults.violations).toEqual([]); + }); + + test("should not have any automatically detectable accessibility issues in dark mode", async ({ + page, + makeAxeBuilder, + }) => { + test.slow(); + await page.emulateMedia({ colorScheme: "dark" }); + const accessibilityScanResults = await makeAxeBuilder().analyze(); + expect(accessibilityScanResults.violations).toEqual([]); + }); });