From ec9989496e9d46d9f2303bf30b5ae99b70acdbc9 Mon Sep 17 00:00:00 2001 From: RachelChan <25484244+rachchan@users.noreply.github.com> Date: Fri, 20 Mar 2026 12:03:51 +0000 Subject: [PATCH 1/3] initial jira setup --- package.json | 3 +++ tests/e2e/utils.ts | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/package.json b/package.json index f9c2892..7016ae1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,9 @@ { "name": "ui-tests", "version": "0.0.1", + "exports": { + "./e2e-utils": "./tests/e2e/utils.ts" + }, "description": "", "homepage": "https://github.com/Pometry/ui-tests", "bugs": { diff --git a/tests/e2e/utils.ts b/tests/e2e/utils.ts index eb4a150..10c7adc 100644 --- a/tests/e2e/utils.ts +++ b/tests/e2e/utils.ts @@ -377,6 +377,7 @@ export async function fillInStyling( } interface GraphState { + highlighted: { id: string }[]; selected: string[]; nodes: { id: string; @@ -390,7 +391,15 @@ export async function getGraphState(page: Page): Promise { const graph = (window as BrowserWindow).__G6_GRAPH__; if (!graph) throw new Error('__G6_GRAPH__ not found on window'); const data = graph.getData(); + const nodesDisabled = data.nodes.some((n) => + n.states?.includes('disabled'), + ); return { + highlighted: nodesDisabled + ? data.nodes + .filter((n) => !n.states?.includes('disabled')) + .map((n) => ({ id: n.id })) + : [], selected: data.nodes .filter((n) => n.states?.includes('selected')) .map((n) => n.id), From 5033129d500af88ad8ca3083b39098cb8a607ad0 Mon Sep 17 00:00:00 2001 From: RachelChan <25484244+rachchan@users.noreply.github.com> Date: Wed, 25 Mar 2026 10:02:28 +0000 Subject: [PATCH 2/3] add tests setup for jira --- tests/e2e/graph.spec.ts | 10 ++----- tests/e2e/utils.ts | 60 +++++++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/tests/e2e/graph.spec.ts b/tests/e2e/graph.spec.ts index 653580f..940c9e6 100644 --- a/tests/e2e/graph.spec.ts +++ b/tests/e2e/graph.spec.ts @@ -1,4 +1,4 @@ -import { expect, Page } from '@playwright/test'; +import { expect } from '@playwright/test'; import { test } from '../fixtures'; import { changeTab, @@ -8,6 +8,7 @@ import { doubleClickOnNode, dragSlider, fillInStyling, + fitView, getGraphState, navigateToGraphPageBySearch, navigateToSavedGraphBySavedGraphsTable, @@ -16,13 +17,6 @@ import { waitForLayoutToFinish, } from './utils'; -async function fitView(page: Page) { - await page - .getByRole('button', { name: 'Fit all nodes within visible region' }) - .click(); - await waitForLayoutToFinish(page); -} - test('Close right hand side panel button and open again', async ({ page }) => { await page.goto('/graph/vanilla/event?initialNodes=%5B%5D'); diff --git a/tests/e2e/utils.ts b/tests/e2e/utils.ts index 10c7adc..77920c2 100644 --- a/tests/e2e/utils.ts +++ b/tests/e2e/utils.ts @@ -23,6 +23,13 @@ type BrowserWindow = Window & { }; }; +export async function fitView(page: Page) { + await page + .getByRole('button', { name: 'Fit all nodes within visible region' }) + .click(); + await waitForLayoutToFinish(page); +} + async function getNodePosition( page: Page, displayName: string, @@ -387,27 +394,34 @@ interface GraphState { } export async function getGraphState(page: Page): Promise { - return page.evaluate(() => { - const graph = (window as BrowserWindow).__G6_GRAPH__; - if (!graph) throw new Error('__G6_GRAPH__ not found on window'); - const data = graph.getData(); - const nodesDisabled = data.nodes.some((n) => - n.states?.includes('disabled'), - ); - return { - highlighted: nodesDisabled - ? data.nodes - .filter((n) => !n.states?.includes('disabled')) - .map((n) => ({ id: n.id })) - : [], - selected: data.nodes - .filter((n) => n.states?.includes('selected')) - .map((n) => n.id), - nodes: data.nodes.map((n) => ({ - id: n.id, - colour: n.style?.fill, - size: n.style?.size, - })), - }; - }); + const handle = await page.waitForFunction( + () => { + const graph = (window as BrowserWindow).__G6_GRAPH__; + if (!graph) return undefined; + const data = graph.getData(); + const anyDisabled = data.nodes.some((n) => + n.states?.includes('disabled'), + ); + console.log( + data.nodes.map((n) => ({ id: n.id, states: n.states })), + ); + return { + highlighted: anyDisabled + ? data.nodes + .filter((n) => !n.states?.includes('disabled')) + .map((n) => ({ id: n.id })) + : [], + selected: data.nodes + .filter((n) => n.states?.includes('selected')) + .map((n) => n.id), + nodes: data.nodes.map((n) => ({ + id: n.id, + colour: n.style?.fill, + size: n.style?.size, + })), + }; + }, + { timeout: 10000 }, + ); + return handle.jsonValue() as Promise; } From 036a7f2985f60d67fa838e8c315721e06990030f Mon Sep 17 00:00:00 2001 From: RachelChan <25484244+rachchan@users.noreply.github.com> Date: Mon, 30 Mar 2026 09:25:56 +0100 Subject: [PATCH 3/3] remove console.log --- tests/e2e/utils.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/e2e/utils.ts b/tests/e2e/utils.ts index 77920c2..698bc60 100644 --- a/tests/e2e/utils.ts +++ b/tests/e2e/utils.ts @@ -402,9 +402,6 @@ export async function getGraphState(page: Page): Promise { const anyDisabled = data.nodes.some((n) => n.states?.includes('disabled'), ); - console.log( - data.nodes.map((n) => ({ id: n.id, states: n.states })), - ); return { highlighted: anyDisabled ? data.nodes