-
Notifications
You must be signed in to change notification settings - Fork 6
test(v4): add features verification (3d transform, container query, !important) #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+71
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { dirname } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { expect, test } from '@playwright/test'; | ||
| import { createRsbuild } from '@rsbuild/core'; | ||
| import { pluginTailwindCSS } from '../../src'; | ||
|
|
||
| const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| test('should support Tailwind CSS v4 features', async ({ page }) => { | ||
| const rsbuild = await createRsbuild({ | ||
| cwd: __dirname, | ||
| rsbuildConfig: { | ||
| plugins: [pluginTailwindCSS()], | ||
| }, | ||
| }); | ||
|
|
||
| await rsbuild.build(); | ||
| const { server, urls } = await rsbuild.preview(); | ||
|
|
||
| await page.goto(urls[0]); | ||
|
|
||
| // 1. Test !important modifier | ||
| const important = page.locator('#important'); | ||
| await expect(important).toHaveCSS('display', 'flex'); | ||
|
|
||
| // 2. Test 3D transforms | ||
| const transform = page.locator('#transform'); | ||
| await expect(transform).toHaveCSS('perspective', '500px'); | ||
| // Check for rotateX in transform. Computed value is usually a matrix. | ||
| await expect(transform).not.toHaveCSS('transform', 'none'); | ||
|
|
||
| // 3. Test Container Queries | ||
| const containerItem = page.locator('#container-item'); | ||
| // In v4, colors might be returned as lab/oklch depending on browser support. | ||
| // We accept the lab value seen in tests or the rgb fallback if environment differs. | ||
| // Received: "lab(55.4814 75.0732 48.8528)" | ||
| const color = await containerItem.evaluate( | ||
| (el) => getComputedStyle(el).color, | ||
| ); | ||
| expect(color).toMatch( | ||
| /^(rgb\(239, 68, 68\)|lab\(55\.4814 75\.0732 48\.8528\)|oklch\(0\.637 0\.237 25\.331\))$/, | ||
| ); | ||
|
|
||
| await server.close(); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @import "tailwindcss"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import './index.css'; | ||
|
|
||
| // 1. Important modifier | ||
| const importantDiv = document.createElement('div'); | ||
| importantDiv.id = 'important'; | ||
| importantDiv.className = 'flex!'; | ||
| importantDiv.textContent = 'Important Flex'; | ||
| document.body.appendChild(importantDiv); | ||
|
|
||
| // 2. 3D Transforms | ||
| const transformDiv = document.createElement('div'); | ||
| transformDiv.id = 'transform'; | ||
| transformDiv.className = 'perspective-[500px] rotate-x-12'; | ||
| transformDiv.textContent = '3D Transform'; | ||
| document.body.appendChild(transformDiv); | ||
|
|
||
| // 3. Container Queries | ||
| const container = document.createElement('div'); | ||
| container.className = '@container/main w-[300px]'; | ||
| const item = document.createElement('div'); | ||
| item.id = 'container-item'; | ||
| item.className = '@[200px]:text-red-500'; | ||
| item.textContent = 'Container Item'; | ||
| container.appendChild(item); | ||
| document.body.appendChild(container); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.