|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const { test, expect } = require('@playwright/test') |
| 4 | + |
| 5 | +const URL_DOCUMENTATION = '/documentation' |
| 6 | +const URL_FAVICON = '/documentation/static/theme/favicon.svg' |
| 7 | + |
| 8 | +test.describe('Check customizations', () => { |
| 9 | + test('Check JS injection', async ({ page }) => { |
| 10 | + await page.goto(URL_DOCUMENTATION) |
| 11 | + await page.waitForLoadState('networkidle') |
| 12 | + |
| 13 | + page.on('dialog', async dialog => { |
| 14 | + expect(dialog.type() === 'beforeunload').toBeTruthy() |
| 15 | + expect(dialog.message() === 'unloaded test-theme').toBeTruthy() |
| 16 | + await dialog.dismiss() |
| 17 | + }) |
| 18 | + await page.close({ runBeforeUnload: true }) |
| 19 | + }) |
| 20 | + |
| 21 | + test('Check CSS injection', async ({ page }) => { |
| 22 | + await page.goto(URL_DOCUMENTATION) |
| 23 | + await page.waitForLoadState('networkidle') |
| 24 | + |
| 25 | + const element = await page.waitForSelector('button.download-url-button') |
| 26 | + const color = await element.evaluate(el => window.getComputedStyle(el).getPropertyValue('background-color')) |
| 27 | + expect(color).toBe('rgb(255, 0, 0)') |
| 28 | + }) |
| 29 | + |
| 30 | + test('Check custom favicon', async ({ page }) => { |
| 31 | + await page.goto(URL_FAVICON) |
| 32 | + |
| 33 | + const faviconId = await (await page.waitForSelector('svg')).getAttribute('id') |
| 34 | + expect(faviconId).toBe('example-logo') // it is included in the svg file |
| 35 | + }) |
| 36 | + |
| 37 | + test('Check custom logo', async ({ page }) => { |
| 38 | + await page.goto(URL_DOCUMENTATION) |
| 39 | + await page.waitForLoadState('networkidle') |
| 40 | + |
| 41 | + const logoSrc = await page.locator('img').first().getAttribute('src') |
| 42 | + await page.goto(logoSrc) |
| 43 | + |
| 44 | + const logoId = await (await page.waitForSelector('svg')).getAttribute('id') |
| 45 | + expect(logoId).toBe('example-logo') // it is included in the svg file |
| 46 | + }) |
| 47 | +}) |
0 commit comments