mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
playwright (#3)
* add playwright setup and tests for auth, profile and organization settings * add playwright github action * add sqlite database * fix playwright base url * add mailpit and parallelization * remove additional waitForUrl in fixture * fix tests * remove waitforurl in tests * change playwright github action to only one worker * try promiso all to avoid loading errors * change environment to include http protocol * convert back to simpler structure * add caching of playwright browser binaries * test if playwright in ci works faster with multiple workers * change back to one worker * remove browser binary caching * try using playwright container to speedup browser setup * rollback image changes * add playwright gitignore changes --------- Co-authored-by: Gregor Vostrak <gregorvostrak@Gregors-MacBook-Pro.local>
This commit is contained in:
54
e2e/auth.spec.ts
Normal file
54
e2e/auth.spec.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
|
||||
async function registerNewUser(page, email, password) {
|
||||
await page.getByRole('link', { name: 'Register' }).click();
|
||||
await page.getByLabel('Name').fill('John Doe');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password', { exact: true }).fill(password);
|
||||
await page.getByLabel('Confirm Password').fill(password);
|
||||
await page.getByRole('button', { name: 'Register' }).click();
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Dashboard' })
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
test('can register, logout and log back in', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL);
|
||||
const email = `john+${Math.round(Math.random() * 10000)}@doe.com`;
|
||||
const password = 'suchagreatpassword123';
|
||||
await registerNewUser(page, email, password);
|
||||
await expect(
|
||||
page.getByRole('button', { name: "John's Organization" })
|
||||
).toBeVisible();
|
||||
await page.locator('#currentUserButton').click();
|
||||
|
||||
await page.getByRole('button', { name: 'Log Out' }).click();
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/');
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/login');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password').fill(password);
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Dashboard' })
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('can register and delete account', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL);
|
||||
const email = `john+${Math.round(Math.random() * 10000)}@doe.com`;
|
||||
const password = 'suchagreatpassword123';
|
||||
await registerNewUser(page, email, password);
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
|
||||
await page.getByRole('button', { name: 'Delete Account' }).click();
|
||||
await page.getByPlaceholder('Password').fill(password);
|
||||
await page.getByRole('button', { name: 'Delete Account' }).nth(1).click();
|
||||
await page.waitForURL(PLAYWRIGHT_BASE_URL + '/');
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/login');
|
||||
await page.getByLabel('Email').fill(email);
|
||||
await page.getByLabel('Password').fill(password);
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await expect(page.getByRole('paragraph')).toContainText(
|
||||
'These credentials do not match our records.'
|
||||
);
|
||||
});
|
||||
50
e2e/organization.spec.ts
Normal file
50
e2e/organization.spec.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { test, expect } from '../playwright/fixtures';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
|
||||
async function goToOrganizationSettings(page) {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
||||
await page.locator('#currentTeamButton').click();
|
||||
await page.getByRole('link', { name: 'Team Settings' }).click();
|
||||
}
|
||||
|
||||
test('test that organization name can be updated', async ({ page }) => {
|
||||
await goToOrganizationSettings(page);
|
||||
await page.getByLabel('Team Name').fill('NEW ORG NAME');
|
||||
await page.getByLabel('Team Name').press('Enter');
|
||||
await page.getByLabel('Team Name').press('Meta+r');
|
||||
await expect(page.getByRole('navigation')).toContainText('NEW ORG NAME');
|
||||
});
|
||||
|
||||
test('test that new editor can be invited', async ({ page }) => {
|
||||
await goToOrganizationSettings(page);
|
||||
const editorId = Math.round(Math.random() * 10000);
|
||||
await page.getByLabel('Email').fill(`new+${editorId}@editor.test`);
|
||||
await page.getByRole('button', { name: 'Editor' }).click();
|
||||
await page.getByRole('button', { name: 'Add' }).click();
|
||||
await page.reload();
|
||||
await expect(page.getByRole('main')).toContainText(
|
||||
`new+${editorId}@editor.test`
|
||||
);
|
||||
});
|
||||
|
||||
test('test that new admin can be invited', async ({ page }) => {
|
||||
await goToOrganizationSettings(page);
|
||||
const adminId = Math.round(Math.random() * 10000);
|
||||
await page.getByLabel('Email').fill(`new+${adminId}@admin.test`);
|
||||
await page.getByRole('button', { name: 'Administrator' }).click();
|
||||
await page.getByRole('button', { name: 'Add' }).click();
|
||||
await page.reload();
|
||||
await expect(page.getByRole('main')).toContainText(
|
||||
`new+${adminId}@admin.test`
|
||||
);
|
||||
});
|
||||
test('test that error shows if no role is selected', async ({ page }) => {
|
||||
await goToOrganizationSettings(page);
|
||||
const noRoleId = Math.round(Math.random() * 10000);
|
||||
|
||||
await page.getByLabel('Email').fill(`new+${noRoleId}@norole.test`);
|
||||
await page.getByRole('button', { name: 'Add' }).click();
|
||||
await expect(page.getByRole('main')).toContainText(
|
||||
'The role field is required.'
|
||||
);
|
||||
});
|
||||
21
e2e/profile.spec.ts
Normal file
21
e2e/profile.spec.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { test, expect } from '../playwright/fixtures';
|
||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||
|
||||
test('test that user name can be updated', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
|
||||
await page.getByLabel('Name').fill('NEW NAME');
|
||||
await page.getByRole('button', { name: 'Save' }).first().click();
|
||||
await page.reload();
|
||||
await expect(page.getByLabel('Name')).toHaveValue('NEW NAME');
|
||||
});
|
||||
|
||||
test('test that user email can be updated', async ({ page }) => {
|
||||
await page.goto(PLAYWRIGHT_BASE_URL + '/user/profile');
|
||||
const emailId = Math.round(Math.random() * 10000);
|
||||
await page.getByLabel('Email').fill(`newemail+${emailId}@test.com`);
|
||||
await page.getByRole('button', { name: 'Save' }).first().click();
|
||||
await page.reload();
|
||||
await expect(page.getByLabel('Email')).toHaveValue(
|
||||
`newemail+${emailId}@test.com`
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user