Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BOHEUS committed Jan 12, 2025
1 parent aa640f5 commit 8b695ef
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,28 @@ test.describe('Authentication test', () => {
membersSection,
settingsPage,
}) => {
await test.step('Go to Settings and copy invite link', () => {
page.goto(process.env.LINK); // skip login page (and redirect) when running on environments with multi-workspace enabled
leftMenu.goToSettings();
settingsPage.goToMembersSection();
membersSection.copyInviteLink();
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);
});
const inviteLink: string = await page.evaluate(
'navigator.clipboard.readText()',
);
await test.step('Go to invite link', () => {
settingsPage.logout();
page.goto(inviteLink);
});
await test.step('Create new account', () => {
loginPage.clickLoginWithEmail();
loginPage.typeEmail(email);
loginPage.clickContinueButton();
loginPage.typePassword(process.env.DEFAULT_PASSWORD);
loginPage.clickSignUpButton();
loginPage.typeFirstName(firstName);
loginPage.typeLastName(lastName);
loginPage.clickContinueButton();
loginPage.noSyncWithGoogle();
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;
});
});
Expand All @@ -51,12 +50,12 @@ test.describe('Authentication test', () => {
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', () => {
leftMenu.goToSettings();
settingsPage.goToProfileSection();
profileSection.deleteAccount();
confirmationModal.typePlaceholderToInput();
confirmationModal.clickConfirmButton();
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');
});
}
Expand Down
26 changes: 13 additions & 13 deletions packages/twenty-e2e-testing/tests/login.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ const test = base.extend<{ loginPage: LoginPage }>({
});

test('Login test', async ({ loginPage, page }) => {
await test.step('Navigated to login page', () => {
page.goto('/');
page.waitForLoadState('networkidle'); // wait as a precaution for environments with multi-workspace enabled
await test.step('Navigated to login page', async () => {
await page.goto('/');
});
await test.step(
'Logging in '.concat(page.url(), ' as ', process.env.DEFAULT_LOGIN),
() => {
async () => {
await page.waitForLoadState('networkidle');
if (
page.url().includes('demo.twenty.com') ||
!page.url().includes('app.localhost:3001')
) {
loginPage.clickLoginWithEmail();
await loginPage.clickLoginWithEmail();
}
loginPage.typeEmail(process.env.DEFAULT_LOGIN);
loginPage.clickContinueButton();
loginPage.typePassword(process.env.DEFAULT_PASSWORD);
loginPage.clickSignInButton();
page.waitForLoadState('networkidle');
expect(page.getByText('Welcome to Twenty')).not.toBeVisible();
await loginPage.typeEmail(process.env.DEFAULT_LOGIN);
await loginPage.clickContinueButton();
await loginPage.typePassword(process.env.DEFAULT_PASSWORD);
await page.waitForLoadState('networkidle');
await loginPage.clickSignInButton();
await expect(page.getByText('Welcome to Twenty')).not.toBeVisible();
},
);

await test.step('Saved auth state', () => {
page.context().storageState({
await test.step('Saved auth state', async () => {
await page.context().storageState({
path: path.resolve(__dirname, '..', '.auth', 'user.json'),
});
process.env.LINK = page.url();
Expand Down

0 comments on commit 8b695ef

Please sign in to comment.