Skip to content

Commit fc955a3

Browse files
committed
Revert changes to existing state generator util. Create a new function for out of order generator util
1 parent df197b9 commit fc955a3

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

e2e/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@ For those interested in the mechanics of snapshot testing with Playwright, you c
105105

106106
- Our Snapshot tests receive a `@snapshot` tag.
107107
- Snapshots need to be executed within the official Playwright container to ensure we're using the exact rendering platform in CI and locally. To do a valid comparison locally:
108+
- Note, microsoft might have retired older images like `-jammy`. Run the following command to find the available tags:
109+
`curl -s https://mcr.microsoft.com/v2/playwright/tags/list | jq -r '.tags[]' | grep "v{X.X.X}`
108110

109111
```sh
110112
// Replace {X.X.X} with the current Playwright version
111113
// from our package.json configuration file
112-
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v{X.X.X}-focal /bin/bash
114+
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v{X.X.X}-jammy /bin/bash
113115
npm install
114116
npm run test:e2e:checksnapshots
115117
```
@@ -123,7 +125,7 @@ To compare a snapshot, run a test and open the html report with the 'Expected' v
123125
```sh
124126
// Replace {X.X.X} with the current Playwright version
125127
// from our package.json configuration file
126-
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v{X.X.X}-focal /bin/bash
128+
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v{X.X.X}-jammy /bin/bash
127129
npm install
128130
npm run test:e2e:updatesnapshots
129131
```

e2e/appActions.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,36 @@ async function createStableStateTelemetry(page, parent = 'mine', outOfOrder = fa
270270
};
271271
}
272272

273+
/**
274+
* Create a Out of order State Telemetry Object (State Generator) for use in visual tests
275+
* and tests against plotting telemetry (e.g. logPlot tests). This will change state every 2 seconds.
276+
* @param {import('@playwright/test').Page} page
277+
* @param {string | import('../src/api/objects/ObjectAPI').Identifier} [parent] the uuid or identifier of the parent object. Defaults to 'mine'
278+
* @returns {Promise<CreatedObjectInfo>} An object containing information about the telemetry object.
279+
*/
280+
async function createOutOfOrderStateTelemetry(page, parent = 'mine', duration = 0.25) {
281+
const parentUrl = await getHashUrlToDomainObject(page, parent);
282+
283+
await page.goto(`${parentUrl}`);
284+
const createdObject = await createDomainObjectWithDefaults(
285+
page,
286+
{
287+
type: 'State Generator',
288+
name: 'Stable State Generator'
289+
},
290+
{ outOfOrder: true, duration: duration.toString() }
291+
);
292+
// Wait until the URL is updated
293+
const uuid = await getFocusedObjectUuid(page);
294+
const url = await getHashUrlToDomainObject(page, uuid);
295+
296+
return {
297+
name: createdObject.name,
298+
uuid,
299+
url
300+
};
301+
}
302+
273303
/**
274304
* Navigates directly to a given object url, in fixed time mode, with the given start and end bounds. Note: does not set
275305
* default view type.
@@ -767,6 +797,7 @@ export {
767797
createDomainObjectWithDefaults,
768798
createExampleTelemetryObject,
769799
createNotification,
800+
createOutOfOrderStateTelemetry,
770801
createPlanFromJSON,
771802
createStableStateTelemetry,
772803
expandEntireTree,

0 commit comments

Comments
 (0)