From f1b2a08691eb8eddb3ee395af6feaf695c57e5e7 Mon Sep 17 00:00:00 2001 From: Sem Bauke Date: Fri, 22 Nov 2024 19:52:01 +0100 Subject: [PATCH] chore: set default login state playwright (#57277) --- e2e/c-sharp.spec.ts | 1 - e2e/cert-username-case-navigation.spec.ts | 1 - e2e/certification.spec.ts | 3 - e2e/challenge-reset-modal.spec.ts | 97 ++++++++++++---------- e2e/challenge-title.spec.ts | 2 - e2e/code-storage.spec.ts | 1 - e2e/codeally.spec.ts | 2 - e2e/completion-modal.spec.ts | 3 +- e2e/delete-modal.spec.ts | 2 - e2e/desktop-layout.spec.ts | 2 - e2e/donate-page-default.spec.ts | 2 - e2e/donation-modal.spec.ts | 5 -- e2e/edit-profile-modal.spec.ts | 2 - e2e/editor.spec.ts | 4 - e2e/email-settings.spec.ts | 2 - e2e/exam-results-modal.spec.ts | 2 - e2e/exam-results.spec.ts | 2 - e2e/exam-show-non-qualified.spec.ts | 2 +- e2e/exam-show-qualified.spec.ts | 2 - e2e/exam-started-show.spec.ts | 2 - e2e/exam-survey.spec.ts | 1 - e2e/exam-token.spec.ts | 2 - e2e/exit-exam-modal.spec.ts | 2 - e2e/finish-exam-modal.spec.ts | 2 - e2e/flash.spec.ts | 1 - e2e/form-helper.spec.ts | 2 - e2e/global-setup.ts | 10 +++ e2e/header.spec.ts | 2 - e2e/help-modal.spec.ts | 2 - e2e/hotkeys.spec.ts | 2 - e2e/image-picture-check.spec.ts | 2 - e2e/internet-presence-settings.spec.ts | 2 - e2e/learn.spec.ts | 2 - e2e/link-ms-user.spec.ts | 2 +- e2e/mobile-layout.spec.ts | 2 - e2e/ms-trophy-show.spec.ts | 2 +- e2e/multifile-cert-projects.spec.ts | 1 - e2e/navigation-from-last-challenge.spec.ts | 1 - e2e/profile.spec.ts | 3 - e2e/progress-bar.spec.ts | 2 - e2e/progress-reset-modal.spec.ts | 2 - e2e/quincy-email-sign-up.spec.ts | 2 - e2e/quiz-challenge.spec.ts | 2 - e2e/report-user.spec.ts | 1 - e2e/scrollbar-width.spec.ts | 2 +- e2e/settings.spec.ts | 4 - e2e/shortcuts-modal.spec.ts | 2 - e2e/show-cert-from-superblock.spec.ts | 2 - e2e/show-certificate-else.spec.ts | 1 + e2e/show-certificate-own.spec.ts | 2 - e2e/show.spec.ts | 2 - e2e/signin.spec.ts | 1 + e2e/signout-modal.spec.ts | 2 - e2e/solution-viewer.spec.ts | 2 - e2e/third-party-donation.spec.ts | 1 - e2e/update-about-me.spec.ts | 2 - e2e/update-email.spec.ts | 2 - e2e/update-stripe-card-default.spec.ts | 1 - e2e/username-change.spec.ts | 1 - playwright.config.ts | 2 +- 60 files changed, 70 insertions(+), 150 deletions(-) diff --git a/e2e/c-sharp.spec.ts b/e2e/c-sharp.spec.ts index 9373a87b757..22a273f9c1b 100644 --- a/e2e/c-sharp.spec.ts +++ b/e2e/c-sharp.spec.ts @@ -1,6 +1,5 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); const checkAnswerButtonText = translations.buttons['check-answer']; const askForHelpButtonText = translations.buttons['ask-for-help']; const trophyButtonText = translations.buttons['verify-trophy']; diff --git a/e2e/cert-username-case-navigation.spec.ts b/e2e/cert-username-case-navigation.spec.ts index 9da76f01537..7ccb5a2d130 100644 --- a/e2e/cert-username-case-navigation.spec.ts +++ b/e2e/cert-username-case-navigation.spec.ts @@ -2,7 +2,6 @@ import { execSync } from 'child_process'; import { expect, test } from '@playwright/test'; test.describe('Public profile certifications', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); test('Should show claimed certifications if the username has all lowercase characters', async ({ page }) => { diff --git a/e2e/certification.spec.ts b/e2e/certification.spec.ts index 5abf3883644..74012408437 100644 --- a/e2e/certification.spec.ts +++ b/e2e/certification.spec.ts @@ -3,8 +3,6 @@ import { test, expect, Page } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; import { alertToBeVisible } from './utils/alerts'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.describe('Certification page - Non Microsoft', () => { test.beforeEach(async ({ page }) => { await page.goto('/certification/certifieduser/responsive-web-design'); @@ -148,7 +146,6 @@ test.describe('Invalid certification page', () => { } }; test.describe('for authenticated user', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); test( 'it should redirect to / and display an error message', testInvalidCertification diff --git a/e2e/challenge-reset-modal.spec.ts b/e2e/challenge-reset-modal.spec.ts index a8dc87ad4fb..5c42de5f249 100644 --- a/e2e/challenge-reset-modal.spec.ts +++ b/e2e/challenge-reset-modal.spec.ts @@ -97,61 +97,68 @@ test('User can reset challenge', async ({ page, isMobile, browserName }) => { ).not.toBeVisible(); }); -test('User can reset classic challenge', async ({ page, isMobile }) => { - await page.goto( - '/learn/javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code' - ); +test.describe('When the user is not logged in', () => { + test.use({ storageState: { cookies: [], origins: [] } }); + test('User can reset classic challenge', async ({ page, isMobile }) => { + await page.goto( + '/learn/javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code' + ); - const challengeSolution = '// This is in-line comment'; - await focusEditor({ page, isMobile }); - await getEditors(page).fill(challengeSolution); + const challengeSolution = '// This is in-line comment'; + await focusEditor({ page, isMobile }); + await getEditors(page).fill(challengeSolution); - const submitButton = page.getByRole('button', { - name: isMobile ? translations.buttons.run : translations.buttons['run-test'] - }); - await submitButton.click(); + const submitButton = page.getByRole('button', { + name: isMobile + ? translations.buttons.run + : translations.buttons['run-test'] + }); + await submitButton.click(); - await expect( - page.locator('.view-lines').getByText(challengeSolution) - ).toBeVisible(); + await expect( + page.locator('.view-lines').getByText(challengeSolution) + ).toBeVisible(); + + if (isMobile) { + await page + .getByText(translations.learn['editor-tabs'].instructions) + .click(); + } + + await expect( + page.getByLabel(translations.icons.passed).locator('circle') + ).toBeVisible(); - if (isMobile) { await page - .getByText(translations.learn['editor-tabs'].instructions) + .getByRole('button', { + name: !isMobile + ? translations.buttons['reset-lesson'] + : translations.buttons.reset + }) .click(); - } - await expect( - page.getByLabel(translations.icons.passed).locator('circle') - ).toBeVisible(); + await page + .getByRole('button', { name: translations.buttons['reset-lesson'] }) + .click(); - await page - .getByRole('button', { - name: !isMobile - ? translations.buttons['reset-lesson'] - : translations.buttons.reset - }) - .click(); + await expect( + page.locator('.view-lines').getByText(challengeSolution) + ).not.toBeVisible(); + await expect( + page.getByLabel(translations.icons.passed).locator('circle') + ).not.toBeVisible(); + await expect( + page.getByText(translations.learn['tests-completed']) + ).not.toBeVisible(); - await page - .getByRole('button', { name: translations.buttons['reset-lesson'] }) - .click(); + if (isMobile) { + await page.getByText(translations.learn['editor-tabs'].console).click(); + } - await expect( - page.locator('.view-lines').getByText(challengeSolution) - ).not.toBeVisible(); - await expect( - page.getByLabel(translations.icons.passed).locator('circle') - ).not.toBeVisible(); - await expect( - page.getByText(translations.learn['tests-completed']) - ).not.toBeVisible(); - - if (isMobile) { - await page.getByText(translations.learn['editor-tabs'].console).click(); - } - - await expect(page.getByText(translations.learn['test-output'])).toBeVisible(); + await expect( + page.getByText(translations.learn['test-output']) + ).toBeVisible(); + }); }); test('should close when the user clicks the close button', async ({ page }) => { diff --git a/e2e/challenge-title.spec.ts b/e2e/challenge-title.spec.ts index a348a73003c..4ebd5cf1ebf 100644 --- a/e2e/challenge-title.spec.ts +++ b/e2e/challenge-title.spec.ts @@ -74,8 +74,6 @@ test.describe('Challenge Title Component (signed out)', () => { }); test.describe('Challenge Title Component (signed in)', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test('should display GreenPass after challenge completion', async ({ page }) => { diff --git a/e2e/code-storage.spec.ts b/e2e/code-storage.spec.ts index 6e539549a80..469423cf1b8 100644 --- a/e2e/code-storage.spec.ts +++ b/e2e/code-storage.spec.ts @@ -2,7 +2,6 @@ import { test, expect } from '@playwright/test'; import { getEditors } from './utils/editor'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.describe('Challenge with editor', function () { test.skip(({ isMobile }) => isMobile); test('the shortcut "Ctrl + S" saves the code', async ({ page }) => { diff --git a/e2e/codeally.spec.ts b/e2e/codeally.spec.ts index 12f9c9aac7b..8dafbc443fc 100644 --- a/e2e/codeally.spec.ts +++ b/e2e/codeally.spec.ts @@ -23,8 +23,6 @@ test.describe('Before completing the project', () => { }); test.describe('After completing the project', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeAll(() => { execSync('node ./tools/scripts/seed/seed-demo-user --certified-user'); }); diff --git a/e2e/completion-modal.spec.ts b/e2e/completion-modal.spec.ts index 60fc38d50e8..65b9494c2bb 100644 --- a/e2e/completion-modal.spec.ts +++ b/e2e/completion-modal.spec.ts @@ -16,6 +16,7 @@ test.beforeEach(async ({ page }) => { }); test.describe('Challenge Completion Modal Tests (Signed Out)', () => { + test.use({ storageState: { cookies: [], origins: [] } }); test('should render the modal correctly', async ({ page }) => { await expect(page.getByRole('heading')).toBeVisible(); await expect(page.getByRole('button', { name: 'close' })).toBeVisible(); @@ -83,8 +84,6 @@ test.describe('Challenge Completion Modal Tests (Signed Out)', () => { }); test.describe('Challenge Completion Modal Tests (Signed In)', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test('should render the modal correctly', async ({ page }) => { await expect(page.getByRole('heading')).toBeVisible(); await expect(page.getByRole('button', { name: 'close' })).toBeVisible(); diff --git a/e2e/delete-modal.spec.ts b/e2e/delete-modal.spec.ts index d6902a35253..b58b098418b 100644 --- a/e2e/delete-modal.spec.ts +++ b/e2e/delete-modal.spec.ts @@ -8,8 +8,6 @@ import { alertToBeVisible } from './utils/alerts'; const execP = promisify(exec); -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { await page.goto('/settings'); }); diff --git a/e2e/desktop-layout.spec.ts b/e2e/desktop-layout.spec.ts index b0d0f0798e7..c6862624d56 100644 --- a/e2e/desktop-layout.spec.ts +++ b/e2e/desktop-layout.spec.ts @@ -1,7 +1,5 @@ import { test, expect } from '@playwright/test'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.describe('Classic challenge - 3 pane desktop layout component', () => { test.skip( ({ isMobile }) => isMobile === true, diff --git a/e2e/donate-page-default.spec.ts b/e2e/donate-page-default.spec.ts index 66bedd3f40a..8db0315860a 100644 --- a/e2e/donate-page-default.spec.ts +++ b/e2e/donate-page-default.spec.ts @@ -1,8 +1,6 @@ import { test, expect, type Page } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - const pageElements = { mainHeading: 'main-head', donateText1: 'donate-text-1', diff --git a/e2e/donation-modal.spec.ts b/e2e/donation-modal.spec.ts index 44b2a3fca44..e3a347aeb94 100644 --- a/e2e/donation-modal.spec.ts +++ b/e2e/donation-modal.spec.ts @@ -117,8 +117,6 @@ test.describe('Donation modal display', () => { await addGrowthbookCookie({ context, variation: 'A' }); }); - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test('should display the content correctly and disable close when the animation is not complete', async ({ page, browserName, @@ -292,7 +290,6 @@ test.describe('Donation modal appearance logic - New user', () => { }); test.describe('Donation modal appearance logic - Certified user', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.beforeEach(async ({ context }) => { await addGrowthbookCookie({ context, variation: 'A' }); }); @@ -333,8 +330,6 @@ test.describe('Donation modal appearance logic - Certified user', () => { }); test.describe('Donation modal appearance logic - Donor user', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeAll(() => { execSync( 'node ./tools/scripts/seed/seed-demo-user --certified-user --set-true isDonating' diff --git a/e2e/edit-profile-modal.spec.ts b/e2e/edit-profile-modal.spec.ts index 8a41f2b122a..c45a96bf0c6 100644 --- a/e2e/edit-profile-modal.spec.ts +++ b/e2e/edit-profile-modal.spec.ts @@ -1,8 +1,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { await page.goto('/certifieduser'); diff --git a/e2e/editor.spec.ts b/e2e/editor.spec.ts index 147b772831f..f86f3a8e907 100644 --- a/e2e/editor.spec.ts +++ b/e2e/editor.spec.ts @@ -64,8 +64,6 @@ test.describe('Editor theme if the system theme is dark', () => { test.use({ colorScheme: 'dark' }); test.describe('If the user is signed in', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test('should respect the user settings', async ({ page, request }) => { const editor = page.locator("div[role='code'].monaco-editor"); @@ -96,8 +94,6 @@ test.describe('Editor theme if the system theme is light', () => { test.use({ colorScheme: 'light' }); test.describe('If the user is signed in', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test('should respect the user settings', async ({ page, request }) => { const editor = page.locator("div[role='code'].monaco-editor"); diff --git a/e2e/email-settings.spec.ts b/e2e/email-settings.spec.ts index ffc182e957e..0f12aa17246 100644 --- a/e2e/email-settings.spec.ts +++ b/e2e/email-settings.spec.ts @@ -15,8 +15,6 @@ const settingsPageElement = { const originalEmail = 'foo@bar.com'; const newEmail = 'foo-update@bar.com'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { execSync('node ./tools/scripts/seed/seed-demo-user --certified-user'); await page.goto('/settings'); diff --git a/e2e/exam-results-modal.spec.ts b/e2e/exam-results-modal.spec.ts index 16917d3d615..321fbd590a8 100644 --- a/e2e/exam-results-modal.spec.ts +++ b/e2e/exam-results-modal.spec.ts @@ -1,7 +1,5 @@ import { test, expect } from '@playwright/test'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.describe('Exam results modal', () => { test.beforeEach(async ({ page }) => { await page.goto('/settings'); diff --git a/e2e/exam-results.spec.ts b/e2e/exam-results.spec.ts index c6aa9d2e4bc..0cba6a0463c 100644 --- a/e2e/exam-results.spec.ts +++ b/e2e/exam-results.spec.ts @@ -3,8 +3,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; import intro from '../client/i18n/locales/english/intro.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - const examUrl = '/learn/foundational-c-sharp-with-microsoft/foundational-c-sharp-with-microsoft-certification-exam/foundational-c-sharp-with-microsoft-certification-exam'; diff --git a/e2e/exam-show-non-qualified.spec.ts b/e2e/exam-show-non-qualified.spec.ts index 22a8acdb3d8..bf8134baf33 100644 --- a/e2e/exam-show-non-qualified.spec.ts +++ b/e2e/exam-show-non-qualified.spec.ts @@ -4,7 +4,7 @@ import translations from '../client/i18n/locales/english/translations.json'; const examUrl = '/learn/foundational-c-sharp-with-microsoft/foundational-c-sharp-with-microsoft-certification-exam/foundational-c-sharp-with-microsoft-certification-exam'; - +test.use({ storageState: { cookies: [], origins: [] } }); test.beforeEach(async ({ page }) => { await page.goto(examUrl); }); diff --git a/e2e/exam-show-qualified.spec.ts b/e2e/exam-show-qualified.spec.ts index 73eeb5deb91..56d9cd26ac2 100644 --- a/e2e/exam-show-qualified.spec.ts +++ b/e2e/exam-show-qualified.spec.ts @@ -2,8 +2,6 @@ import { test, expect } from '@playwright/test'; import intro from '../client/i18n/locales/english/intro.json'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - const examUrl = '/learn/foundational-c-sharp-with-microsoft/foundational-c-sharp-with-microsoft-certification-exam/foundational-c-sharp-with-microsoft-certification-exam'; diff --git a/e2e/exam-started-show.spec.ts b/e2e/exam-started-show.spec.ts index ecbcb0a2fea..3b189c93789 100644 --- a/e2e/exam-started-show.spec.ts +++ b/e2e/exam-started-show.spec.ts @@ -2,8 +2,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; import intro from '../client/i18n/locales/english/intro.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - const examUrl = '/learn/foundational-c-sharp-with-microsoft/foundational-c-sharp-with-microsoft-certification-exam/foundational-c-sharp-with-microsoft-certification-exam'; diff --git a/e2e/exam-survey.spec.ts b/e2e/exam-survey.spec.ts index 28260d002fd..7ecbf43c5e0 100644 --- a/e2e/exam-survey.spec.ts +++ b/e2e/exam-survey.spec.ts @@ -3,7 +3,6 @@ import { test, expect } from '@playwright/test'; const url = '/learn/foundational-c-sharp-with-microsoft/foundational-c-sharp-with-microsoft-certification-exam/foundational-c-sharp-with-microsoft-certification-exam'; test.describe('Exam Survey', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.beforeAll(() => { execSync('node ./tools/scripts/seed/seed-demo-user --certified-user'); execSync('node tools/scripts/seed/seed-surveys.js delete-only'); diff --git a/e2e/exam-token.spec.ts b/e2e/exam-token.spec.ts index 46ca3665a0a..b6ca5e1a025 100644 --- a/e2e/exam-token.spec.ts +++ b/e2e/exam-token.spec.ts @@ -3,8 +3,6 @@ // import { test, expect } from '@playwright/test'; -// test.use({ storageState: 'playwright/.auth/certified-user.json' }); - // test.beforeEach(async ({ page }) => { // await page.goto('/settings'); // }); diff --git a/e2e/exit-exam-modal.spec.ts b/e2e/exit-exam-modal.spec.ts index a315dab4a3b..dc76f577033 100644 --- a/e2e/exit-exam-modal.spec.ts +++ b/e2e/exit-exam-modal.spec.ts @@ -1,8 +1,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - const examUrl = '/learn/foundational-c-sharp-with-microsoft/foundational-c-sharp-with-microsoft-certification-exam/foundational-c-sharp-with-microsoft-certification-exam'; const cancelExamUrl = diff --git a/e2e/finish-exam-modal.spec.ts b/e2e/finish-exam-modal.spec.ts index 2f41f4a2fa5..54e51e542c3 100644 --- a/e2e/finish-exam-modal.spec.ts +++ b/e2e/finish-exam-modal.spec.ts @@ -1,8 +1,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - const examUrl = '/learn/foundational-c-sharp-with-microsoft/foundational-c-sharp-with-microsoft-certification-exam/foundational-c-sharp-with-microsoft-certification-exam'; const QUESTION_COUNT = 5; diff --git a/e2e/flash.spec.ts b/e2e/flash.spec.ts index d13e2fc960d..2619754c626 100644 --- a/e2e/flash.spec.ts +++ b/e2e/flash.spec.ts @@ -1,7 +1,6 @@ import { test, expect, type Page } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.beforeEach(async ({ page }) => { await page.goto('/settings'); }); diff --git a/e2e/form-helper.spec.ts b/e2e/form-helper.spec.ts index b00119e51d5..b6eee7e860d 100644 --- a/e2e/form-helper.spec.ts +++ b/e2e/form-helper.spec.ts @@ -1,8 +1,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.describe('Test form with only solution link', () => { test.beforeEach(async ({ page }) => { await page.goto( diff --git a/e2e/global-setup.ts b/e2e/global-setup.ts index 5cdf17539c0..a1699039e6f 100644 --- a/e2e/global-setup.ts +++ b/e2e/global-setup.ts @@ -3,6 +3,12 @@ import { execSync } from 'child_process'; import { test as setup } from '@playwright/test'; setup.describe('certifieduser', () => { + setup.use({ storageState: { cookies: [], origins: [] } }); + + setup.beforeAll(() => { + execSync('node ./tools/scripts/seed/seed-demo-user --certified-user '); + }); + setup('can sign in', async ({ request }) => { await request.get(process.env.API_LOCATION + '/signin'); await request.storageState({ @@ -12,6 +18,10 @@ setup.describe('certifieduser', () => { }); setup.describe('developmentuser', () => { + // We need to make sure the development user does not have any cookies from the certified user. + // Ass the certified user now has the default storage state. + setup.use({ storageState: { cookies: [], origins: [] } }); + // We can only sign in as a single user (one with email: 'foo@bar.com'), so // changing users means changing the record with that email in the database. setup.beforeAll(() => { diff --git a/e2e/header.spec.ts b/e2e/header.spec.ts index 1ac19e49759..e37cbb257fd 100644 --- a/e2e/header.spec.ts +++ b/e2e/header.spec.ts @@ -276,8 +276,6 @@ test.describe('Header', () => { }); test.describe('Exam Header', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test('Renders exam nav for Foundational C# with Microsoft exam', async ({ page }) => { diff --git a/e2e/help-modal.spec.ts b/e2e/help-modal.spec.ts index f18cbd6a95c..73ac222ed47 100644 --- a/e2e/help-modal.spec.ts +++ b/e2e/help-modal.spec.ts @@ -1,8 +1,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { await page.goto( '/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/write-your-first-c-sharp-code' diff --git a/e2e/hotkeys.spec.ts b/e2e/hotkeys.spec.ts index 596fb6155df..7d59999ce13 100644 --- a/e2e/hotkeys.spec.ts +++ b/e2e/hotkeys.spec.ts @@ -46,8 +46,6 @@ const waitUntilHydrated = async (page: Page, pageId: PageId) => { await waitUntilListening(page); }; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeAll(async ({ request }) => { await authedRequest({ request, diff --git a/e2e/image-picture-check.spec.ts b/e2e/image-picture-check.spec.ts index c4d3671093d..4c4590605af 100644 --- a/e2e/image-picture-check.spec.ts +++ b/e2e/image-picture-check.spec.ts @@ -1,8 +1,6 @@ import { test, expect } from '@playwright/test'; test.describe('Picture input field', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { await page.goto('/certifieduser'); diff --git a/e2e/internet-presence-settings.spec.ts b/e2e/internet-presence-settings.spec.ts index dd2bbf0deef..432e2e310ec 100644 --- a/e2e/internet-presence-settings.spec.ts +++ b/e2e/internet-presence-settings.spec.ts @@ -12,8 +12,6 @@ const settingsPageElement = { internetPresenceForm: 'internet-presence' } as const; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { // Reset input values execSync('node ./tools/scripts/seed/seed-demo-user --certified-user'); diff --git a/e2e/learn.spec.ts b/e2e/learn.spec.ts index 9ce0b901d34..e736e9270e8 100644 --- a/e2e/learn.spec.ts +++ b/e2e/learn.spec.ts @@ -74,8 +74,6 @@ test.describe('Learn - Unauthenticated user', () => { }); test.describe('Learn - Authenticated user)', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test('the page should render correctly', async ({ page }) => { await page.goto('/learn'); diff --git a/e2e/link-ms-user.spec.ts b/e2e/link-ms-user.spec.ts index a3584404245..9db82e41a52 100644 --- a/e2e/link-ms-user.spec.ts +++ b/e2e/link-ms-user.spec.ts @@ -11,6 +11,7 @@ test.beforeEach(async ({ page }) => { }); test.describe('Link MS user component (signed-out user)', () => { + test.use({ storageState: { cookies: [], origins: [] } }); test('should display the page content with a signin CTA', async ({ page }) => { @@ -44,7 +45,6 @@ test.describe('Link MS user component (signed-in user)', () => { test.afterEach(() => { execSync('node ./tools/scripts/seed/seed-ms-username'); }); - test.use({ storageState: 'playwright/.auth/certified-user.json' }); test("should recognize the user's MS account", async ({ page }) => { await expect( diff --git a/e2e/mobile-layout.spec.ts b/e2e/mobile-layout.spec.ts index 1256dbd8a59..fa354833588 100644 --- a/e2e/mobile-layout.spec.ts +++ b/e2e/mobile-layout.spec.ts @@ -2,8 +2,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.describe('Classic challenge - 5 tabs mobile layout component', () => { test.skip( ({ isMobile }) => isMobile === false, diff --git a/e2e/ms-trophy-show.spec.ts b/e2e/ms-trophy-show.spec.ts index 6a38dbc8945..4bec2e73694 100644 --- a/e2e/ms-trophy-show.spec.ts +++ b/e2e/ms-trophy-show.spec.ts @@ -3,7 +3,7 @@ import translations from '../client/i18n/locales/english/translations.json'; const verifyTrophyButtonText = translations.buttons['verify-trophy']; const askForHelpButtonText = translations.buttons['ask-for-help']; - +test.use({ storageState: { cookies: [], origins: [] } }); test.beforeEach(async ({ page }) => { await page.goto( '/learn/foundational-c-sharp-with-microsoft/write-your-first-code-using-c-sharp/trophy-write-your-first-code-using-c-sharp' diff --git a/e2e/multifile-cert-projects.spec.ts b/e2e/multifile-cert-projects.spec.ts index 9f1e10fd52d..59b9707c3dc 100644 --- a/e2e/multifile-cert-projects.spec.ts +++ b/e2e/multifile-cert-projects.spec.ts @@ -1,7 +1,6 @@ import { execSync } from 'child_process'; import { test, expect } from '@playwright/test'; import { clearEditor, focusEditor } from './utils/editor'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.describe('multifileCertProjects', () => { test.beforeEach(async ({ page }) => { execSync('node ./tools/scripts/seed/seed-demo-user --certified-user'); diff --git a/e2e/navigation-from-last-challenge.spec.ts b/e2e/navigation-from-last-challenge.spec.ts index 3bb60e9fb0a..5f0db32b157 100644 --- a/e2e/navigation-from-last-challenge.spec.ts +++ b/e2e/navigation-from-last-challenge.spec.ts @@ -22,7 +22,6 @@ const rwdChallenge = { nextUrl: '/learn/2022/responsive-web-design/#build-a-personal-portfolio-webpage-project' }; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.describe('Navigation from the middle or end (URL solution)', () => { test('In the middle of a block should take you to the next challenge', async ({ page diff --git a/e2e/profile.spec.ts b/e2e/profile.spec.ts index 66aa818e6cd..c4c1ab6f74e 100644 --- a/e2e/profile.spec.ts +++ b/e2e/profile.spec.ts @@ -83,7 +83,6 @@ const legacyCerts = [ test.describe('Profile component', () => { test.describe('when viewing my own profile', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.beforeEach(async ({ page }) => { await page.goto('/certifieduser'); @@ -207,8 +206,6 @@ test.describe('Profile component', () => { }); test.describe('while logged in', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test('displays the public username', async ({ page }) => { await expect( page.getByRole('heading', { name: '@publicuser' }) diff --git a/e2e/progress-bar.spec.ts b/e2e/progress-bar.spec.ts index 905ba1df518..8d2e4615a12 100644 --- a/e2e/progress-bar.spec.ts +++ b/e2e/progress-bar.spec.ts @@ -1,8 +1,6 @@ import { expect, test } from '@playwright/test'; import { clearEditor, focusEditor } from './utils/editor'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.describe('Progress bar component', () => { test('Should appear with the correct content after the user has submitted their code', async ({ page, diff --git a/e2e/progress-reset-modal.spec.ts b/e2e/progress-reset-modal.spec.ts index 2b01fe1a365..072802f58bf 100644 --- a/e2e/progress-reset-modal.spec.ts +++ b/e2e/progress-reset-modal.spec.ts @@ -5,8 +5,6 @@ import translations from '../client/i18n/locales/english/translations.json'; const execP = promisify(exec); -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { await page.goto('/settings'); }); diff --git a/e2e/quincy-email-sign-up.spec.ts b/e2e/quincy-email-sign-up.spec.ts index bb3607f0d90..f21431bbc50 100644 --- a/e2e/quincy-email-sign-up.spec.ts +++ b/e2e/quincy-email-sign-up.spec.ts @@ -92,8 +92,6 @@ test.describe('Email sign-up page when user is not signed in', () => { }); test.describe('Email sign-up page when user is signed in', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { // It's necessary to seed with a user that has not accepted the privacy // terms, otherwise the user will be redirected away from the email sign-up diff --git a/e2e/quiz-challenge.spec.ts b/e2e/quiz-challenge.spec.ts index fb6509da010..69e1f7bbde5 100644 --- a/e2e/quiz-challenge.spec.ts +++ b/e2e/quiz-challenge.spec.ts @@ -6,8 +6,6 @@ test.describe('Quiz challenge', () => { 'The FSD superblock is not available if SHOW_UPCOMING_CHANGES is false' ); - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { await page.goto( '/learn/full-stack-developer/quiz-basic-html/quiz-basic-html' diff --git a/e2e/report-user.spec.ts b/e2e/report-user.spec.ts index 4aeacff4498..0b6e02eca0b 100644 --- a/e2e/report-user.spec.ts +++ b/e2e/report-user.spec.ts @@ -5,7 +5,6 @@ import { getFirstEmail, getSubject } from './utils/mailhog'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.beforeEach(async () => { await deleteAllEmails(); diff --git a/e2e/scrollbar-width.spec.ts b/e2e/scrollbar-width.spec.ts index fbc65630df8..a28f72a757e 100644 --- a/e2e/scrollbar-width.spec.ts +++ b/e2e/scrollbar-width.spec.ts @@ -1,5 +1,5 @@ import { test, expect } from '@playwright/test'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); + test.describe('Editor scrollbar width', () => { test.beforeEach(async ({ page }) => { await page.goto('/settings'); diff --git a/e2e/settings.spec.ts b/e2e/settings.spec.ts index fa25e0616d2..6d515552958 100644 --- a/e2e/settings.spec.ts +++ b/e2e/settings.spec.ts @@ -47,8 +47,6 @@ const legacyCertifications = [ ]; test.describe('Settings - Certified User', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { execSync('node ./tools/scripts/seed/seed-demo-user --certified-user'); await page.goto('/settings'); @@ -262,8 +260,6 @@ test.describe('Settings - Certified User', () => { // Instead of simulating 6 cert claim flows, // we use the data of Certified User but remove the Full Stack cert. test.describe('Settings - Certified User without Full Stack Certification', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { execSync( 'node ./tools/scripts/seed/seed-demo-user --certified-user --set-false isFullStackCert' diff --git a/e2e/shortcuts-modal.spec.ts b/e2e/shortcuts-modal.spec.ts index 34498b5912b..12629a62b94 100644 --- a/e2e/shortcuts-modal.spec.ts +++ b/e2e/shortcuts-modal.spec.ts @@ -7,8 +7,6 @@ import { getEditors } from './utils/editor'; const course = '/learn/javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - const enableKeyboardShortcuts = async (request: APIRequestContext) => { const res = await authedRequest({ request, diff --git a/e2e/show-cert-from-superblock.spec.ts b/e2e/show-cert-from-superblock.spec.ts index 69209ccea6a..8cc62381121 100644 --- a/e2e/show-cert-from-superblock.spec.ts +++ b/e2e/show-cert-from-superblock.spec.ts @@ -32,8 +32,6 @@ test.describe('When the user HAS NOT claimed their cert', () => { }); test.describe('When the user HAS claimed their cert', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { await page.goto('/learn/front-end-development-libraries'); }); diff --git a/e2e/show-certificate-else.spec.ts b/e2e/show-certificate-else.spec.ts index 42df08db40e..c6cb858a6c0 100644 --- a/e2e/show-certificate-else.spec.ts +++ b/e2e/show-certificate-else.spec.ts @@ -2,6 +2,7 @@ import { test, expect, type Page } from '@playwright/test'; test.describe('Show certification else', () => { let page: Page; + test.use({ storageState: { cookies: [], origins: [] } }); test.beforeAll(async ({ browser }) => { page = await browser.newPage(); diff --git a/e2e/show-certificate-own.spec.ts b/e2e/show-certificate-own.spec.ts index 1a5d98f9681..054c53e442f 100644 --- a/e2e/show-certificate-own.spec.ts +++ b/e2e/show-certificate-own.spec.ts @@ -1,7 +1,5 @@ import { test, expect, type Page } from '@playwright/test'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.describe('Show certification own', () => { let page: Page; diff --git a/e2e/show.spec.ts b/e2e/show.spec.ts index ec2c0229d8e..3492fb6ed9d 100644 --- a/e2e/show.spec.ts +++ b/e2e/show.spec.ts @@ -40,8 +40,6 @@ test.describe('Odin challenges', () => { }); test.describe('When the user is signed in', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test('should render the content correctly', async ({ page }) => { await expect(page).toHaveTitle( 'Write Your First Code Using C# - Write Your First C# Code | Learn | freeCodeCamp.org' diff --git a/e2e/signin.spec.ts b/e2e/signin.spec.ts index 71651b49a1c..d0aba09a398 100644 --- a/e2e/signin.spec.ts +++ b/e2e/signin.spec.ts @@ -1,6 +1,7 @@ import { test, expect } from '@playwright/test'; test.describe('signing in', () => { + test.use({ storageState: { cookies: [], origins: [] } }); test('welcomes the user', async ({ page }) => { const welcomeText = 'Welcome back, Full Stack User.'; await page.goto('/learn'); diff --git a/e2e/signout-modal.spec.ts b/e2e/signout-modal.spec.ts index 1f9d6383124..9f9e30126fe 100644 --- a/e2e/signout-modal.spec.ts +++ b/e2e/signout-modal.spec.ts @@ -1,8 +1,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { await page.goto('/'); }); diff --git a/e2e/solution-viewer.spec.ts b/e2e/solution-viewer.spec.ts index 1d2b30fe145..0b292fd6e67 100644 --- a/e2e/solution-viewer.spec.ts +++ b/e2e/solution-viewer.spec.ts @@ -1,7 +1,5 @@ import { test, expect } from '@playwright/test'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.describe('Solution Viewer component', () => { test('renders the modal correctly', async ({ page }) => { await page.goto( diff --git a/e2e/third-party-donation.spec.ts b/e2e/third-party-donation.spec.ts index 9e6cd1ad284..a086c48cbcc 100644 --- a/e2e/third-party-donation.spec.ts +++ b/e2e/third-party-donation.spec.ts @@ -5,7 +5,6 @@ import stripeJson from './fixtures/donation/stripe.json'; import { alertToBeVisible } from './utils/alerts'; test.describe('third-party donation tests', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.beforeEach(async ({ page }) => { await page.goto('/donate'); }); diff --git a/e2e/update-about-me.spec.ts b/e2e/update-about-me.spec.ts index de50e0d6fcf..750ba359a18 100644 --- a/e2e/update-about-me.spec.ts +++ b/e2e/update-about-me.spec.ts @@ -2,8 +2,6 @@ import { execSync } from 'child_process'; import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { execSync( 'node ./tools/scripts/seed/seed-demo-user --certified-user --set-false isFullStackCert' diff --git a/e2e/update-email.spec.ts b/e2e/update-email.spec.ts index 0ed02e8f9d6..43435001f7d 100644 --- a/e2e/update-email.spec.ts +++ b/e2e/update-email.spec.ts @@ -2,8 +2,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; test.describe('The update-email page when the user is signed in', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); - test.beforeEach(async ({ page }) => { await page.goto('/update-email'); }); diff --git a/e2e/update-stripe-card-default.spec.ts b/e2e/update-stripe-card-default.spec.ts index a37a70e8e11..a4067e47803 100644 --- a/e2e/update-stripe-card-default.spec.ts +++ b/e2e/update-stripe-card-default.spec.ts @@ -2,7 +2,6 @@ import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; test.describe('Update Card Page for Non-Donor Authenticated User', () => { - test.use({ storageState: 'playwright/.auth/certified-user.json' }); test('should render correctly', async ({ page }) => { await page.goto('/update-stripe-card'); await expect(page).toHaveTitle( diff --git a/e2e/username-change.spec.ts b/e2e/username-change.spec.ts index 0b0d2ff8546..201d3788fb5 100644 --- a/e2e/username-change.spec.ts +++ b/e2e/username-change.spec.ts @@ -1,7 +1,6 @@ import { execSync } from 'child_process'; import { test, expect } from '@playwright/test'; import translations from '../client/i18n/locales/english/translations.json'; -test.use({ storageState: 'playwright/.auth/certified-user.json' }); test.afterAll(() => { // change the name back to the original diff --git a/playwright.config.ts b/playwright.config.ts index 8adc5cc9130..8791e0ea687 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -33,7 +33,7 @@ export default defineConfig({ baseURL: process.env.HOME_LOCATION || 'http://127.0.0.1:8000', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', - + storageState: 'playwright/.auth/certified-user.json', /* Use custom test attribute */ testIdAttribute: 'data-playwright-test-label' },