Skip to content

Commit 27a5fd2

Browse files
authored
test(v4): add features verification (3d transform, container query, !important) (#86)
This PR adds test cases for new Tailwind CSS v4 features including 3D transforms, container queries, and the !important modifier syntax.
1 parent facfa43 commit 27a5fd2

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

test/v4-features/index.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { dirname } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
import { expect, test } from '@playwright/test';
4+
import { createRsbuild } from '@rsbuild/core';
5+
import { pluginTailwindCSS } from '../../src';
6+
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
9+
test('should support Tailwind CSS v4 features', async ({ page }) => {
10+
const rsbuild = await createRsbuild({
11+
cwd: __dirname,
12+
rsbuildConfig: {
13+
plugins: [pluginTailwindCSS()],
14+
},
15+
});
16+
17+
await rsbuild.build();
18+
const { server, urls } = await rsbuild.preview();
19+
20+
await page.goto(urls[0]);
21+
22+
// 1. Test !important modifier
23+
const important = page.locator('#important');
24+
await expect(important).toHaveCSS('display', 'flex');
25+
26+
// 2. Test 3D transforms
27+
const transform = page.locator('#transform');
28+
await expect(transform).toHaveCSS('perspective', '500px');
29+
// Check for rotateX in transform. Computed value is usually a matrix.
30+
await expect(transform).not.toHaveCSS('transform', 'none');
31+
32+
// 3. Test Container Queries
33+
const containerItem = page.locator('#container-item');
34+
// In v4, colors might be returned as lab/oklch depending on browser support.
35+
// We accept the lab value seen in tests or the rgb fallback if environment differs.
36+
// Received: "lab(55.4814 75.0732 48.8528)"
37+
const color = await containerItem.evaluate(
38+
(el) => getComputedStyle(el).color,
39+
);
40+
expect(color).toMatch(
41+
/^(rgb\(239, 68, 68\)|lab\(55\.4814 75\.0732 48\.8528\)|oklch\(0\.637 0\.237 25\.331\))$/,
42+
);
43+
44+
await server.close();
45+
});

test/v4-features/src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "tailwindcss";

test/v4-features/src/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import './index.css';
2+
3+
// 1. Important modifier
4+
const importantDiv = document.createElement('div');
5+
importantDiv.id = 'important';
6+
importantDiv.className = 'flex!';
7+
importantDiv.textContent = 'Important Flex';
8+
document.body.appendChild(importantDiv);
9+
10+
// 2. 3D Transforms
11+
const transformDiv = document.createElement('div');
12+
transformDiv.id = 'transform';
13+
transformDiv.className = 'perspective-[500px] rotate-x-12';
14+
transformDiv.textContent = '3D Transform';
15+
document.body.appendChild(transformDiv);
16+
17+
// 3. Container Queries
18+
const container = document.createElement('div');
19+
container.className = '@container/main w-[300px]';
20+
const item = document.createElement('div');
21+
item.id = 'container-item';
22+
item.className = '@[200px]:text-red-500';
23+
item.textContent = 'Container Item';
24+
container.appendChild(item);
25+
document.body.appendChild(container);

0 commit comments

Comments
 (0)