Add E2E tests (#9309)
Try adding E2E tests when labelling the PR or merging on main branch
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { test, expect } from '../../lib/fixtures/screenshot';
|
||||
import { expect, test } from '../../lib/fixtures/screenshot';
|
||||
|
||||
test.describe('Basic check', () => {
|
||||
test('Checking if table in Companies is visible', async ({ page }) => {
|
||||
40
packages/twenty-e2e-testing/tests/all/workspaces.e2e-spec.ts
Normal file
40
packages/twenty-e2e-testing/tests/all/workspaces.e2e-spec.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { test } from '@playwright/test';
|
||||
import { sh } from '../../drivers/shell_driver';
|
||||
|
||||
test.describe('', () => {
|
||||
test.use({ storageState: { cookies: [], origins: [] } });
|
||||
|
||||
/*
|
||||
|
||||
test('Creating new workspace', async ({ page, browserName }) => {
|
||||
// this test must use only 1 browser, otherwise it will lead to success and fail (1 workspace is created instead of x workspaces)
|
||||
if (browserName == 'chromium') {
|
||||
await sh(
|
||||
'npx nx run twenty-server:database:reset --configuration=no-seed',
|
||||
);
|
||||
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: 'Continue With Email' }).click();
|
||||
await page.getByPlaceholder('Email').fill('test@apple.dev'); // email must be changed each time test is run
|
||||
await page.getByPlaceholder('Email').press('Enter'); // otherwise if tests fails after this step, new workspace is created
|
||||
await page.getByPlaceholder('Password').fill('Applecar2025');
|
||||
await page.getByPlaceholder('Password').press('Enter');
|
||||
await page.getByPlaceholder('Apple').fill('Test');
|
||||
await page.getByRole('button', { name: 'Continue' }).click();
|
||||
await page.getByPlaceholder('Tim').click();
|
||||
await page.getByPlaceholder('Tim').fill('Test2');
|
||||
await page.getByPlaceholder('Cook').click();
|
||||
await page.getByPlaceholder('Cook').fill('Test2');
|
||||
await page.getByRole('button', { name: 'Continue' }).click();
|
||||
await page.getByText('Continue without sync').click();
|
||||
await page.getByRole('button', { name: 'Finish' }).click();
|
||||
await expect(page.locator('table')).toBeVisible({ timeout: 1000 });
|
||||
await sh('npx nx run twenty-server:database:reset');
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
test('Syncing all workspaces', async () => {
|
||||
await sh('npx nx run twenty-server:command workspace:sync-metadata -f');
|
||||
});
|
||||
});
|
||||
@ -1,66 +0,0 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { sh } from '../../drivers/shell_driver';
|
||||
|
||||
test.describe('', () => {
|
||||
test('Testing logging', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: 'Continue With Email' }).click();
|
||||
await page.getByPlaceholder('Email').fill('tim@apple.dev');
|
||||
await page.getByRole('button', { name: 'Continue', exact: true }).click();
|
||||
await page.getByPlaceholder('Password').fill('Applecar2025');
|
||||
await page.getByRole('button', { name: 'Sign in' }).click();
|
||||
await expect(page.getByText('Welcome to Twenty')).not.toBeVisible();
|
||||
expect(page.url()).not.toContain('/welcome');
|
||||
await page.getByRole('link', { name: 'Opportunities' }).click();
|
||||
await expect(page.locator('tbody > tr')).toHaveCount(4);
|
||||
});
|
||||
|
||||
test('Creating new workspace', async ({ page, browserName }) => {
|
||||
// this test must use only 1 browser, otherwise it will lead to success and fail (1 workspace is created instead of x workspaces)
|
||||
if (browserName == 'chromium') {
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: 'Continue With Email' }).click();
|
||||
await page.getByPlaceholder('Email').fill('test@apple.dev'); // email must be changed each time test is run
|
||||
await page.getByPlaceholder('Email').press('Enter'); // otherwise if tests fails after this step, new workspace is created
|
||||
await page.getByPlaceholder('Password').fill('Applecar2025');
|
||||
await page.getByPlaceholder('Password').press('Enter');
|
||||
await page.getByPlaceholder('Apple').fill('Test');
|
||||
await page.getByRole('button', { name: 'Continue' }).click();
|
||||
await page.getByPlaceholder('Tim').click();
|
||||
await page.getByPlaceholder('Tim').fill('Test2');
|
||||
await page.getByPlaceholder('Cook').click();
|
||||
await page.getByPlaceholder('Cook').fill('Test2');
|
||||
await page.getByRole('button', { name: 'Continue' }).click();
|
||||
await page.getByText('Continue without sync').click();
|
||||
await page.getByRole('button', { name: 'Finish' }).click();
|
||||
await expect(page.locator('table')).toBeVisible({ timeout: 1000 });
|
||||
}
|
||||
});
|
||||
|
||||
test('Syncing all workspaces', async () => {
|
||||
await sh('npx nx run twenty-server:command workspace:sync-metadata -f');
|
||||
await sh('npx nx run twenty-server:command workspace:sync-metadata -f');
|
||||
});
|
||||
|
||||
test('Resetting database', async ({ page, browserName }) => {
|
||||
if (browserName === 'chromium') {
|
||||
await sh('yarn nx database:reset twenty-server'); // if this command fails for any reason, database must be restarted manually using the same command because database is in unstable state
|
||||
await page.goto('/');
|
||||
await page.getByRole('button', { name: 'Continue With Email' }).click();
|
||||
await page.getByPlaceholder('Email').fill('tim@apple.dev');
|
||||
await page.getByRole('button', { name: 'Continue' }).click();
|
||||
await page.getByPlaceholder('Password').fill('Applecar2025');
|
||||
await page.getByRole('button', { name: 'Sign in' }).click();
|
||||
await page.getByRole('link', { name: 'Companies' }).click();
|
||||
expect(page.url()).toContain('/companies');
|
||||
await expect(page.locator('table')).toBeVisible();
|
||||
}
|
||||
});
|
||||
|
||||
test('Seeding database', async ({ page, browserName }) => {
|
||||
if (browserName === 'chromium') {
|
||||
await sh('npx nx workspace:seed:demo');
|
||||
await page.goto('/');
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -1,17 +0,0 @@
|
||||
import { test as base, expect } from '../../lib/fixtures/screenshot';
|
||||
import { LoginPage } from '../../lib/pom/loginPage';
|
||||
|
||||
// fixture
|
||||
const test = base.extend<{ loginPage: LoginPage }>({
|
||||
loginPage: async ({ page }, use) => {
|
||||
await use(new LoginPage(page));
|
||||
},
|
||||
});
|
||||
|
||||
test('Check login with email', async ({ loginPage }) => {
|
||||
await loginPage.typeEmail(process.env.DEFAULT_LOGIN);
|
||||
await loginPage.clickContinueButton();
|
||||
await loginPage.typePassword(process.env.DEFAULT_PASSWORD);
|
||||
await loginPage.clickSignInButton();
|
||||
await expect(loginPage.signInButton).not.toBeVisible();
|
||||
});
|
||||
@ -1,4 +1,4 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
test('Check if demo account is working properly @demo-only', async ({
|
||||
page,
|
||||
@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user