Skip to content

Commit 3528f43

Browse files
Added tests for show result text on the video overlay.
1 parent 8172798 commit 3528f43

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

tests/unittest/read-a-drivers-license.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { test, expect } from '@playwright/test';
33
/*
44
1. Test the Read Driver's License page should have the correct header.
55
2. Test the Read Driver's License page should have the correct heading.
6+
3. Test the Read Driver's License page should have the camera icon to activate the video streaming.
67
*/
78

89
const URL = '/use-case/read-a-drivers-license/index.html';
@@ -13,11 +14,19 @@ test.beforeEach(async ({ page }) => {
1314

1415
test('should have correct title', async ({ page }) => {
1516
const title = await page.title();
16-
expect(title).toBe("Dynamsoft Barcode Reader Sample - Read a Driver's License");
17+
await expect(title).toBe("Dynamsoft Barcode Reader Sample - Read a Driver's License");
1718
});
1819

1920
test('should have main heading', async ({ page }) => {
2021
const h1 = await page.locator('h1');
21-
expect(h1).not.toBeNull();
22+
await expect(h1).not.toBeNull();
2223
await expect(h1).toHaveText("Read a Driver's License");
23-
});
24+
});
25+
26+
27+
test('should be able to click on the start scanning camera icon and load the video container', async ({ page }) => {
28+
await page.locator("svg#svg-start").click();
29+
const videoContainer = await page.locator(".dce-video-container");
30+
await expect(videoContainer).not.toBeNull();
31+
32+
})
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
/*
4+
1. Test the Display Barcode Results as Video Overlay page should have the correct header.
5+
2. Test the Display Barcode Results as Video Overlay page should have the correct main heading.
6+
3. Test the Display Barcode Results as Video Overlay page should have the camera view container.
7+
4. Test the Display Barcode Results as Video Overlay page should have the results field.
8+
*/
9+
10+
const URL = '/use-case/show-result-texts-on-the-video.html';
11+
12+
test.beforeEach(async ({ page }) => {
13+
await page.goto(URL);
14+
});
15+
16+
test('should have correct title', async ({ page }) => {
17+
const title = await page.title();
18+
expect(title).toBe("Dynamsoft Barcode Reader Sample - Display Barcode Results as Video Overlays");
19+
});
20+
21+
test('should have main heading', async ({ page }) => {
22+
const h1 = await page.locator('h1');
23+
expect(h1).not.toBeNull();
24+
await expect(h1).toHaveText('Display Barcode Results as Video Overlays');
25+
});
26+
27+
test('should have camera view container', async ({ page }) => {
28+
const cameraViewContainer = await page.locator('#camera-view-container');
29+
await expect(cameraViewContainer).toBeVisible();
30+
31+
const boundingBox = await cameraViewContainer.boundingBox();
32+
33+
const viewportSize = page.viewportSize();
34+
expect(boundingBox?.height).toBeCloseTo(viewportSize!.height * 0.9, -1);
35+
});
36+
37+
test('should have result containers', async ({ page }) => {
38+
const resultsContainer = await page.locator('#results');
39+
expect(resultsContainer).not.toBeNull();
40+
});

0 commit comments

Comments
 (0)