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

Setup Playwright UI tests #61

Merged
merged 1 commit into from
Jan 3, 2025
Merged
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,3 +11,8 @@ _deps
/build
Brewfile.lock.json
.DS_Store
test/ui/node_modules/
test/ui/test-results/
test/ui/playwright-report/
test/ui/blob-report/
test/ui/playwright/.cache/
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@ HURL ?= hurl
JSONSCHEMA ?= jsonschema
DOCKER ?= docker
SHELLCHECK ?= shellcheck
NPX ?= npx
NPM ?= npm

# Options
INDEX ?= ON
@@ -76,6 +78,12 @@ test-e2e:
$(HURL) --test \
--variable base=$(shell jq --raw-output '.url' < $(SANDBOX)/configuration.json) \
test/e2e/common/*.hurl test/e2e/$(EDITION)/*.hurl
ifeq ($(ENTERPRISE), ON)
$(NPM) --prefix test/ui install
$(NPX) --prefix test/ui playwright install --with-deps
env BASE_URL=$(shell jq --raw-output '.url' < $(SANDBOX)/configuration.json) \
$(NPX) --prefix test/ui playwright test --config test/ui/playwright.config.js
endif

.PHONY: sandbox
sandbox: compile
@@ -90,5 +98,5 @@ docker:

.PHONY: clean
clean:
$(CMAKE) -E rm -R -f build
$(CMAKE) -E rm -R -f build test/ui/node_modules test/ui/test-results
$(DOCKER) system prune --force --all --volumes || true
5 changes: 5 additions & 0 deletions test/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
6 changes: 6 additions & 0 deletions test/ui/explorer.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { test, expect } = require('@playwright/test');

test('has title', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/Sourcemeta/);
});
96 changes: 96 additions & 0 deletions test/ui/package-lock.json

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

9 changes: 9 additions & 0 deletions test/ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@sourcemeta/registry",
"private": true,
"version": "0.0.0",
"devDependencies": {
"@playwright/test": "^1.49.1",
"@types/node": "^22.10.5"
}
}
16 changes: 16 additions & 0 deletions test/ui/playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { defineConfig, devices } = require('@playwright/test');

// See https://playwright.dev/docs/test-configuration
module.exports = defineConfig({
testDir: '.',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'list',
use: {
baseURL: process.env.BASE_URL,
trace: 'on-first-retry'
}
});