Repository navigation
Add Chromium browser tests for workbench and animation #36
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
Open
ralphhanna
wants to merge
3
commits into
main
Choose a base branch
from
test/browser-coverage-20260927
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: Browser tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| chromium: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: npm | ||
| - run: npm ci | ||
| - run: npx playwright install --with-deps chromium | ||
| - run: npm run build | ||
| - run: npm run test:browser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import test from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import express from 'express'; | ||
| import { chromium } from 'playwright'; | ||
| import { join } from 'node:path'; | ||
| import { renderInstanceFixture, renderModelsFixture, root } from './instanceFixture.mjs'; | ||
|
|
||
| async function startFixtureServer() { | ||
| const app = express(); | ||
| app.use('/vendor/gsap', express.static(join(root, 'node_modules/gsap/dist'))); | ||
| app.use(express.static(join(root, 'public'))); | ||
| app.get('/', (_request, response) => response.send(renderInstanceFixture())); | ||
| app.get('/models', (_request, response) => response.send(renderModelsFixture())); | ||
| const server = app.listen(0, '127.0.0.1'); | ||
| await new Promise(resolve => server.once('listening', resolve)); | ||
| return { server, url: `http://127.0.0.1:${server.address().port}` }; | ||
| } | ||
|
|
||
| test('instance Show Animation plays and can be replayed', { timeout: 20000 }, async () => { | ||
| const { server, url } = await startFixtureServer(); | ||
| let browser; | ||
| try { | ||
| browser = await chromium.launch({ headless: true }); | ||
| const page = await browser.newPage(); | ||
| const errors = []; | ||
| page.on('pageerror', error => errors.push(error.message)); | ||
| await page.goto(url, { waitUntil: 'domcontentloaded' }); | ||
|
|
||
| assert.equal(await page.locator('script[src="/vendor/gsap/gsap.min.js"]').count(), 1); | ||
| assert.equal(await page.evaluate(() => typeof gsap), 'object'); | ||
| assert.equal(await page.evaluate(() => typeof MotionPathPlugin !== 'undefined'), true); | ||
| assert.equal(await page.locator('#jsonInfo').count(), 1); | ||
|
|
||
| const button = page.getByRole('button', { name: 'Show Animation' }); | ||
| const flow = page.locator('[data-element-id="Flow_1"]'); | ||
| await button.click(); | ||
| await page.waitForFunction(() => | ||
| document.querySelector('[data-element-id="Flow_1"]').classList.contains('Completed'), | ||
| ); | ||
| assert.equal((await flow.getAttribute('class')).includes('Completed'), true); | ||
|
|
||
| await button.click(); | ||
| await page.waitForFunction(() => | ||
| document.querySelector('[data-element-id="Flow_1"]').classList.contains('Completed'), | ||
| ); | ||
| assert.deepEqual(errors, []); | ||
| } finally { | ||
| if (browser) await browser.close(); | ||
| await new Promise(resolve => server.close(resolve)); | ||
| } | ||
| }); | ||
|
|
||
| test('model search updates the preview and section navigation', { timeout: 20000 }, async () => { | ||
| const { server, url } = await startFixtureServer(); | ||
| let browser; | ||
| try { | ||
| browser = await chromium.launch({ headless: true }); | ||
| const page = await browser.newPage(); | ||
| const errors = []; | ||
| page.on('pageerror', error => errors.push(error.message)); | ||
| await page.goto(url + '/models', { waitUntil: 'domcontentloaded' }); | ||
|
|
||
| await page.getByRole('searchbox', { name: 'Search models' }).fill('invoice'); | ||
| assert.deepEqual(await page.locator('#process option').allTextContents(), ['Invoice']); | ||
| assert.equal(await page.locator('#selected-model-name').innerText(), 'Invoice'); | ||
| assert.equal(await page.locator('#modelLink').getAttribute('href'), '/model/edit/Invoice/'); | ||
|
|
||
| await page.locator('.workbench-tabs [data-section="tasks"]').click(); | ||
| await page.locator('#tasks').waitFor({ state: 'visible' }); | ||
| assert.equal(await page.locator('#tasks').isVisible(), true); | ||
| assert.equal(await page.locator('#processes').isVisible(), false); | ||
| assert.deepEqual(errors, []); | ||
| } finally { | ||
| if (browser) await browser.close(); | ||
| await new Promise(resolve => server.close(resolve)); | ||
| } | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { dirname, join } from 'node:path'; | ||
| import pug from 'pug'; | ||
|
|
||
| const root = dirname(dirname(fileURLToPath(import.meta.url))); | ||
| const startedAt = '2026-09-27T10:00:00.000Z'; | ||
| const steps = [ | ||
| { id: 'StartEvent_1', type: 'bpmn:StartEvent', action: 'Started' }, | ||
| { id: 'Flow_1', type: 'bpmn:SequenceFlow', action: 'Ended' }, | ||
| { id: 'Task_1', type: 'bpmn:Task', action: 'Ended' }, | ||
| ]; | ||
|
|
||
| export function renderInstanceFixture() { | ||
| const items = steps.map((step, index) => ({ | ||
| id: `item-${index}`, elementId: step.id, name: step.id, type: step.type, | ||
| status: 'end', startedAt, endedAt: startedAt, | ||
| })); | ||
| const definition = { | ||
| processes: [], | ||
| elements: steps.filter(step => step.type !== 'bpmn:SequenceFlow') | ||
| .map(step => ({ id: step.id, type: step.type, description: [], behaviours: [] })), | ||
| flows: [{ id: 'Flow_1', type: 'bpmn:SequenceFlow', description: [] }], | ||
| }; | ||
| const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="600" height="150" viewBox="0 0 600 150"> | ||
| <g class="djs-element" data-element-id="StartEvent_1"> | ||
| <g class="djs-visual"><circle cx="65" cy="75" r="20" fill="white" stroke="black"/></g> | ||
| </g> | ||
| <g class="djs-element" data-element-id="Flow_1"> | ||
| <g class="djs-visual"><path d="M85 75 L350 75" fill="none" stroke="black" stroke-width="2"/></g> | ||
| </g> | ||
| <g class="djs-element" data-element-id="Task_1"> | ||
| <g class="djs-visual"><rect x="350" y="45" width="120" height="60" fill="white" stroke="black"/></g> | ||
| </g> | ||
| </svg>`; | ||
| return pug.renderFile(join(root, 'src/views/InstanceDetails.pug'), { | ||
| title: 'Instance Details', | ||
| instance: { id: 'browser-test', name: 'Animation Fixture', startedAt, endedAt: startedAt, data: {} }, | ||
| lastItem: items.at(-1), | ||
| logs: steps.map((step, index) => ({ | ||
| type: 'info', date: startedAt, | ||
| message: JSON.stringify({ id: step.id, type: step.type, action: step.action, seq: index + 1 }), | ||
| })), | ||
| items, vars: [], svg, definition: JSON.stringify(definition), | ||
| decorations: JSON.stringify(items.map((item, index) => ({ | ||
| type: 'seq', id: item.elementId, color: 'black', seq: index + 1, | ||
| }))), | ||
| user: { isAdmin: () => true }, | ||
| }); | ||
| } | ||
|
|
||
| export function renderModelsFixture() { | ||
| return pug.renderFile(join(root, 'src/views/index.pug'), { | ||
| title: 'Workbench', | ||
| request: { session: {} }, | ||
| user: { userName: 'system', userGroups: ['SYSTEM'], isAdmin: () => true }, | ||
| procs: ['Buy Used Car', 'Invoice'], | ||
| waiting: [], instances: [], _csrf: 'browser-test', | ||
| }); | ||
| } | ||
|
|
||
| export { root }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
/modelsfixture rendersindex.pugthroughlayoutHome, whose shared head loadsSVGHelper.js. OnDOMContentLoaded, that script callsscanSVG(), which executesdecorations.forEach(...), but this view never definesdecorations; Chromium therefore recordsReferenceError: decorations is not defined, and this assertion fails on every browser-test workflow run. Initialize the expected global in the fixture or guard/fix the shared helper before requiring an empty page-error list.Useful? React with 👍 / 👎.