From 687f34fbdc8526defea0857ba2dd59ed67551bcb Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Wed, 6 May 2026 02:22:10 +0000 Subject: [PATCH] harden affiliates e2e against popup races and copy churn - waitForEvent('page') resolves when the new tab is created, not when it has navigated, so popup.url() could return 'about:blank' before the forms.gle redirect chain settles. Add popup.waitForLoadState('domcontentloaded') so the URL assertion always reads the post-redirect URL. - The FAQ toggle test was hardcoding the question and answer copy. If src/i18n/translations.ts changes the copy, the locator silently stops matching. Resolve the first FAQ's question/answer from the same translation keys the page renders ('affiliate-landing.faq.1.q' and '.a'), so the test tracks the real source of truth. --- apps/website/e2e/affiliates.spec.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/apps/website/e2e/affiliates.spec.ts b/apps/website/e2e/affiliates.spec.ts index af088df32c..ac7038e073 100644 --- a/apps/website/e2e/affiliates.spec.ts +++ b/apps/website/e2e/affiliates.spec.ts @@ -1,8 +1,22 @@ import { expect } from '@playwright/test' -import { AFFILIATE_FAQ_COUNT } from '../src/components/affiliates/affiliateFaqs' +import { + AFFILIATE_FAQ_COUNT, + AFFILIATE_FAQ_PREFIX +} from '../src/components/affiliates/affiliateFaqs' +import type { TranslationKey } from '../src/i18n/translations' +import { t } from '../src/i18n/translations' import { test } from './fixtures/blockExternalMedia' +const FIRST_FAQ_QUESTION = t( + `${AFFILIATE_FAQ_PREFIX}.1.q` as TranslationKey, + 'en' +) +const FIRST_FAQ_ANSWER = t( + `${AFFILIATE_FAQ_PREFIX}.1.a` as TranslationKey, + 'en' +) + const PATH = '/affiliates' const APPLY_URL = 'https://forms.gle/RS8L2ttcuGap4Q1v6' @@ -115,6 +129,7 @@ test.describe('Affiliates landing — desktop interactions', () => { const popupPromise = context.waitForEvent('page') await page.getByTestId('affiliate-hero-cta').click() const popup = await popupPromise + await popup.waitForLoadState('domcontentloaded') const popupUrl = popup.url() expect( popupUrl.includes('forms.gle/RS8L2ttcuGap4Q1v6') || @@ -124,16 +139,12 @@ test.describe('Affiliates landing — desktop interactions', () => { }) test('FAQ items toggle open and closed on click', async ({ page }) => { - const firstQuestion = page.getByRole('button', { - name: 'How do I track my referrals?' - }) + const firstQuestion = page.getByRole('button', { name: FIRST_FAQ_QUESTION }) await expect(firstQuestion).toHaveAttribute('aria-expanded', 'false') await firstQuestion.click() await expect(firstQuestion).toHaveAttribute('aria-expanded', 'true') - await expect( - page.getByText('Real-time dashboard via our partner portal.') - ).toBeVisible() + await expect(page.getByText(FIRST_FAQ_ANSWER)).toBeVisible() await firstQuestion.click() await expect(firstQuestion).toHaveAttribute('aria-expanded', 'false')