The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix invitation E2E revoking the shared login session (#26712)
Félix Malfaitef88c077c208
diff --git a/packages/twenty-e2e-testing/lib/constants/authStorageStatePath.ts b/packages/twenty-e2e-testing/lib/constants/authStorageStatePath.tsnew file mode 100644index 00000000000..7359e1bf5e6--- /dev/null+++ b/packages/twenty-e2e-testing/lib/constants/authStorageStatePath.ts@@ -0,0 +1,9 @@+import path from 'path';++export const AUTH_STORAGE_STATE_PATH = path.resolve(+ __dirname,+ '..',+ '..',+ '.auth',+ 'user.json',+);diff --git a/packages/twenty-e2e-testing/playwright.config.ts b/packages/twenty-e2e-testing/playwright.config.tsindex a57098b3778..cfa5fa4ac0b 100644--- a/packages/twenty-e2e-testing/playwright.config.ts+++ b/packages/twenty-e2e-testing/playwright.config.ts@@ -1,6 +1,7 @@import { defineConfig, devices } from '@playwright/test';import { config } from 'dotenv';import * as path from 'path';+import { AUTH_STORAGE_STATE_PATH } from './lib/constants/authStorageStatePath';const envResult = config({path: path.resolve(__dirname, '.env'),@@ -50,7 +51,7 @@ export default defineConfig({use: {...devices['Desktop Chrome'],permissions: ['clipboard-read', 'clipboard-write'],- storageState: path.resolve(__dirname, '.auth', 'user.json'), // takes saved cookies from directory+ storageState: AUTH_STORAGE_STATE_PATH, // takes saved cookies from directory},dependencies: ['setup'],},diff --git a/packages/twenty-e2e-testing/tests/authentication/signup_invite_email.spec.ts b/packages/twenty-e2e-testing/tests/authentication/signup_invite_email.spec.tsindex b998bc23c1e..ca9e2c2775e 100644--- a/packages/twenty-e2e-testing/tests/authentication/signup_invite_email.spec.ts+++ b/packages/twenty-e2e-testing/tests/authentication/signup_invite_email.spec.ts@@ -1,11 +1,17 @@import { randomUUID } from 'crypto';+import { AUTH_STORAGE_STATE_PATH } from '../../lib/constants/authStorageStatePath';+import { LeftMenu } from '../../lib/pom/leftMenu';+import { MembersSection } from '../../lib/pom/settings/membersSection';+import { SettingsPage } from '../../lib/pom/settingsPage';import { expect, test } from './fixture';+test.use({ storageState: { cookies: [], origins: [] } });+test('Sign up with invite link via email', async ({+ browser,page,loginPage,leftMenu,- membersSection,settingsPage,profileSection,confirmationModal,@@ -16,18 +22,26 @@ test('Sign up with invite link via email', async ({const inviteLink: string =await test.step('Go to Settings and copy invite link', async () => {- await page.goto(process.env.LINK); // skip login page (and redirect) when running on environments with multi-workspace enabled- await leftMenu.goToSettings();- await settingsPage.goToMembersSection();- await membersSection.copyInviteLink();- return await page.evaluate('navigator.clipboard.readText()');+ // Later tests reuse the saved session, and signing out or signing up+ // from it would revoke it server-side.+ const inviterPage = await browser.newPage({+ storageState: AUTH_STORAGE_STATE_PATH,+ permissions: ['clipboard-read', 'clipboard-write'],+ });++ try {+ await inviterPage.goto(process.env.LINK);+ await new LeftMenu(inviterPage).goToSettings();+ await new SettingsPage(inviterPage).goToMembersSection();+ await new MembersSection(inviterPage).copyInviteLink();++ return await inviterPage.evaluate(() => navigator.clipboard.readText());+ } finally {+ await inviterPage.close();+ }});await test.step('Go to invite link', async () => {- await settingsPage.logout();- // Logging out replaces the document, which would interrupt the goto below.- await page.waitForURL('**/welcome');-await page.goto(inviteLink);await expect(page.getByText(/Join .+ team/)).toBeVisible();});@@ -43,6 +57,19 @@ test('Sign up with invite link via email', async ({await loginPage.typeFirstName(firstName);await loginPage.typeLastName(lastName);await loginPage.clickContinueButton();+ await expect(page.getByTestId('workspace-dropdown')).toBeVisible();+ });++ await test.step('Log out and sign back in', async () => {+ await leftMenu.goToSettings();+ await settingsPage.logout();+ await page.waitForURL('**/welcome');++ await loginPage.clickLoginWithEmailIfVisible();+ await loginPage.typeEmail(email);+ await loginPage.clickContinueButton();+ await loginPage.typePassword(process.env.DEFAULT_PASSWORD);+ await loginPage.clickSignInButton();});await test.step('Delete account from workspace', async () => {diff --git a/packages/twenty-e2e-testing/tests/login.setup.ts b/packages/twenty-e2e-testing/tests/login.setup.tsindex 4606fcdc43d..add681c175c 100644--- a/packages/twenty-e2e-testing/tests/login.setup.ts+++ b/packages/twenty-e2e-testing/tests/login.setup.ts@@ -1,5 +1,5 @@import { test as base, expect } from '@playwright/test';-import path from 'path';+import { AUTH_STORAGE_STATE_PATH } from '../lib/constants/authStorageStatePath';import { LoginPage } from '../lib/pom/loginPage';// fixture@@ -36,8 +36,6 @@ test('Login test', async ({ loginPage, page }) => {);await test.step('Saved auth state', async () => {- await page.context().storageState({- path: path.resolve(__dirname, '..', '.auth', 'user.json'),- });+ await page.context().storageState({ path: AUTH_STORAGE_STATE_PATH });});});