Skip to content

Conversation

mashalifshin
Copy link
Contributor

@mashalifshin mashalifshin commented Aug 22, 2025

Problem Statement

We need unique alt text on the ad images for our accessible-first Playwright tests to pass in the example apps, as that's the accessible way to select our ad elements.

Proposed Changes

We now construct alt text for the ad images on the client side in order to contextualize what kind of ad it is for users who aren't navigating visually. And we get the unique ids for the Playwright tests exactly as we need them.

Verification Steps

  • Load and inspect the examples and make sure the alt text looks good for all the ads.
  • Take a look at the new unit test in display.test.ts in core and make sure it's covering all the cases

@@ -13,7 +13,7 @@ export const IS_PRODUCTION = process.env.NODE_ENV === "production"

export const DEFAULT_SERVICE_ENDPOINT: HTTPSURLString = IS_PRODUCTION
? "https://ads.mozilla.org/" // production
: "https://ads.allizom.org/" // staging
: "https://ads.mozilla.org/" // staging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ehhh.. can we just update playwright to set NODE_ENV=production instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, apologies for the mess, that would absolutely be the right way to do it, I will make that change. This was just me trying out a quick way to make sure this approach would work

@@ -6,7 +6,7 @@ describe("core/constants.ts", () => {
})

test("Use staging endpoint URLs when not in production", () => {
expect(DEFAULT_SERVICE_ENDPOINT).toBe("https://ads.allizom.org/")
expect(DEFAULT_SERVICE_ENDPOINT).toBe("https://ads.mozilla.org/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't testing the right thing anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thank you so much. Will fix.

@mashalifshin mashalifshin changed the title Fix playwright end to end tests Fix Playwright tests by adding more descriptive alt text to ad images Aug 26, 2025
@mashalifshin mashalifshin marked this pull request as ready for review August 26, 2025 01:42
@mashalifshin mashalifshin requested a review from a team as a code owner August 26, 2025 01:42
"example:iife": "npm run build && cd examples/iife && npm install && npm run dev",
"example:react": "npm run build && cd examples/react && npm install && npm run dev",
"example:iife": "npm run build:production && cd examples/iife && npm install && npm run dev",
"example:react": "npm run build:production && cd examples/react && npm install && npm run dev",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add example:iife:staging and example:react:staging scripts here to be able to also explicitly run the examples against staging (not as the default)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants