Skip to content

Commit

Permalink
test: add playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
tjorbo committed Mar 20, 2024
1 parent 69f8b50 commit a13081f
Show file tree
Hide file tree
Showing 21 changed files with 86 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
/out-tsc
.npm
.run
.env.local

# auto generated
src/environments/environment.ts
src/index.html

#download from cypress
cypress/downloads
test/cypress/downloads

# dependencies
/node_modules
Expand Down
76 changes: 76 additions & 0 deletions playwright-dev.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import {defineConfig, devices} from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: 'test/playwright',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL: 'http://127.0.0.1:4200',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {...devices['Desktop Chrome']},
},

{
name: 'firefox',
use: {...devices['Desktop Firefox']},
},

{
name: 'webkit',
use: {...devices['Desktop Safari']},
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
5 changes: 2 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {defineConfig, devices} from '@playwright/test';
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright',
testDir: 'test/playwright',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
Expand All @@ -23,8 +23,7 @@ export default defineConfig({
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:4200',
baseURL: 'http://127.0.0.1:80',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ context('admin-view', () => {
{
body: values.adminProtectionFalse
}
).as('apiCheckProtection');
)

cy.intercept(
{
Expand All @@ -35,7 +35,7 @@ context('admin-view', () => {
},
body: values.getAdmin
}
).as('apiCheckAppointment');
)

cy.visit(getBaseHref(values.adminLink));
cy.location('href').should('include', '/#/admin/');
Expand Down Expand Up @@ -161,6 +161,7 @@ context('admin-view', () => {
.click();
cy.get('[data-id=startDateInput]')
.type(dayjs().add(1, 'd').format('DD.MM.YYYY'))
cy.get('[data-id=startDateInput]')
.should('have.value', dayjs().add(1, 'd').format('DD.MM.YYYY'));
cy.get('[data-id=next]')
.click();
Expand All @@ -172,6 +173,7 @@ context('admin-view', () => {
.click();
cy.get('[data-id=passwordInput]')
.type('Hallo2021!')
cy.get('[data-id=passwordInput]')
.should('have.value', 'Hallo2021!');
cy.get('[data-id=repeatPasswordInput]')
.type('Hallo2021!');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cypress/tsconfig.json → test/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../../tsconfig.json",
"include": [
"**/*.ts"
],
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {expect, test} from '@playwright/test';
import AxeBuilder from '@axe-core/playwright';

test('simple-walkthrough', async ({page}) => {
await page.goto('http://localhost:4200');
await page.goto('/');
await page.getByTestId('headline').isVisible()

const accessibilityScanResults = await new AxeBuilder({page})
Expand Down

0 comments on commit a13081f

Please sign in to comment.