Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit f0907ac

Browse files
committed
test(e2e/test): add and pass
1 parent 1ddeeb8 commit f0907ac

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

e2e/test/class-conflict.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('Class conflict resolution works correctly', async ({ page }) => {
4+
await page.goto('http://localhost:4000');
5+
await page.waitForSelector('[data-testid="e2e-test-span"]');
6+
const div = page.locator('[data-testid="e2e-test-span"]');
7+
await div.evaluate((node) => node.classList.add('test_conflict'));
8+
await expect(div).toHaveCSS('font-size', '14px');
9+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('Components have correct classes applied', async ({ page }) => {
4+
await page.goto('http://localhost:4000');
5+
await page.waitForSelector('[data-testid="e2e-test-div"]');
6+
const div = page.locator('[data-testid="e2e-test-div"]');
7+
await expect(div).toHaveClass(/e2e_/);
8+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('Media queries are placed after regular selectors', async ({ page }) => {
4+
await page.goto('http://localhost:4000');
5+
await page.waitForSelector('head > style', { state: 'attached' });
6+
const styleContent = await page.evaluate(() => {
7+
return Array.from(document.styleSheets)
8+
.filter((sheet) => sheet.href === null || sheet.href.startsWith(window.location.origin))
9+
.map((sheet) =>
10+
Array.from(sheet.cssRules)
11+
.map((rule) => rule.cssText)
12+
.join('\n')
13+
)
14+
.join('\n');
15+
});
16+
expect(styleContent).toMatch(/^[^@]+@media/);
17+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('Responsive design applies correct styles based on viewport size', async ({ page }) => {
4+
await page.goto('http://localhost:4000');
5+
await page.waitForSelector('[data-testid="e2e-test-div"]');
6+
const div = page.locator('[data-testid="e2e-test-div"]');
7+
8+
await page.setViewportSize({ width: 1200, height: 800 });
9+
await expect(div).toHaveCSS('color', 'rgb(255, 192, 203)');
10+
11+
await page.setViewportSize({ width: 800, height: 600 });
12+
await expect(div).toHaveCSS('color', 'rgb(0, 255, 255)');
13+
});

e2e/test/style-inject-head.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('Stylesheet is correctly inserted in the head', async ({ page }) => {
4+
await page.goto('http://localhost:4000');
5+
await page.waitForSelector('head > style', { state: 'attached' });
6+
const styleElements = await page.locator('head > style').count();
7+
expect(styleElements).toBeGreaterThan(0);
8+
});

0 commit comments

Comments
 (0)