Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Livetest #73

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ data
omelette
.yalc
backend
livetest
9 changes: 9 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"compilerOptions": {
"paths": {
"@eeacms/volto-corsproxy": [
"addons/volto-corsproxy/src"
],
"@eeacms/volto-block-divider": [
"addons/volto-block-divider/src"
],
"@eeacms/volto-block-image-cards": [
"addons/volto-block-image-cards/src"
],
"@eeacms/volto-plotlycharts": [
"addons/volto-plotlycharts/src"
],
Expand Down
31 changes: 31 additions & 0 deletions livetest/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
root: true,
env: {
browser: true,
commonjs: true,
es2021: true,
jest: true
},
extends: [
'standard',
'plugin:cypress/recommended'
],
overrides: [
{
env: {
node: true
},
files: [
'.eslintrc.{js,cjs}'
],
parserOptions: {
sourceType: 'script'
}
}
],
parserOptions: {
ecmaVersion: 'latest'
},
rules: {
}
}
27 changes: 27 additions & 0 deletions livetest/.github-example/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn
- name: Install Playwright Browsers
run: yarn playwright install --with-deps
- name: Run Playwright tests
run: yarn playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions livetest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
Binary file added livetest/.yarn/install-state.gz
Binary file not shown.
34 changes: 34 additions & 0 deletions livetest/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.DEFAULT_GOAL: help

help:
@echo "Run make setup"
@echo "Run make pw"

.PHONY: setup
setup:
yarn install
yarn playwright install

.PHONY: upd
upd:
yarn playwright test --update-snapshots

.PHONY: pw
pw: ## start Playwright with UI, for interactive use
yarn playwright test --ui

.PHONY: pw-run
pw-run: ## run the tests automatically. Intended for CI
yarn playwright test --project chromium

.PHONY: pw-show
pw-show:
yarn playwright show-report

.PHONY: cypress
cypress:
yarn cypress open

.PHONY: cypress-test
cypress-test:
yarn cypress run --env type=actual --env "pluginVisualRegressionCleanupUnusedImages=true"
20 changes: 20 additions & 0 deletions livetest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "livetest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"author": "",
"license": "ISC",
"devDependencies": {
"@axe-core/playwright": "4.8.1",
"@playwright/test": "1.39.0",
"@types/node": "20.8.7",
"eslint": "^8.0.1",
"eslint-config-standard": "latest",
"eslint-config-xo": "latest",
"eslint-plugin-cypress": "2.15.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-promise": "^6.0.0"
}
}
78 changes: 78 additions & 0 deletions livetest/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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. */
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 */
trace: 'on-first-retry',
viewport: { width: 1400, height: 720 },
},

/* 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,
// },
});
75 changes: 75 additions & 0 deletions livetest/tests/freshwater.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { test, expect } from '@playwright/test';
import AxeBuilder from '@axe-core/playwright'; // 1

// const site = 'https://water.europa.eu/freshwater';
const site = 'https://demo-water.devel5cph.eea.europa.eu/freshwater';

const url = (path) => `${site}${path}`;
const TIMEOUT = 10000;
const WAIT = 5000;

test.use({
viewport: { width: 1600, height: 1200 },
locale: 'en',
timezoneId: 'Europe/Berlin',
});

test('homepage', async ({ page }) => {
await page.goto(url('/'));

await expect(page).toHaveTitle(/WISE Freshwater/);
await expect(page).toHaveScreenshot({ fullPage: true, timeout: TIMEOUT });

// const accessibilityScanResults = await new AxeBuilder({ page }).analyze()
// expect(accessibilityScanResults.violations).toEqual([])
});

test('about', async ({ page }) => {
await page.goto(url('/about/wise-freshwater'));
await expect(page).toHaveScreenshot('about.png', {
fullPage: true,
timeout: TIMEOUT,
});

const relevantLinksH3 = page.getByText('Relevant Links');
const box = page
.locator('css=.columns-view')
.filter({ has: relevantLinksH3 });
await expect(box).toHaveScreenshot('about-relevant-links.png');

// const accessibilityScanResults = await new AxeBuilder({ page }).analyze()
// expect(accessibilityScanResults.violations).toEqual([])
});

test('eu country page', async ({ page }) => {
// test.setTimeout(120000)
test.slow();
await page.goto(url('/countries/uwwt/european-union'));
await page.waitForTimeout(WAIT);
await expect(page).toHaveScreenshot('eu-page1.png');

await page.keyboard.press('PageDown', { timeout: TIMEOUT });
await page.waitForTimeout(WAIT);
// await expect(page).toHaveScreenshot('eu-page2.png', { timeout: 300000, maxDiffPixels: 400 })
await expect(page).toHaveScreenshot('eu-page2.png', { timeout: TIMEOUT });

await page.keyboard.press('PageDown');
await page.waitForTimeout(WAIT);
await expect(page).toHaveScreenshot('eu-page3.png', { timeout: TIMEOUT });

await page.keyboard.press('PageDown');
await page.waitForTimeout(WAIT);
await expect(page).toHaveScreenshot('eu-page4.png', { timeout: TIMEOUT });
});

test('eea accessibility page', async ({ page }) => {
await page.goto('https://www.eea.europa.eu/en/accessibility/tests');
// await expect(page).toHaveScreenshot('about.png', { fullPage: true, timeout: TIMEOUT })
//
// const relevantLinksH3 = page.getByText('Relevant Links')
// const box = page.locator('css=.columns-view').filter({ has: relevantLinksH3 })
// await expect(box).toHaveScreenshot('about-relevant-links.png')

const accessibilityScanResults = await new AxeBuilder({ page }).analyze();
expect(accessibilityScanResults.violations).toEqual([]);
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading