Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Apr 14, 2023
2 parents 52ba6bb + ffae1f1 commit cf02718
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 21 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
npm install
npm update
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ Thumbs.db

# graphql types
graphql/graphql-types.ts
/test-results/
/playwright-report/
/playwright/.cache/
25 changes: 25 additions & 0 deletions e2e/login.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { AppConfig } from '../src/environments/environment';
import { test, expect } from '@playwright/test';

test.describe("CATcher's Login Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});

test('displays "CATcher" in header bar', async ({ page }) => {
const title = await page.locator('app-layout-header').textContent();
expect(title).toEqual(`CATcher v${AppConfig.version}receiptmail`);
});

test('allows users to authenticate themselves', async ({ page }) => {
await page.locator('app-profiles').click();
await page.locator('mat-option').nth(1).click();
await page.getByRole('button', { name: 'Submit' }).click();

await expect(page.getByText('Confirm Login Account')).toHaveText('Confirm Login Account');

const login_button = page.getByRole('button', { name: 'github-logo Continue as CAT-Tester' });
await expect(login_button).toBeVisible();
await login_button.click();
});
});
21 changes: 0 additions & 21 deletions e2e/spec/login/login.e2e-spec.ts

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"test": "npm run codegen:gql && ng test",
"e2e": "npm run codegen:gql && ng e2e",
"actions:e2e": "npm run codegen:gql && ng e2e --protractor-config=e2e/protractor.gh-actions.conf --webdriver-update=false",
"playwright:e2e": "npx playwright test",
"webdriver-manager": "webdriver-manager",
"lint": "ng lint",
"lint:fix": "ng lint --fix",
Expand Down Expand Up @@ -75,6 +76,7 @@
"@graphql-codegen/typescript-operations": "^1.18.4",
"@graphql-codegen/typescript-resolvers": "^1.20.0",
"@octokit/graphql-schema": "^8.24.0",
"@playwright/test": "^1.32.1",
"@types/dompurify": "^2.3.1",
"@types/jasmine": "^3.8.2",
"@types/jasminewd2": "2.0.8",
Expand Down
91 changes: 91 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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: './e2e',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000
},
/* 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: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost: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: { channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { channel: 'chrome' },
// },
],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',

/* Run your local dev server before starting the tests */
webServer: {
command: 'npm run ng:serve:test',
port: 4200,
reuseExistingServer: !process.env.CI
}
});

0 comments on commit cf02718

Please sign in to comment.