|
1 |
| -// Modules, constants, and variables |
2 |
| -// ----------------------------------------------------------------------------- |
3 | 1 | import docsifyInit from '../helpers/docsify-init.js';
|
4 | 2 | import { test, expect } from './fixtures/docsify-init-fixture.js';
|
5 | 3 |
|
6 |
| -// Suite |
7 |
| -// ----------------------------------------------------------------------------- |
8 |
| -test.describe('Example Tests', () => { |
9 |
| - // Tests |
10 |
| - // --------------------------------------------------------------------------- |
11 |
| - test('dom manipulation', async ({ page }) => { |
12 |
| - const testText = 'This is a test'; |
13 |
| - const testHTML = `<h1>Test</h1><p>${testText}</p>`; |
14 |
| - |
15 |
| - // Inject HTML |
16 |
| - await page.setContent(testHTML); |
17 |
| - |
18 |
| - // Get reference to page element |
19 |
| - const bodyElm = page.locator('body'); |
20 |
| - const pElm = page.locator('body > p'); |
21 |
| - |
22 |
| - // Add class to element and test |
23 |
| - await bodyElm.evaluate(elm => elm.classList.add('foo')); |
24 |
| - |
25 |
| - // Tests |
26 |
| - await expect(bodyElm).toHaveClass('foo'); |
27 |
| - await expect(bodyElm).toContainText('Test'); |
28 |
| - await expect(pElm).toHaveCount(1); |
29 |
| - await expect(pElm).toHaveText(testText); |
30 |
| - await expect(pElm).not.toHaveText('NOPE'); |
31 |
| - }); |
32 |
| - |
33 |
| - test('javascript in browser context', async ({ page }) => { |
34 |
| - // Get native DOM values |
35 |
| - const clientDimensions = await page.evaluate(() => { |
36 |
| - return { |
37 |
| - width: document.documentElement.clientWidth, |
38 |
| - height: document.documentElement.clientHeight, |
39 |
| - }; |
40 |
| - }); |
41 |
| - |
42 |
| - expect(clientDimensions).toHaveProperty('width'); |
43 |
| - expect(typeof clientDimensions.width).toBe('number'); |
44 |
| - expect(clientDimensions).toHaveProperty('height'); |
45 |
| - expect(typeof clientDimensions.height).toBe('number'); |
46 |
| - |
47 |
| - // Get result of script executed in browser context |
48 |
| - const scriptResult = await page.evaluate( |
49 |
| - numbers => { |
50 |
| - const result = numbers.reduce( |
51 |
| - (accumulator, currentValue) => accumulator + currentValue |
52 |
| - ); |
53 |
| - |
54 |
| - return Promise.resolve(result); |
55 |
| - }, |
56 |
| - [1, 2, 3] |
57 |
| - ); |
58 |
| - |
59 |
| - expect(scriptResult).toBe(6); |
60 |
| - |
61 |
| - // Get result of local function executed in browser context |
62 |
| - function add(...addends) { |
63 |
| - return addends.reduce( |
64 |
| - (accumulator, currentValue) => accumulator + currentValue |
65 |
| - ); |
66 |
| - } |
67 |
| - |
68 |
| - const functionResult = await page.evaluate(` |
69 |
| - const add = ${add.toString()}; |
70 |
| -
|
71 |
| - const result = add(1, 2, 3); |
72 |
| -
|
73 |
| - Promise.resolve(result); |
74 |
| - `); |
75 |
| - |
76 |
| - expect(functionResult).toBe(6); |
77 |
| - }); |
78 |
| - |
| 4 | +test.describe('Creating a Docsify site (e2e tests in Playwright)', () => { |
79 | 5 | test('manual docsify site using playwright methods', async ({ page }) => {
|
80 | 6 | // Add docsify target element
|
81 | 7 | await page.setContent('<div id="app"></div>');
|
|
0 commit comments