|
| 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