Skip to content

Commit e34822f

Browse files
Deploy preview for PR 217 🛫
1 parent db51bd8 commit e34822f

File tree

4 files changed

+87
-1
lines changed

4 files changed

+87
-1
lines changed
13.9 KB
Loading
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 hello wolrd page should have the correct header.
5+
2. Test the hello world page should have the correct main heading.
6+
3. Test the hello world page should have the camera view container.
7+
4. Test the hello world page should have the results field.
8+
*/
9+
10+
const URL = '/hello-world/hello-world.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 (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 (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+
});

pr-preview/pr-217/tests/unittest/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { test, Locator, expect } from '@playwright/test';
2-
import exp from 'constants';
32

43
/*
54
1. Test the index page to contain correct links
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
/*
4+
1. Test the read an image page should have the correct header.
5+
2. Test the read an image page should have the correct main heading.
6+
3. Test the read an image page should have the results field.
7+
4. Test the read an image page should have input selector to select an image file as input and parsed in the results field..
8+
*/
9+
10+
const URL = '/hello-world/read-an-image.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 (Read an Image)");
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 (Read an Image)');
25+
});
26+
27+
test('should have result containers', async ({ page }) => {
28+
const resultsContainer = await page.locator('#results');
29+
expect(resultsContainer).not.toBeNull();
30+
});
31+
32+
test('should be able to select an image file as an input and parsed the Barcodes in the results', async ({ page }) => {
33+
const fileSelector = await page.locator('input#input-file');
34+
await expect(fileSelector).toBeVisible();
35+
const fileChooserPromise = page.waitForEvent('filechooser');
36+
await fileSelector.click();
37+
const fileChooser = await fileChooserPromise;
38+
await expect(fileChooser.isMultiple()).toBe(true);
39+
await fileChooser.setFiles('./tests/image-src/ABC.png');
40+
41+
const results = await page.locator('#results');
42+
await expect(results).toContainText("Dynamsoft-948743540084");
43+
await expect(results).toContainText("Dynamsoft-162323263989");
44+
await expect(results).toContainText("Dynamsoft-052408584613");
45+
46+
});
47+

0 commit comments

Comments
 (0)