chore: improved structure'

'
This commit is contained in:
pit
2023-09-18 21:13:55 +01:00
parent 5beb1c6192
commit 3c43d7af05
7 changed files with 40 additions and 44 deletions

2
.gitignore vendored
View File

@ -47,7 +47,7 @@ yarn-error.log*
!.vscode/tasks.json !.vscode/tasks.json
!.vscode/launch.json !.vscode/launch.json
!.vscode/extensions.json !.vscode/extensions.json
/test-results/ **/test-results/
/playwright-report/ /playwright-report/
/playwright/.cache/ /playwright/.cache/

View File

@ -1,25 +0,0 @@
import { type Page, expect, test as setup } from '@playwright/test';
import { STORAGE_STATE } from '../../../../playwright.config';
setup('authenticate', async ({ page }: { page: Page }) => {
await page.goto('/signup');
await page.getByLabel('Name').fill(process.env.E2E_TEST_USERNAME);
await page.getByLabel('Email').fill(process.env.E2E_TEST_USER_EMAIL);
await page.getByLabel('Password').fill(process.env.E2E_TEST_USER_PASSWORD);
const canvas = page.locator('canvas');
const box = await canvas.boundingBox();
if (box) {
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
await page.mouse.down();
await page.mouse.move(box.x + box.width / 4, box.y + box.height / 4);
await page.mouse.up();
}
await page.getByRole('button', { name: 'Sign Up' }).click();
await page.waitForURL('/documents');
await expect(page).toHaveURL('/documents');
await page.context().storageState({ path: STORAGE_STATE });
});

View File

@ -0,0 +1,13 @@
import { type Page, expect, test as setup } from '@playwright/test';
import { STORAGE_STATE } from '../../../../../playwright.config';
setup('authenticate', async ({ page }: { page: Page }) => {
await page.goto('/');
await page.getByLabel('Email').fill('example@documenso.com');
await page.getByLabel('Password').fill('123456');
await page.getByRole('button', { name: 'Sign In' }).click();
await page.waitForURL('/documents');
await expect(page).toHaveURL('/documents');
await page.context().storageState({ path: STORAGE_STATE });
});

View File

@ -27,7 +27,7 @@ test.describe('Document upload test', () => {
await page await page
.getByText('Add a documentDrag & drop your document here.') .getByText('Add a documentDrag & drop your document here.')
.locator('input[type=file]') .locator('input[type=file]')
.setInputFiles('./apps/web/src/tests/documenso.pdf'); .setInputFiles('./apps/web/src/tests/e2e/documenso.pdf');
}); });
test('user can see /documents page', async ({ page }: { page: Page }) => { test('user can see /documents page', async ({ page }: { page: Page }) => {

View File

@ -14,7 +14,7 @@ export const STORAGE_STATE = 'playwright/.auth/user.json';
* See https://playwright.dev/docs/test-configuration. * See https://playwright.dev/docs/test-configuration.
*/ */
export default defineConfig({ export default defineConfig({
testDir: './apps/web/src/tests', testDir: './apps/web/src/tests/e2e',
/* Run tests in files in parallel */ /* Run tests in files in parallel */
fullyParallel: true, fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */ /* Fail the build on CI if you accidentally left test.only in the source code. */
@ -36,35 +36,43 @@ export default defineConfig({
/* Configure projects for major browsers */ /* Configure projects for major browsers */
projects: [ projects: [
{ name: 'setup', testMatch: /.*\.setup\.ts/ }, { name: 'setup', testMatch: '**/*.setup.ts' },
{ {
name: 'Authenticated User Tests', name: 'Authenticated User Tests',
testMatch: /.*\.spec\.ts/, testMatch: '*.authenticated.spec.ts',
testIgnore: /test-auth-flow\.spec\.ts/,
dependencies: ['setup'], dependencies: ['setup'],
use: { use: {
...devices['Desktop Chrome'],
storageState: STORAGE_STATE, storageState: STORAGE_STATE,
}, },
}, },
{ {
name: 'chromium', name: 'Unauthenticated User Tests',
use: { use: {
...devices['Desktop Chrome'], ...devices['Desktop Chrome'],
}, },
testMatch: '*.unauthenticated.spec.ts',
testIgnore: ['*.setup.ts', '*.authenticated.spec.ts'],
}, },
// {
// name: 'chromium',
// use: {
// ...devices['Desktop Chrome'],
// },
// },
{ // {
name: 'firefox', // name: 'firefox',
use: { // use: {
...devices['Desktop Firefox'], // ...devices['Desktop Firefox'],
}, // },
}, // },
{ // {
name: 'webkit', // name: 'webkit',
use: { // use: {
...devices['Desktop Safari'], // ...devices['Desktop Safari'],
}, // },
}, // },
], ],
/* Test against mobile viewports. */ /* Test against mobile viewports. */