Skip to content

Commit 81ab881

Browse files
committed
test(e2e): add case for importing styles from packages
1 parent 19e4d40 commit 81ab881

File tree

9 files changed

+62
-0
lines changed

9 files changed

+62
-0
lines changed

e2e/docs/.vuepress/client.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { defineClientConfig } from 'vuepress/client'
22
import RootComponentFromUserConfig from './components/RootComponentFromUserConfig.vue'
33

4+
// static imported styles file
5+
import '@vuepress-e2e/style-exports/foo.css'
6+
47
export default defineClientConfig({
8+
async enhance() {
9+
// dynamic imported styles file
10+
await import('@vuepress-e2e/style-exports')
11+
},
512
rootComponents: [RootComponentFromUserConfig],
613
})

e2e/docs/imports/style-exports.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="style-exports">dynamic import</div>
2+
3+
<div class="style-exports-foo">static import</div>

e2e/modules/style-exports/foo.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.style-exports-foo {
2+
font-size: 30px;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.style-exports {
2+
font-size: 20px;
3+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@vuepress-e2e/style-exports",
3+
"type": "module",
4+
"exports": {
5+
".": {
6+
"types": "./types.d.ts",
7+
"default": "./index.css"
8+
},
9+
"./foo.css": {
10+
"types": "./types.d.ts",
11+
"default": "./foo.css"
12+
}
13+
},
14+
"main": "./index.css",
15+
"module": "./index.css",
16+
"types": "./types.d.ts"
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {}

e2e/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"dependencies": {
1919
"@vuepress-e2e/conditional-exports": "file:./modules/conditional-exports",
20+
"@vuepress-e2e/style-exports": "file:./modules/style-exports",
2021
"@vuepress/bundler-vite": "workspace:*",
2122
"@vuepress/bundler-webpack": "workspace:*",
2223
"sass": "^1.77.4",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { expect, test } from '@playwright/test'
2+
3+
test('should load dynamic imported styles correctly', async ({ page }) => {
4+
await page.goto('imports/style-exports.html')
5+
6+
const locator = page.locator('.style-exports')
7+
8+
await expect(locator).toHaveText('dynamic import')
9+
await expect(locator).toHaveCSS('font-size', '20px')
10+
})
11+
12+
test('should load static imported styles correctly', async ({ page }) => {
13+
await page.goto('imports/style-exports.html')
14+
15+
const locator = page.locator('.style-exports-foo')
16+
17+
await expect(locator).toHaveText('static import')
18+
await expect(locator).toHaveCSS('font-size', '30px')
19+
})

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)