Add E2E tests (#9309)

Try adding E2E tests when labelling the PR or merging on main branch
This commit is contained in:
Félix Malfait
2025-01-02 13:28:02 +01:00
committed by GitHub
parent 5da744ebc5
commit afae244057
15 changed files with 247 additions and 168 deletions

View File

@ -1,18 +1,38 @@
import { test as setup, expect } from '@playwright/test';
import { expect, test as setup } from '@playwright/test';
import path from 'path';
setup('Login test', async ({ page }) => {
await page.goto('/');
await page.getByRole('button', { name: 'Continue With Email' }).click();
await page.getByPlaceholder('Email').fill(process.env.DEFAULT_LOGIN);
await page.getByRole('button', { name: 'Continue', exact: true }).click();
await page.getByPlaceholder('Password').fill(process.env.DEFAULT_PASSWORD);
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page.getByText('Welcome to Twenty')).not.toBeVisible();
console.log('Starting login test');
// End of authentication steps.
await page.goto('/');
console.log('Navigated to homepage');
await page.getByRole('button', { name: 'Continue With Email' }).click();
console.log('Clicked email login button');
console.log('Default login', process.env.DEFAULT_LOGIN);
await page.getByPlaceholder('Email').fill(process.env.DEFAULT_LOGIN ?? '');
console.log('Filled email field');
await page.getByRole('button', { name: 'Continue', exact: true }).click();
console.log('Clicked continue button');
await page
.getByPlaceholder('Password')
.fill(process.env.DEFAULT_PASSWORD ?? '');
console.log('Filled password field');
await page.getByRole('button', { name: 'Sign in' }).click();
console.log('Clicked sign in button');
await page.waitForLoadState('networkidle');
console.log('Waited for network to be idle');
await expect(page.getByText('Welcome to Twenty')).not.toBeVisible();
console.log('Verified welcome message not visible');
await page.context().storageState({
path: path.resolve(__dirname, '..', '.auth', 'user.json'),
});
console.log('Saved auth state');
});