-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.spec.ts
49 lines (42 loc) · 1.62 KB
/
module.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { test, expect } from '@playwright/test';
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test.describe('Bootstrap 4', () => {
test('should initially hide page content', async ({ page }) => {
await expect(page.locator('body')).toBeHidden();
});
test('should eventually display page content', async ({ page }) => {
await expect(page.locator('body')).toBeVisible();
});
test('should style alert messages', async ({ page }) => {
const alert = page.locator('.alert-primary').first();
const initialColor = await alert.evaluate((el) => {
return getComputedStyle(el).backgroundColor;
});
await page.waitForResponse(
'https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css'
);
const styledColor = await alert.evaluate((el) => getComputedStyle(el).backgroundColor);
expect(styledColor !== initialColor);
});
test.describe('Modal', () => {
test('should have one hidden modal', async ({ page }) => {
const modal = page.locator('[role="dialog"]');
const isHidden = await modal.getAttribute('aria-hidden');
expect((await modal.count()).valueOf() === 1);
expect(isHidden.valueOf() === 'true');
});
test('should have button to launch modal', async ({ page }) => {
const button = page.locator('text=Launch demo modal');
expect(button).toBeDefined();
});
test('should launch modal on button click', async ({ page }) => {
const modal = page.locator('[role="dialog"]');
const isHidden = await modal.getAttribute('aria-hidden');
const button = page.locator('text=Launch demo modal');
await button.click();
expect(isHidden.valueOf() === 'false');
});
});
});