Skip to content

Commit 8172798

Browse files
Added unittests for ES6, PWA, and requireJS pages
1 parent 1a37223 commit 8172798

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

tests/unittest/ES6.test.ts

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 ES6 hello wolrd page should have the correct header.
5+
2. Test the ES6 hello world page should have the correct main heading.
6+
3. Test the ES6 hello world page should have the camera view container.
7+
4. Test the ES6 hello world page should have the results field.
8+
*/
9+
10+
const URL = '/hello-world/es6.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 - Hello World for ES6 (Decode via Camera)");
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('Hello World for ES6 (Decode via Camera)');
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.8, -1);
35+
});
36+
37+
test('should have result containers', async ({ page }) => {
38+
const resultsContainer = await page.locator('#results');
39+
expect(resultsContainer).not.toBeNull();
40+
});

tests/unittest/pwa.test.ts

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 PWA hello wolrd page should have the correct header.
5+
2. Test the PWA hello world page should have the correct main heading.
6+
3. Test the PWA hello world page should have the camera view container.
7+
4. Test the PWA hello world page should have the results field.
8+
*/
9+
10+
const URL = '/hello-world/pwa/helloworld-pwa.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 PWA Sample - Hello World (Decode via Camera)");
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('Hello World for PWA');
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.8, -1);
35+
});
36+
37+
test('should have result containers', async ({ page }) => {
38+
const resultsContainer = await page.locator('#results');
39+
expect(resultsContainer).not.toBeNull();
40+
});

tests/unittest/requireJS.test.ts

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 requireJS hello wolrd page should have the correct header.
5+
2. Test the requireJS hello world page should have the correct main heading.
6+
3. Test the requireJS hello world page should have the camera view container.
7+
4. Test the requireJS hello world page should have the results field.
8+
*/
9+
10+
const URL = '/hello-world/requirejs.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 - Hello World for RequireJS (Decode via Camera)");
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('Hello World for RequireJS (Decode via Camera)');
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.8, -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)