Skip to content

Commit 6fcb208

Browse files
committed
minor changes
1 parent 2c4efae commit 6fcb208

32 files changed

+78
-15
lines changed

packages/docs/docs/contribute/playwright-tests.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ test.describe('Your Example Name', async () => {
100100
// Your test code here to add a measurement
101101
const locator = page.locator('.cornerstone-canvas');
102102
await checkForScreenshot(
103+
page,
103104
locator,
104105
screenshotPath.your_example_name.measurementAdded
105106
);
@@ -133,6 +134,7 @@ test.describe('Basic Stack Manipulation', async () => {
133134
const locator = page.locator('.cornerstone-canvas');
134135
await simulateDrag(page, locator);
135136
await checkForScreenshot(
137+
page,
136138
locator,
137139
screenShotPaths.stackManipulationTools.windowLevel
138140
);

playwright.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ export default defineConfig({
2525
name: 'firefox',
2626
use: { ...devices['Desktop Firefox'], deviceScaleFactor: 1 },
2727
},
28-
{
29-
name: 'webkit',
30-
use: { ...devices['Desktop Safari'], deviceScaleFactor: 1 },
31-
},
28+
// This is commented out until SharedArrayBuffer is enabled in WebKit
29+
// See: https://github.com/microsoft/playwright/issues/14043
30+
//{
31+
// name: 'webkit',
32+
// use: { ...devices['Desktop Safari'], deviceScaleFactor: 1 },
33+
//},
3234
],
3335
webServer: {
3436
command: 'yarn build-and-serve-static-examples',
Loading
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

tests/stackAPI.spec.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,64 @@ test.describe('Stack Viewport API', async () => {
1313
test('should set VOI range correctly', async ({ page }) => {
1414
await page.getByRole('button', { name: 'Set VOI Range' }).click();
1515
const locator = page.locator('.cornerstone-canvas');
16-
await checkForScreenshot(locator, screenShotPaths.stackAPI.setVoiRange);
16+
await checkForScreenshot(
17+
page,
18+
locator,
19+
screenShotPaths.stackAPI.setVoiRange
20+
);
1721
});
1822
test('should move to next image', async ({ page }) => {
1923
await page.getByRole('button', { name: 'Next Image' }).click();
2024
const locator = page.locator('.cornerstone-canvas');
21-
await checkForScreenshot(locator, screenShotPaths.stackAPI.nextImage);
25+
await checkForScreenshot(page, locator, screenShotPaths.stackAPI.nextImage);
2226
});
2327
test('should move to previous image', async ({ page }) => {
2428
await page.getByRole('button', { name: 'Next Image' }).click();
2529
await page.getByRole('button', { name: 'Previous Image' }).click();
2630
const locator = page.locator('.cornerstone-canvas');
27-
await checkForScreenshot(locator, screenShotPaths.stackAPI.previousImage);
31+
await checkForScreenshot(
32+
page,
33+
locator,
34+
screenShotPaths.stackAPI.previousImage
35+
);
2836
});
2937
test('should flip horizontally ', async ({ page }) => {
3038
await page.getByRole('button', { name: 'Flip H' }).click();
3139
const locator = page.locator('.cornerstone-canvas');
32-
await checkForScreenshot(locator, screenShotPaths.stackAPI.flipH);
40+
await checkForScreenshot(page, locator, screenShotPaths.stackAPI.flipH);
3341
});
3442
test('should flip vertically ', async ({ page }) => {
3543
await page.getByRole('button', { name: 'Flip V' }).click();
3644
const locator = page.locator('.cornerstone-canvas');
37-
await checkForScreenshot(locator, screenShotPaths.stackAPI.flipV);
45+
await checkForScreenshot(page, locator, screenShotPaths.stackAPI.flipV);
3846
});
3947
test('should rotate absolute 150 degrees', async ({ page }) => {
4048
await page.getByRole('button', { name: 'Rotate Absolute 150' }).click();
4149
const locator = page.locator('.cornerstone-canvas');
4250
await checkForScreenshot(
51+
page,
4352
locator,
4453
screenShotPaths.stackAPI.rotateAbsolute150
4554
);
4655
});
4756
test('should rotate delta 30 degrees', async ({ page }) => {
4857
await page.getByRole('button', { name: 'Rotate Delta 30' }).click();
4958
const locator = page.locator('.cornerstone-canvas');
50-
await checkForScreenshot(locator, screenShotPaths.stackAPI.rotateDelta30);
59+
await checkForScreenshot(
60+
page,
61+
locator,
62+
screenShotPaths.stackAPI.rotateDelta30
63+
);
5164
});
5265
test('should invert', async ({ page }) => {
5366
await page.getByRole('button', { name: 'Invert' }).click();
5467
const locator = page.locator('.cornerstone-canvas');
55-
await checkForScreenshot(locator, screenShotPaths.stackAPI.invert);
68+
await checkForScreenshot(page, locator, screenShotPaths.stackAPI.invert);
5669
});
5770
test('should apply colormap', async ({ page }) => {
5871
await page.getByRole('button', { name: 'Apply Colormap' }).click();
5972
const locator = page.locator('.cornerstone-canvas');
60-
await checkForScreenshot(locator, screenShotPaths.stackAPI.colormap);
73+
await checkForScreenshot(page, locator, screenShotPaths.stackAPI.colormap);
6174
});
6275

6376
test('should reset', async ({ page }) => {
@@ -67,6 +80,10 @@ test.describe('Stack Viewport API', async () => {
6780
await page.getByRole('button', { name: 'Rotate Random' }).click();
6881
await page.getByRole('button', { name: 'Reset Viewport' }).click();
6982
const locator = page.locator('.cornerstone-canvas');
70-
await checkForScreenshot(locator, screenShotPaths.stackAPI.resetViewport);
83+
await checkForScreenshot(
84+
page,
85+
locator,
86+
screenShotPaths.stackAPI.resetViewport
87+
);
7188
});
7289
});

tests/stackBasic.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ test.describe('Basic Stack', async () => {
1414
page,
1515
}) => {
1616
const locator = page.locator('.cornerstone-canvas');
17-
await checkForScreenshot(locator, screenShotPaths.stackBasic.viewport);
17+
await checkForScreenshot(
18+
page,
19+
locator,
20+
screenShotPaths.stackBasic.viewport
21+
);
1822
});
1923
});

tests/stackManipulationTools.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ test.describe('Basic Stack Manipulation', async () => {
1818
const locator = page.locator('.cornerstone-canvas');
1919
await simulateDrag(page, locator);
2020
await checkForScreenshot(
21+
page,
2122
locator,
2223
screenShotPaths.stackManipulationTools.windowLevel
2324
);
@@ -29,6 +30,7 @@ test.describe('Basic Stack Manipulation', async () => {
2930
const locator = page.locator('.cornerstone-canvas');
3031
await simulateDrag(page, locator);
3132
await checkForScreenshot(
33+
page,
3234
locator,
3335
screenShotPaths.stackManipulationTools.planarRotate
3436
);

tests/stackProperties.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ test.describe('Stack Properties', async () => {
1414
await page.getByRole('button', { name: 'Next Image' }).click();
1515
const locator = page.locator('.cornerstone-canvas');
1616
await checkForScreenshot(
17+
page,
1718
locator,
1819
screenShotPaths.stackProperties.nextImage
1920
);
@@ -24,6 +25,7 @@ test.describe('Stack Properties', async () => {
2425
await page.getByRole('button', { name: 'Previous Image' }).click();
2526
const locator = page.locator('.cornerstone-canvas');
2627
await checkForScreenshot(
28+
page,
2729
locator,
2830
screenShotPaths.stackProperties.previousImage
2931
);
@@ -37,11 +39,13 @@ test.describe('Stack Properties', async () => {
3739
.click();
3840
const locator = page.locator('.cornerstone-canvas');
3941
await checkForScreenshot(
42+
page,
4043
locator,
4144
screenShotPaths.stackProperties.propertiesAddedForCurrentImage
4245
);
4346
await page.getByRole('button', { name: 'Next Image' }).click();
4447
await checkForScreenshot(
48+
page,
4549
locator,
4650
screenShotPaths.stackProperties.propertiesAreSameForNextImage
4751
);
@@ -60,11 +64,13 @@ test.describe('Stack Properties', async () => {
6064
.click();
6165
const locator = page.locator('.cornerstone-canvas');
6266
await checkForScreenshot(
67+
page,
6368
locator,
6469
screenShotPaths.stackProperties.propertiesRemovedForCurrentImage
6570
);
6671
await page.getByRole('button', { name: 'Previous Image' }).click();
6772
await checkForScreenshot(
73+
page,
6874
locator,
6975
screenShotPaths.stackProperties.propertiesAreSameForPreviousImage
7076
);
@@ -80,6 +86,7 @@ test.describe('Stack Properties', async () => {
8086
.click();
8187
const locator = page.locator('.cornerstone-canvas');
8288
await checkForScreenshot(
89+
page,
8390
locator,
8491
screenShotPaths.stackProperties.resetToDefaultViewportProperties
8592
);
@@ -92,6 +99,7 @@ test.describe('Stack Properties', async () => {
9299
await page.getByRole('button', { name: 'Reset to metadata' }).click();
93100
const locator = page.locator('.cornerstone-canvas');
94101
await checkForScreenshot(
102+
page,
95103
locator,
96104
screenShotPaths.stackProperties.resetMetadata
97105
);

tests/utils/checkForScreenshot.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { expect } from '@playwright/test';
22

33
/**
4-
*
4+
* @param page - The page to interact with
55
* @param locator - The element to check for screenshot
66
* @param screenshotPath - The path to save the screenshot
77
* @param attempts - The number of attempts to check for screenshot
88
* @param delay - The delay between attempts
99
* @returns True if the screenshot matches, otherwise throws an error
1010
*/
1111
const checkForScreenshot = async (
12+
page,
1213
locator,
1314
screenshotPath,
1415
attempts = 10,
1516
delay = 100
1617
) => {
18+
await page.waitForLoadState('networkidle');
1719
for (let i = 1; i < attempts; i++) {
1820
try {
1921
await expect(locator).toHaveScreenshot(screenshotPath, {

tests/utils/screenShotPaths.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ const screenShotPaths = {
3333
resetToDefaultViewportProperties: 'resetToDefaultViewportProperties.png',
3434
resetMetadata: 'resetMetadata.png',
3535
},
36+
volumeBasic: {
37+
viewport: 'viewport.png',
38+
},
3639
};
3740

3841
export { screenShotPaths };

tests/volumeBasic.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { test } from '@playwright/test';
2+
import {
3+
visitExample,
4+
checkForScreenshot,
5+
screenShotPaths,
6+
} from './utils/index';
7+
8+
test.beforeEach(async ({ page }) => {
9+
await visitExample(page, 'volumeBasic');
10+
});
11+
12+
test.describe('Basic Volume', async () => {
13+
test('should display a single DICOM series in a Volume viewport.', async ({
14+
page,
15+
}) => {
16+
const locator = page.locator('.cornerstone-canvas');
17+
await checkForScreenshot(
18+
page,
19+
locator,
20+
screenShotPaths.volumeBasic.viewport
21+
);
22+
});
23+
});

0 commit comments

Comments
 (0)