Skip to content

Commit

Permalink
update e2e workflow: test before deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasZhao1908 committed Nov 29, 2023
1 parent 4c660e2 commit a6a3b33
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 105 deletions.
55 changes: 25 additions & 30 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,36 @@ jobs:
working-directory: ./frontend
shell: bash
run: NODE_OPTIONS=--max-old-space-size=8192 pnpm build

e2e:
name: E2E testing
needs: [build, frontend-dependencies]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Restore PNPM packages
uses: actions/cache@v3
with:
key: pnpm
path: ${{ needs.frontend-dependencies.outputs.STORE_PATH }}
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: true
- name: Install Playwright
working-directory: ./frontend
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
working-directory: ./frontend
run: pnpm exec playwright test
- name: Upload Build
uses: actions/upload-artifact@v3
with:
name: build
path: ./frontend/build

deploy:
name: gh pages
needs: build
Expand All @@ -193,33 +218,3 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
e2e:
name: E2E testing
needs: [deploy, frontend-dependencies]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Restore PNPM packages
uses: actions/cache@v3
with:
key: pnpm
path: ${{ needs.frontend-dependencies.outputs.STORE_PATH }}
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: true
- name: Install Playwright
working-directory: ./frontend
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
working-directory: ./frontend
run: pnpm exec playwright test
- uses: actions/upload-artifact@v3
working-directory: ./frontend
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
59 changes: 8 additions & 51 deletions frontend/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,34 @@
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: './tests',
/* 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. */
reporter: 'list',
timeout: 100000,
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
baseURL: 'http://127.0.0.1:4173',
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,
// },
webServer: {
command: 'pnpm preview',
url: 'http://127.0.0.1:4173',
reuseExistingServer: !process.env.CI
}
});
52 changes: 28 additions & 24 deletions frontend/tests/e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';

test('main page', async ({ page }) => {
await page.goto('https://portal.aether.es/');
await page.goto('/');
await page.getByText('Number of Ontologies').click();
await page.getByText('Number of Classes').click();
await page.getByText('Number of Datatype Properties').click();
Expand All @@ -12,7 +12,7 @@ test('main page', async ({ page }) => {
await page.getByLabel('Go to home').click();
});
test('submit page', async ({ page }) => {
await page.goto('https://portal.aether.es/submit');
await page.goto('/submit');
await page.getByRole('heading', { name: 'Submit an Ontology' }).click();
const page1Promise = page.waitForEvent('popup');
await page.getByRole('link', { name: 'Github Notification' }).click();
Expand All @@ -21,7 +21,7 @@ test('submit page', async ({ page }) => {
});

test('search page', async ({ page }) => {
await page.goto('https://portal.aether.es/search');
await page.goto('/search');
await page.getByRole('heading', { name: 'Search for Classes and' }).click();
await page.getByTestId('search-input').click();
await page.getByTestId('search-input').fill('bigowl');
Expand All @@ -36,30 +36,34 @@ test('search page', async ({ page }) => {
await page.getByTestId('search-input').fill('bigowl4dq');
await page.getByRole('row', { name: '1 Accuracy Documentation Link' }).getByRole('link').nth(1).click();
});

test('ontologies page', async ({ page }) => {
await page.goto('https://portal.aether.es/ontologies');
await page.getByRole('button', { name: 'A-Z sort' }).click();
await page.getByRole('button', { name: 'Z-A sort' }).click();
await page.getByRole('button', { name: '2' }).click();
await page.getByRole('button', { name: '1' }).click();
await page.getByRole('link', { name: 'e-LION e-LION (e-Learning' }).click();
await page.getByRole('row', { name: 'title e-LION' }).getByRole('paragraph').click();
await page.getByText('e-lion', { exact: true }).click();
await page.getByText('e-LION (e-Learning').click();
await page.goto('/ontologies');
await page.getByTestId('search-input').click();
await page.getByTestId('search-input').fill('bigowlalgorithm');
await page.getByRole('link', { name: 'BIGOWLAlgorithms This' }).click();
await page.getByRole('cell', { name: 'title' }).click();
await page.getByRole('cell', { name: 'uri' }).click();
await page.getByRole('cell', { name: 'prefix' }).click();
await page.getByRole('cell', { name: 'description' }).click();
await page.getByRole('cell', { name: 'creator' }).click();
await page.getByRole('cell', { name: 'publisher' }).click();
await page.getByRole('cell', { name: 'created' }).click();
await page.getByRole('cell', { name: 'rights' }).click();
await page.getByRole('cell', { name: 'imports' }).click();
await page.getByRole('cell', { name: 'Number of Individuals' }).click();
await page.getByRole('cell', { name: 'Number of Classes' }).click();
await page.getByRole('cell', { name: 'Number of Datatype Properties' }).click();
await page.getByRole('cell', { name: 'Number of Object Properties' }).click();
await page.getByRole('button', { name: '2' }).click();
await page.getByRole('button', { name: '3' }).click();
await page.getByTestId('go-to-end-btn').click();
await page.getByTestId('go-to-start-btn').click();
await page.getByTestId('hierarchy-view').check();
await page.getByText('foaf:Person').dblclick();
await page.getByText('BIGOWLAlgorithms:Algorithm').click();
await page.getByText('BIGOWLAlgorithms:Algorithm').click();
await page.getByText('BIGOWLAlgorithms:RFPredict').click();
await page.getByText('Table Class Hierarchy').click();
await page.getByTestId('mappings-toggle').check();
await page.getByRole('row', { name: 'http://schema.org 4 toggle' }).getByRole('button').click();
await page.getByRole('row', { name: 'http://schema.org 4 toggle' }).getByRole('button').click();
await page.getByTestId('table-view').check();
await page.locator('label').filter({ hasText: 'Others' }).click();
await page.locator('label').filter({ hasText: 'Others' }).click();
await page.getByLabel('Individuals').uncheck();
await page.getByLabel('Datatype properties').uncheck();
await page.getByLabel('Object properties').uncheck();
await page.getByLabel('Classes').uncheck();
await page.getByRole('heading', { name: 'No results' }).click();
await page.getByRole('cell', { name: 'Referenced classes' }).click();
await page.getByRole('cell', { name: 'Ontology', exact: true }).click();
});

0 comments on commit a6a3b33

Please sign in to comment.