-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: remove plugin-vue from tailwind playground (#14073)
- Loading branch information
1 parent
d36d6fb
commit 0768625
Showing
16 changed files
with
130 additions
and
164 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
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 |
---|---|---|
@@ -1,84 +1,82 @@ | ||
import { expect, test } from 'vitest' | ||
import { | ||
editFile, | ||
getBgColor, | ||
getColor, | ||
isBuild, | ||
isServe, | ||
page, | ||
untilBrowserLogAfter, | ||
untilUpdated, | ||
} from '~utils' | ||
|
||
test('should render', async () => { | ||
expect(await page.textContent('#pagetitle')).toBe('|Page title|') | ||
expect(await page.textContent('#pagetitle')).toBe('Page title') | ||
}) | ||
|
||
if (!isBuild) { | ||
test('regenerate CSS and HMR (glob pattern)', async () => { | ||
const el = await page.$('#pagetitle') | ||
const el2 = await page.$('#helloroot') | ||
expect(await getColor(el)).toBe('rgb(11, 22, 33)') | ||
test.runIf(isServe)('regenerate CSS and HMR (glob pattern)', async () => { | ||
const el = page.locator('#view1-text') | ||
expect(await getColor(el)).toBe('rgb(22, 163, 74)') | ||
|
||
await untilBrowserLogAfter( | ||
() => | ||
editFile('src/views/Page.vue', (code) => | ||
code.replace('|Page title|', '|Page title updated|'), | ||
), | ||
[ | ||
'[vite] css hot updated: /index.css', | ||
'[vite] hot updated: /src/views/Page.vue', | ||
], | ||
false, | ||
) | ||
await untilUpdated(() => el.textContent(), '|Page title updated|') | ||
await untilBrowserLogAfter( | ||
() => | ||
editFile('src/views/view1.js', (code) => | ||
code.replace('|view1|', '|view1 updated|'), | ||
), | ||
[ | ||
'[vite] css hot updated: /index.css', | ||
'[vite] hot updated: /src/views/view1.js via /src/main.js', | ||
], | ||
false, | ||
) | ||
await untilUpdated(() => el.textContent(), '|view1 updated|') | ||
|
||
await untilBrowserLogAfter( | ||
() => | ||
editFile('src/components/HelloWorld.vue', (code) => | ||
code.replace('text-gray-800', 'text-[rgb(10,20,30)]'), | ||
), | ||
[ | ||
'[vite] css hot updated: /index.css', | ||
'[vite] hot updated: /src/components/HelloWorld.vue', | ||
], | ||
false, | ||
) | ||
await untilUpdated(() => getColor(el2), 'rgb(10, 20, 30)') | ||
}) | ||
await untilBrowserLogAfter( | ||
() => | ||
editFile('src/views/view1.js', (code) => | ||
code.replace('text-green-600', 'text-orange-600'), | ||
), | ||
[ | ||
'[vite] css hot updated: /index.css', | ||
'[vite] hot updated: /src/views/view1.js via /src/main.js', | ||
], | ||
false, | ||
) | ||
// await new Promise(resolve => setTimeout(resolve, 10)) | ||
await untilUpdated(async () => getColor(el), 'rgb(234, 88, 12)') | ||
}) | ||
|
||
test('regenerate CSS and HMR (relative path)', async () => { | ||
const el = await page.$('h1') | ||
expect(await getColor(el)).toBe('black') | ||
test.runIf(isServe)( | ||
'same file duplicated in module graph (#4267)', | ||
async () => { | ||
const el = page.locator('#component1') | ||
expect(await getColor(el)).toBe('rgb(220, 38, 38)') | ||
|
||
// when duplicated, page reload happens | ||
await untilBrowserLogAfter( | ||
() => | ||
editFile('src/App.vue', (code) => | ||
code.replace('text-black', 'text-[rgb(11,22,33)]'), | ||
editFile('src/components/component1.js', (code) => | ||
code.replace('text-red-600', 'text-blue-600'), | ||
), | ||
[ | ||
'[vite] css hot updated: /index.css', | ||
'[vite] hot updated: /src/App.vue', | ||
'[vite] hot updated: /src/components/component1.js', | ||
], | ||
false, | ||
) | ||
await untilUpdated(() => getColor(el), 'rgb(11, 22, 33)') | ||
}) | ||
await untilUpdated(() => getColor(el), 'rgb(37, 99, 235)') | ||
}, | ||
) | ||
|
||
test('regenerate CSS and HMR (pug template)', async () => { | ||
const el = await page.$('.pug') | ||
expect(await getBgColor(el)).toBe('rgb(248, 113, 113)') | ||
test.runIf(isServe)('regenerate CSS and HMR (relative path)', async () => { | ||
const el = page.locator('#pagetitle') | ||
expect(await getColor(el)).toBe('rgb(124, 58, 237)') | ||
|
||
await untilBrowserLogAfter( | ||
() => | ||
editFile('src/components/PugTemplate.vue', (code) => | ||
code.replace('bg-red-400', 'bg-red-600'), | ||
), | ||
[ | ||
'[vite] css hot updated: /index.css', | ||
'[vite] hot updated: /src/components/PugTemplate.vue?vue&type=template&lang.js', | ||
], | ||
false, | ||
) | ||
await untilUpdated(() => getBgColor(el), 'rgb(220, 38, 38)') | ||
}) | ||
} | ||
await untilBrowserLogAfter( | ||
() => | ||
editFile('src/main.js', (code) => | ||
code.replace('text-violet-600', 'text-cyan-600'), | ||
), | ||
['[vite] css hot updated: /index.css', '[vite] hot updated: /src/main.js'], | ||
false, | ||
) | ||
await untilUpdated(() => getColor(el), 'rgb(8, 145, 178)') | ||
}) |
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 |
---|---|---|
@@ -1,14 +1,5 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
<link rel="stylesheet" href="./index.css" /> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.js"></script> | ||
</body> | ||
</html> | ||
<link rel="stylesheet" href="./index.css" /> | ||
|
||
<div id="app"></div> | ||
|
||
<script type="module" src="/src/main.js" defer></script> |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
export const component1 = /* html */ ` | ||
<div id="component1" data-id="component1" class="text-red-600">component1</div> | ||
` | ||
|
||
import.meta.hot?.accept((mod) => { | ||
document.querySelectorAll('[data-id="component1"]').forEach((d) => { | ||
d.outerHTML = mod.component1 | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,6 +1,18 @@ | ||
import { createApp } from 'vue' | ||
import App from './App.vue' | ||
import router from './router' | ||
// import '../index.css'; | ||
import { view1 } from './views/view1' | ||
|
||
createApp(App).use(router).mount('#app') | ||
export const main = (view1Content) => /* html */ ` | ||
<h1 id="pagetitle" class="text-3xl text-violet-600">Page title</h1> | ||
${view1Content} | ||
<!-- used in postcss-plugins-different-dir --> | ||
<div id="tailwind-style" class="bg-red-100 text-[#888888]">style</div> | ||
` | ||
|
||
document.getElementById('app').innerHTML = main(view1) | ||
|
||
import.meta.hot?.accept((mod) => { | ||
document.getElementById('app').innerHTML = mod.main(view1) | ||
}) | ||
|
||
import.meta.hot?.accept(['./views/view1'], ([mod]) => { | ||
document.getElementById('app').innerHTML = main(mod.view1) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
import { component1 } from '../components/component1' | ||
|
||
export const view1 = /* html */ ` | ||
<div data-id="view1"> | ||
<div id="view1-text" class="text-green-600">|view1|</div> | ||
${component1} | ||
</div> | ||
` |
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
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
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