-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): add test case for CSS layers (#3669)
- Loading branch information
1 parent
a4263a7
commit 8573c97
Showing
7 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,66 @@ | ||
import { build, dev, rspackOnlyTest } from '@e2e/helper'; | ||
import { expect } from '@playwright/test'; | ||
|
||
rspackOnlyTest('should bundle CSS layers as expected in build', async () => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
}); | ||
const files = await rsbuild.unwrapOutputJSON(); | ||
|
||
const content = | ||
files[Object.keys(files).find((file) => file.endsWith('.css'))!]; | ||
|
||
expect(content).toEqual( | ||
'@layer a{.a{color:red}}@layer b{.b{color:green}}@layer c{@layer{.c-sub{color:#00f}.c-sub2{color:green}}.c{color:#00f}}', | ||
); | ||
}); | ||
|
||
rspackOnlyTest( | ||
'should bundle CSS layers as expected in dev', | ||
async ({ page }) => { | ||
const rsbuild = await dev({ | ||
cwd: __dirname, | ||
page, | ||
rsbuildConfig: { | ||
dev: { | ||
writeToDisk: true, | ||
}, | ||
}, | ||
}); | ||
const files = await rsbuild.unwrapOutputJSON(); | ||
|
||
const content = | ||
files[Object.keys(files).find((file) => file.endsWith('.css'))!]; | ||
|
||
expect(content.trim()).toEqual(`@layer a { | ||
.a { | ||
color: red; | ||
} | ||
} | ||
@layer b { | ||
.b { | ||
color: green; | ||
} | ||
} | ||
@layer c { | ||
@layer {.c-sub { | ||
color: #00f; | ||
} | ||
.c-sub2 { | ||
color: green; | ||
} | ||
} | ||
} | ||
@layer c { | ||
.c { | ||
color: #00f; | ||
} | ||
}`); | ||
|
||
await rsbuild.close(); | ||
}, | ||
); |
This file contains 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,3 @@ | ||
.a { | ||
color: red; | ||
} |
This file contains 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,3 @@ | ||
.b { | ||
color: green; | ||
} |
This file contains 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,7 @@ | ||
.c-sub { | ||
color: blue; | ||
} | ||
|
||
.c-sub2 { | ||
color: green; | ||
} |
This file contains 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,5 @@ | ||
@import './c-sub.css' layer; | ||
|
||
.c { | ||
color: blue; | ||
} |
This file contains 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 './style.css'; |
This file contains 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,3 @@ | ||
@import './a.css' layer(a); | ||
@import './b.css' layer(b); | ||
@import './c.css' layer(c); |