Playwright E2E test - sign up with invite link via email (#9332)
Related to https://github.com/twentyhq/twenty/issues/8469#issuecomment-2471573054 --------- Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
45
packages/twenty-e2e-testing/tests/authentication/fixture.ts
Normal file
45
packages/twenty-e2e-testing/tests/authentication/fixture.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { test as base } from '../../lib/fixtures/screenshot';
|
||||
import { LoginPage } from '../../lib/pom/loginPage';
|
||||
import { LeftMenu } from '../../lib/pom/leftMenu';
|
||||
import { SettingsPage } from '../../lib/pom/settingsPage';
|
||||
import { MembersSection } from '../../lib/pom/settings/membersSection';
|
||||
import { ProfileSection } from '../../lib/pom/settings/profileSection';
|
||||
import { ConfirmationModal } from '../../lib/pom/helper/confirmationModal';
|
||||
|
||||
type Fixtures = {
|
||||
confirmationModal: ConfirmationModal;
|
||||
loginPage: LoginPage;
|
||||
leftMenu: LeftMenu;
|
||||
settingsPage: SettingsPage;
|
||||
membersSection: MembersSection;
|
||||
profileSection: ProfileSection;
|
||||
};
|
||||
|
||||
export const test = base.extend<Fixtures>({
|
||||
confirmationModal: async ({ page }, use) => {
|
||||
const confirmationModal = new ConfirmationModal(page);
|
||||
await use(confirmationModal);
|
||||
},
|
||||
loginPage: async ({ page }, use) => {
|
||||
const loginPage = new LoginPage(page);
|
||||
await use(loginPage);
|
||||
},
|
||||
leftMenu: async ({ page }, use) => {
|
||||
const leftMenu = new LeftMenu(page);
|
||||
await use(leftMenu);
|
||||
},
|
||||
settingsPage: async ({ page }, use) => {
|
||||
const settingsPage = new SettingsPage(page);
|
||||
await use(settingsPage);
|
||||
},
|
||||
membersSection: async ({ page }, use) => {
|
||||
const membersSection = new MembersSection(page);
|
||||
await use(membersSection);
|
||||
},
|
||||
profileSection: async ({ page }, use) => {
|
||||
const profileSection = new ProfileSection(page);
|
||||
await use(profileSection);
|
||||
},
|
||||
});
|
||||
|
||||
export { expect } from '@playwright/test';
|
||||
@ -0,0 +1,64 @@
|
||||
import { expect, test } from './fixture';
|
||||
|
||||
test.describe('Authentication test', () => {
|
||||
const email = 'test@apple.dev';
|
||||
const firstName = 'John';
|
||||
const lastName = 'Doe';
|
||||
let testCompleted = false;
|
||||
|
||||
test('Sign up with invite link via email', async ({
|
||||
page,
|
||||
loginPage,
|
||||
leftMenu,
|
||||
membersSection,
|
||||
settingsPage,
|
||||
}) => {
|
||||
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()');
|
||||
});
|
||||
await test.step('Go to invite link', async () => {
|
||||
await settingsPage.logout();
|
||||
await page.goto(inviteLink);
|
||||
});
|
||||
await test.step('Create new account', async () => {
|
||||
await loginPage.clickLoginWithEmail();
|
||||
await loginPage.typeEmail(email);
|
||||
await loginPage.clickContinueButton();
|
||||
await loginPage.typePassword(process.env.DEFAULT_PASSWORD);
|
||||
await loginPage.clickSignUpButton();
|
||||
await loginPage.typeFirstName(firstName);
|
||||
await loginPage.typeLastName(lastName);
|
||||
await loginPage.clickContinueButton();
|
||||
await loginPage.noSyncWithGoogle();
|
||||
testCompleted = true;
|
||||
});
|
||||
});
|
||||
|
||||
test.afterEach(
|
||||
async ({
|
||||
page,
|
||||
confirmationModal,
|
||||
leftMenu,
|
||||
profileSection,
|
||||
settingsPage,
|
||||
}) => {
|
||||
if (testCompleted) {
|
||||
// security measurement to clean up only after test is completed,
|
||||
// otherwise default account used for tests may be deleted and resetting database will be necessary
|
||||
await test.step('Cleanup - deleting account', async () => {
|
||||
await leftMenu.goToSettings();
|
||||
await settingsPage.goToProfileSection();
|
||||
await profileSection.deleteAccount();
|
||||
await confirmationModal.typePlaceholderToInput();
|
||||
await confirmationModal.clickConfirmButton();
|
||||
expect(page.url()).toContain('/welcome');
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user