Skip to content

Commit

Permalink
Setup Playwright UI tests (#61)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti authored Jan 3, 2025
1 parent 854aea6 commit 78b39c4
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -4,6 +4,8 @@ HURL ?= hurl
JSONSCHEMA ?= jsonschema
DOCKER ?= docker
SHELLCHECK ?= shellcheck
NPX ?= npx
NPM ?= npm

# Options
INDEX ?= ON
Expand Down Expand Up @@ -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
Expand All @@ -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'
}
});

0 comments on commit 78b39c4

Please sign in to comment.