Skip to content

Commit

Permalink
Added UI Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Jan 8, 2024
1 parent 1a3e582 commit 453e8a8
Show file tree
Hide file tree
Showing 16 changed files with 306 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/ui-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: UI Tests
on: [push, pull_request]
jobs:
ui_test:
name: UI Tests
runs-on: ubuntu-latest
strategy:
matrix:
ps-version:
- '8.0.5'
- '8.1.3'
- 'nightly'
env:
PS_VERSION: ${{ matrix.ps-version }}
steps:
- name: Checkout
uses: actions/checkout@v3.1.0

- uses: actions/setup-node@v3
with:
node-version: 14

- name: Build
run: npm install && npm run build

- name: Start containers
run: docker-compose -f "docker-compose.yml" up -d --build

- name: Install dependencies
run: npm ci
working-directory: tests/UI/

- name: Install Playwright Browsers
run: npx playwright install --with-deps
working-directory: tests/UI/

- name: Run Playwright tests
run: npx playwright test
working-directory: tests/UI/

- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ node_modules

# mac
.DS_Store

## UI Tests
./tests/UI/node_modules/
./tests/UI/reports/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"watch": "npm run dev",
"lint": "eslint -c .eslintrc.js --ext .js,.vue .",
"lint-fix": "eslint -c .eslintrc.js --ext .js,.vue . --fix",
"test": "mochapack --webpack-config .webpack/common.js --require tests/UI/setup.js tests/UI/**/*.spec.js"
"test": "mochapack --webpack-config .webpack/common.js --require tests/js/setup.js tests/js/**/*.spec.js"
},
"author": "PrestaShop",
"license": "AFL-3.0",
Expand Down
18 changes: 18 additions & 0 deletions tests/UI/campaigns/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});

test('get started link', async ({ page }) => {
await page.goto('https://playwright.dev/');

// Click the get started link.
await page.getByRole('link', { name: 'Get started' }).click();

// Expects page to have a heading with the name of Installation.
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
41 changes: 41 additions & 0 deletions tests/UI/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
services:
prestashop:
image: prestashop/prestashop-flashlight:${PS_VERSION}
container_name: prestashop
depends_on:
mysql:
condition: service_healthy
environment:
- DEBUG_MODE=true
volumes:
- type: bind
# Local Path
source: ../../
# Mount Path
target: /var/www/html/modules/blockwishlist
ports:
- 8000:80

mysql:
image: mariadb:lts
container_name: prestashop-mysql
healthcheck:
test:
[
'CMD',
'mysqladmin',
'ping',
'--host=localhost',
'--user=prestashop',
'--password=prestashop',
]
interval: 5s
timeout: 10s
retries: 5
environment:
- MYSQL_HOST=mysql
- MYSQL_USER=prestashop
- MYSQL_PASSWORD=prestashop
- MYSQL_ROOT_PASSWORD=prestashop
- MYSQL_PORT=3306
- MYSQL_DATABASE=prestashop
140 changes: 140 additions & 0 deletions tests/UI/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tests/UI/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "blockwishlist_tests_ui",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@playwright/test": "^1.40.1",
"@types/node": "^20.10.7"
}
}
42 changes: 42 additions & 0 deletions tests/UI/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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: './',
/* 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', { outputFolder: 'reports' }],
],
/* 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',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
});
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.

0 comments on commit 453e8a8

Please sign in to comment.