Skip to content

Commit 784d38c

Browse files
committed
test: expand demo watch hmr coverage
1 parent d7db13a commit 784d38c

17 files changed

Lines changed: 1072 additions & 18 deletions

File tree

.github/workflows/e2e-watch.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,24 @@ jobs:
9292
watch_timeout_ms: '280000'
9393
watch_poll_ms: '300'
9494
watch_command_timeout_ms: '720000'
95+
- os: macos-latest
96+
runner_label: macos
97+
watch_case: taro-vite-vue3-tailwindcss-v4
98+
round_profile: default
99+
watch_save_snapshots: '1'
100+
timeout_minutes: 40
101+
watch_timeout_ms: '280000'
102+
watch_poll_ms: '300'
103+
watch_command_timeout_ms: '720000'
104+
- os: macos-latest
105+
runner_label: macos
106+
watch_case: taro-webpack-vue3-tailwindcss-v4
107+
round_profile: default
108+
watch_save_snapshots: '1'
109+
timeout_minutes: 45
110+
watch_timeout_ms: '320000'
111+
watch_poll_ms: '320'
112+
watch_command_timeout_ms: '840000'
95113
- os: macos-latest
96114
runner_label: macos
97115
watch_case: uni-app-vite-tailwindcss-v4
@@ -173,6 +191,15 @@ jobs:
173191
watch_timeout_ms: '320000'
174192
watch_poll_ms: '340'
175193
watch_command_timeout_ms: '840000'
194+
- os: windows-latest
195+
runner_label: windows
196+
watch_case: taro-vite-vue3-tailwindcss-v4
197+
round_profile: default
198+
watch_save_snapshots: '1'
199+
timeout_minutes: 45
200+
watch_timeout_ms: '320000'
201+
watch_poll_ms: '340'
202+
watch_command_timeout_ms: '840000'
176203
- os: windows-latest
177204
runner_label: windows
178205
watch_case: weapp-vite-tailwindcss-v3

e2e/e2eMatrix.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ const DEMO_HOT_UPDATE_CASES = [
1717
'mpx-tailwindcss-v4',
1818
'taro-webpack-react-tailwindcss-v3',
1919
'taro-webpack-react-tailwindcss-v4',
20+
'taro-webpack-vue3-tailwindcss-v3',
21+
'taro-webpack-vue3-tailwindcss-v4',
2022
'taro-vite-react-tailwindcss-v3',
2123
'taro-vite-react-tailwindcss-v4',
24+
'taro-vite-vue3-tailwindcss-v3',
25+
'taro-vite-vue3-tailwindcss-v4',
2226
'uni-app-vite-tailwindcss-v3',
2327
'uni-app-vite-tailwindcss-v4',
2428
'weapp-vite-tailwindcss-v3',
@@ -35,10 +39,6 @@ export const HOT_UPDATE_COVERED_PROJECTS = new Set(DEMO_HOT_UPDATE_CASES)
3539

3640
// 这些项目没有稳定的 dev/hot-update 链路,默认只保留静态产物 e2e。
3741
export const HOT_UPDATE_EXEMPT_PROJECTS = new Set<string>()
38-
HOT_UPDATE_EXEMPT_PROJECTS.add('taro-webpack-vue3-tailwindcss-v3')
39-
HOT_UPDATE_EXEMPT_PROJECTS.add('taro-webpack-vue3-tailwindcss-v4')
40-
HOT_UPDATE_EXEMPT_PROJECTS.add('taro-vite-vue3-tailwindcss-v3')
41-
HOT_UPDATE_EXEMPT_PROJECTS.add('taro-vite-vue3-tailwindcss-v4')
4242

4343
export function getAllStaticE2EProjectNames() {
4444
return [...E2E_PROJECTS, ...NATIVE_PROJECTS].map(item => item.name)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, it } from 'vitest'
2+
import { resolveCaseName, runHotUpdateTarget, shouldRunTarget } from '../shared'
3+
4+
describe('e2e watch hot-update taro-vite-vue3-tailwindcss-v3', () => {
5+
const caseName = resolveCaseName()
6+
const target = 'taro-vite-vue3-tailwindcss-v3' as const
7+
8+
if (!shouldRunTarget(caseName, target)) {
9+
it.skip('skips taro-vite-vue3-tailwindcss-v3 watch hot-update for current E2E_WATCH_CASE filter', () => {})
10+
return
11+
}
12+
13+
it('should verify template/script/style/subpackage hot updates and project report for taro-vite-vue3-tailwindcss-v3', async () => {
14+
await runHotUpdateTarget(target)
15+
})
16+
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, it } from 'vitest'
2+
import { resolveCaseName, runHotUpdateTarget, shouldRunTarget } from '../shared'
3+
4+
describe('e2e watch hot-update taro-vite-vue3-tailwindcss-v4', () => {
5+
const caseName = resolveCaseName()
6+
const target = 'taro-vite-vue3-tailwindcss-v4' as const
7+
8+
if (!shouldRunTarget(caseName, target)) {
9+
it.skip('skips taro-vite-vue3-tailwindcss-v4 watch hot-update for current E2E_WATCH_CASE filter', () => {})
10+
return
11+
}
12+
13+
it('should verify template/script/style/subpackage hot updates and project report for taro-vite-vue3-tailwindcss-v4', async () => {
14+
await runHotUpdateTarget(target)
15+
})
16+
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, it } from 'vitest'
2+
import { resolveCaseName, runHotUpdateTarget, shouldRunTarget } from '../shared'
3+
4+
describe('e2e watch hot-update taro-webpack-vue3-tailwindcss-v3', () => {
5+
const caseName = resolveCaseName()
6+
const target = 'taro-webpack-vue3-tailwindcss-v3' as const
7+
8+
if (!shouldRunTarget(caseName, target)) {
9+
it.skip('skips taro-webpack-vue3-tailwindcss-v3 watch hot-update for current E2E_WATCH_CASE filter', () => {})
10+
return
11+
}
12+
13+
it('should verify template/script/style/subpackage hot updates and project report for taro-webpack-vue3-tailwindcss-v3', async () => {
14+
await runHotUpdateTarget(target)
15+
})
16+
})
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, it } from 'vitest'
2+
import { resolveCaseName, runHotUpdateTarget, shouldRunTarget } from '../shared'
3+
4+
describe('e2e watch hot-update taro-webpack-vue3-tailwindcss-v4', () => {
5+
const caseName = resolveCaseName()
6+
const target = 'taro-webpack-vue3-tailwindcss-v4' as const
7+
8+
if (!shouldRunTarget(caseName, target)) {
9+
it.skip('skips taro-webpack-vue3-tailwindcss-v4 watch hot-update for current E2E_WATCH_CASE filter', () => {})
10+
return
11+
}
12+
13+
it('should verify template/script/style/subpackage hot updates and project report for taro-webpack-vue3-tailwindcss-v4', async () => {
14+
await runHotUpdateTarget(target)
15+
})
16+
})

e2e/watch/hot-update/shared.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export type ConcreteWatchCaseName
1414
| 'taro-webpack-react-tailwindcss-v4'
1515
| 'taro-vite-react-tailwindcss-v3'
1616
| 'taro-vite-react-tailwindcss-v4'
17+
| 'taro-webpack-vue3-tailwindcss-v3'
18+
| 'taro-webpack-vue3-tailwindcss-v4'
19+
| 'taro-vite-vue3-tailwindcss-v3'
20+
| 'taro-vite-vue3-tailwindcss-v4'
1721
| 'uni-app-vite-tailwindcss-v3'
1822
| 'uni-app-vite-tailwindcss-v4'
1923
| 'weapp-vite-tailwindcss-v3'
@@ -156,6 +160,16 @@ interface StyleMutationMetric {
156160

157161
type HotUpdateMutationMetric = TemplateOrScriptMutationMetric | StyleMutationMetric
158162

163+
interface SubPackageMutationMetric {
164+
root: 'sub-normal' | 'sub-independent'
165+
independent: boolean
166+
outputWxml: string
167+
outputJs: string
168+
globalStyleOutputs: string[]
169+
template: TemplateOrScriptMutationMetric
170+
style: StyleMutationMetric
171+
}
172+
159173
interface HotUpdateCaseReport {
160174
name: ConcreteWatchCaseName
161175
label: string
@@ -172,6 +186,7 @@ interface HotUpdateCaseReport {
172186
globalStyleOutput?: string
173187
globalStyleOutputs?: string[]
174188
mutationMetrics: HotUpdateMutationMetric[]
189+
subPackageMutationMetrics?: SubPackageMutationMetric[]
175190
summaryByMutationKind: Partial<Record<MutationKind, HotUpdateSummary>>
176191
initialReadyMs: number
177192
hotUpdateOutputMs: number
@@ -197,8 +212,12 @@ const criticalDemoProjects = [
197212
'demo/mpx-tailwindcss-v4',
198213
'demo/taro-webpack-react-tailwindcss-v3',
199214
'demo/taro-webpack-react-tailwindcss-v4',
215+
'demo/taro-webpack-vue3-tailwindcss-v3',
216+
'demo/taro-webpack-vue3-tailwindcss-v4',
200217
'demo/taro-vite-react-tailwindcss-v3',
201218
'demo/taro-vite-react-tailwindcss-v4',
219+
'demo/taro-vite-vue3-tailwindcss-v3',
220+
'demo/taro-vite-vue3-tailwindcss-v4',
202221
'demo/uni-app-vite-tailwindcss-v3',
203222
'demo/uni-app-vite-tailwindcss-v4',
204223
'demo/weapp-vite-tailwindcss-v3',
@@ -298,6 +317,10 @@ export function resolveCaseName() {
298317
|| value === 'taro-webpack-react-tailwindcss-v4'
299318
|| value === 'taro-vite-react-tailwindcss-v3'
300319
|| value === 'taro-vite-react-tailwindcss-v4'
320+
|| value === 'taro-webpack-vue3-tailwindcss-v3'
321+
|| value === 'taro-webpack-vue3-tailwindcss-v4'
322+
|| value === 'taro-vite-vue3-tailwindcss-v3'
323+
|| value === 'taro-vite-vue3-tailwindcss-v4'
301324
|| value === 'uni-app-vite-tailwindcss-v3'
302325
|| value === 'uni-app-vite-tailwindcss-v4'
303326
|| value === 'weapp-vite-tailwindcss-v4'
@@ -439,7 +462,11 @@ function assertHotUpdateReport(report: HotUpdateReport, target: WatchCaseName, m
439462
expect(item.escapedClasses.length).toBe(item.classTokens.length)
440463
expect(item.rounds.length).toBeGreaterThanOrEqual(requiredMutationRounds.length)
441464
const hasContentMutation = item.mutationMetrics.some(metric => metric.mutationKind === 'content')
465+
const subPackageMutationMetrics = item.subPackageMutationMetrics ?? []
442466
expect(item.mutationMetrics.length).toBe(hasContentMutation ? 4 : 3)
467+
expect(subPackageMutationMetrics.length).toBe(2)
468+
expect(subPackageMutationMetrics.map(metric => metric.root).sort()).toEqual(['sub-independent', 'sub-normal'])
469+
expect(subPackageMutationMetrics.some(metric => metric.independent)).toBe(true)
443470
expect(item.summaryByMutationKind.template?.count).toBe(1)
444471
expect(item.summaryByMutationKind.script?.count).toBe(1)
445472
expect(item.summaryByMutationKind.style?.count).toBe(1)
@@ -652,6 +679,31 @@ function assertHotUpdateReport(report: HotUpdateReport, target: WatchCaseName, m
652679
expect(styleMetric.rollbackEffectiveMs).toBeGreaterThan(0)
653680
expect(styleMetric.hotUpdateEffectiveMs).toBeLessThanOrEqual(maxHotUpdateMs)
654681
}
682+
683+
for (const subPackageMetric of subPackageMutationMetrics) {
684+
expect(subPackageMetric.outputWxml).toContain(subPackageMetric.root)
685+
expect(subPackageMetric.outputJs).toContain(subPackageMetric.root)
686+
expect(subPackageMetric.globalStyleOutputs.length).toBeGreaterThan(0)
687+
expect(subPackageMetric.template.sourceFile).toContain(subPackageMetric.root)
688+
expect(subPackageMetric.template.marker).toContain('tw-watch-subpackage-')
689+
expect(subPackageMetric.template.rounds.length).toBeGreaterThanOrEqual(requiredMutationRounds.length)
690+
expect(subPackageMetric.template.verifyEscapedIn.length + subPackageMetric.template.verifyClassLiteralIn.length).toBeGreaterThan(0)
691+
expect(subPackageMetric.template.verifiedGlobalStyleEscapedClasses.length).toBeGreaterThanOrEqual(
692+
subPackageMetric.template.minRequiredGlobalStyleEscapedClasses,
693+
)
694+
expect(subPackageMetric.template.hotUpdateEffectiveMs).toBeGreaterThan(0)
695+
expect(subPackageMetric.template.hotUpdateEffectiveMs).toBeLessThanOrEqual(maxHotUpdateMs)
696+
expect(subPackageMetric.template.rollbackEffectiveMs).toBeGreaterThan(0)
697+
expect(subPackageMetric.style.sourceFile).toContain(subPackageMetric.root)
698+
expect(subPackageMetric.style.outputStyle).toContain('.wxss')
699+
expect(subPackageMetric.style.styleNeedle).toContain('.tw-watch-style-')
700+
expect(subPackageMetric.style.hotUpdateEffectiveMs).toBeGreaterThan(0)
701+
expect(subPackageMetric.style.hotUpdateEffectiveMs).toBeLessThanOrEqual(maxHotUpdateMs)
702+
expect(subPackageMetric.style.rollbackEffectiveMs).toBeGreaterThan(0)
703+
if (subPackageMetric.independent) {
704+
expect(subPackageMetric.root).toBe('sub-independent')
705+
}
706+
}
655707
}
656708

657709
const commentCarrierSummary: CommentCarrierSummaryItem[] = report.cases

packages/weapp-tailwindcss/test/ci/workflows.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ describe('e2e watch workflow', () => {
191191
'macos:22:uni-app-vite-tailwindcss-v3:issue33',
192192
'macos:22:weapp-vite-tailwindcss-v3:issue33',
193193
'macos:22:taro-webpack-react-tailwindcss-v4:issue33',
194+
'macos:22:taro-vite-vue3-tailwindcss-v4:default',
195+
'macos:22:taro-webpack-vue3-tailwindcss-v4:default',
194196
'macos:22:uni-app-vite-tailwindcss-v4:default',
195197
'macos:22:mpx-tailwindcss-v4:default',
196198
'macos:22:weapp-vite-tailwindcss-v4:issue33',
@@ -201,6 +203,7 @@ describe('e2e watch workflow', () => {
201203
'windows:22:uni-app-vite-tailwindcss-v3:issue33',
202204
'windows:22:weapp-vite-tailwindcss-v3:issue33',
203205
'windows:22:taro-webpack-react-tailwindcss-v4:issue33',
206+
'windows:22:taro-vite-vue3-tailwindcss-v4:default',
204207
'windows:22:mpx-tailwindcss-v4:default',
205208
'windows:22:weapp-vite-tailwindcss-v4:issue33',
206209
'windows:22:weapp-vite-tailwindcss-v3:issue33',

packages/weapp-tailwindcss/test/watch-hmr-coverage-matrix.unit.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ const matrixProjects = [
1919
'demo/mpx-tailwindcss-v4',
2020
'demo/taro-webpack-react-tailwindcss-v3',
2121
'demo/taro-webpack-react-tailwindcss-v4',
22+
'demo/taro-webpack-vue3-tailwindcss-v3',
23+
'demo/taro-webpack-vue3-tailwindcss-v4',
2224
'demo/taro-vite-react-tailwindcss-v3',
2325
'demo/taro-vite-react-tailwindcss-v4',
26+
'demo/taro-vite-vue3-tailwindcss-v3',
27+
'demo/taro-vite-vue3-tailwindcss-v4',
2428
'demo/uni-app-vite-tailwindcss-v3',
2529
'demo/uni-app-vite-tailwindcss-v4',
2630
'demo/weapp-vite-tailwindcss-v3',
@@ -44,8 +48,17 @@ describe('watch-hmr coverage matrix', () => {
4448
expect(watchCase.templateMutation, `${watchCase.project} should cover template class HMR`).toBeDefined()
4549
expect(watchCase.scriptMutation, `${watchCase.project} should cover script class HMR`).toBeDefined()
4650
expect(watchCase.styleMutation, `${watchCase.project} should cover style @apply HMR`).toBeDefined()
51+
expect(watchCase.subPackageMutations?.map(item => item.root).sort(), `${watchCase.project} should cover normal and independent subpackage HMR`).toEqual(['sub-independent', 'sub-normal'])
4752
expect(watchCase.templateMutation.verifyEscapedIn.length + (watchCase.templateMutation.verifyClassLiteralIn?.length ?? 0)).toBeGreaterThan(0)
4853
expect(watchCase.scriptMutation.verifyEscapedIn.length + (watchCase.scriptMutation.verifyClassLiteralIn?.length ?? 0)).toBeGreaterThan(0)
54+
for (const subPackageMutation of watchCase.subPackageMutations ?? []) {
55+
expect(subPackageMutation.outputWxml).toContain(subPackageMutation.root)
56+
expect(subPackageMutation.outputJs).toContain(subPackageMutation.root)
57+
expect(subPackageMutation.templateMutation.sourceFile).toContain(subPackageMutation.root)
58+
expect(subPackageMutation.styleMutation.sourceFile).toContain(subPackageMutation.root)
59+
expect(subPackageMutation.templateMutation.roundConfigs?.length).toBeGreaterThanOrEqual(3)
60+
expect(subPackageMutation.templateMutation.verifyEscapedIn.length + (subPackageMutation.templateMutation.verifyClassLiteralIn?.length ?? 0)).toBeGreaterThan(0)
61+
}
4962
if (watchCase.contentMutation) {
5063
expect(watchCase.contentMutation.verifyClassLiteralIn).toContain('js')
5164
}

packages/weapp-tailwindcss/test/watch-hmr-regression.unit.test.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ function createCase(
176176
createClassMutationMetrics('content', [complexRound]),
177177
createStyleMutationMetrics(),
178178
],
179+
subPackageMutationMetrics: [],
179180
summaryByMutationKind: {},
180181
initialReadyMs: 25,
181182
hotUpdateOutputMs: hotUpdateEffectiveMs + 10,
@@ -813,6 +814,57 @@ describe('watch-hmr regression cases', () => {
813814
}
814815
})
815816

817+
it('registers watch hot-update cases for every demo project including Vue3 variants', () => {
818+
const cases = [
819+
...buildDemoBaseCases('/repo'),
820+
...buildDemoExtendedCases('/repo'),
821+
]
822+
823+
expect(cases.map(watchCase => watchCase.name)).toEqual([
824+
'gulp-tailwindcss-v3',
825+
'gulp-tailwindcss-v4',
826+
'taro-webpack-react-tailwindcss-v3',
827+
'taro-webpack-vue3-tailwindcss-v3',
828+
'mpx-tailwindcss-v3',
829+
'weapp-vite-tailwindcss-v3',
830+
'weapp-vite-tailwindcss-v4',
831+
'uni-app-vite-tailwindcss-v3',
832+
'uni-app-vite-tailwindcss-v4',
833+
'mpx-tailwindcss-v4',
834+
'taro-vite-react-tailwindcss-v4',
835+
'taro-vite-react-tailwindcss-v3',
836+
'taro-webpack-react-tailwindcss-v4',
837+
'taro-vite-vue3-tailwindcss-v3',
838+
'taro-vite-vue3-tailwindcss-v4',
839+
'taro-webpack-vue3-tailwindcss-v4',
840+
])
841+
})
842+
843+
it('covers normal and independent subpackage hot updates for every demo watch case', () => {
844+
const cases = [
845+
...buildDemoBaseCases('/repo'),
846+
...buildDemoExtendedCases('/repo'),
847+
]
848+
849+
for (const watchCase of cases) {
850+
expect(watchCase.subPackageMutations?.map(item => item.root).sort(), watchCase.name).toEqual(['sub-independent', 'sub-normal'])
851+
for (const subPackageMutation of watchCase.subPackageMutations ?? []) {
852+
expect(subPackageMutation.templateMutation.sourceFile, watchCase.name).toContain(subPackageMutation.root)
853+
expect(subPackageMutation.styleMutation.sourceFile, watchCase.name).toContain(subPackageMutation.root)
854+
expect(subPackageMutation.outputWxml, watchCase.name).toContain(subPackageMutation.root)
855+
expect(subPackageMutation.outputJs, watchCase.name).toContain(subPackageMutation.root)
856+
expect(subPackageMutation.globalStyleCandidates.length, watchCase.name).toBeGreaterThan(0)
857+
expect(subPackageMutation.templateMutation.roundConfigs?.map(item => item.name), watchCase.name).toEqual([
858+
'baseline-arbitrary',
859+
'complex-corpus',
860+
'hex-arbitrary',
861+
])
862+
}
863+
expect(watchCase.subPackageMutations?.find(item => item.root === 'sub-independent')?.independent, watchCase.name).toBe(true)
864+
expect(watchCase.subPackageMutations?.find(item => item.root === 'sub-normal')?.independent, watchCase.name).toBe(false)
865+
}
866+
})
867+
816868
it('keeps script read-path HMR checks available for every demo case', () => {
817869
const cases = [
818870
...buildDemoBaseCases('/repo'),
@@ -886,7 +938,7 @@ describe('watch-hmr regression cases', () => {
886938
expect(win32DemoCases.find(watchCase => watchCase.name === 'uni-app-vite-tailwindcss-v3')).toBeDefined()
887939
})
888940

889-
it('keeps issue33 watch cases in macOS and Windows CI matrices', async () => {
941+
it('keeps issue33 and Vue3 watch cases in macOS and Windows CI matrices', async () => {
890942
const workflowSource = await readFile(
891943
path.resolve(__dirname, '../../../.github/workflows/e2e-watch.yml'),
892944
'utf8',
@@ -909,8 +961,11 @@ describe('watch-hmr regression cases', () => {
909961
const requiredMatrixEntries = [
910962
{ os: 'macos-latest', runner_label: 'macos', watch_case: 'uni-app-vite-tailwindcss-v3', round_profile: 'issue33' },
911963
{ os: 'macos-latest', runner_label: 'macos', watch_case: 'weapp-vite-tailwindcss-v3', round_profile: 'issue33' },
964+
{ os: 'macos-latest', runner_label: 'macos', watch_case: 'taro-vite-vue3-tailwindcss-v4', round_profile: 'default' },
965+
{ os: 'macos-latest', runner_label: 'macos', watch_case: 'taro-webpack-vue3-tailwindcss-v4', round_profile: 'default' },
912966
{ os: 'windows-latest', runner_label: 'windows', watch_case: 'uni-app-vite-tailwindcss-v3', round_profile: 'issue33' },
913967
{ os: 'windows-latest', runner_label: 'windows', watch_case: 'weapp-vite-tailwindcss-v3', round_profile: 'issue33' },
968+
{ os: 'windows-latest', runner_label: 'windows', watch_case: 'taro-vite-vue3-tailwindcss-v4', round_profile: 'default' },
914969
]
915970

916971
for (const entry of requiredMatrixEntries) {

0 commit comments

Comments
 (0)