Skip to content

Commit 2acfce3

Browse files
committed
Fix include-assets-step tests after copy-by-pattern pre-glob check
The new fileExists short-circuit in copyByPattern broke the auto-mocked pattern tests at the step level (fileExists returns undefined → early return). Add a beforeEach default for the pattern-entries block, and switch the pattern-only manifest test from a flat false to an implementation that returns true for the sourceDir path.
1 parent 6e2ab4c commit 2acfce3

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/app/src/cli/services/build/steps/include-assets-step.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,11 @@ describe('executeIncludeAssetsStep', () => {
552552
})
553553

554554
describe('pattern entries', () => {
555+
beforeEach(() => {
556+
// copyByPattern now short-circuits if sourceDir doesn't exist; default true here.
557+
vi.mocked(fs.fileExists).mockResolvedValue(true)
558+
})
559+
555560
test('copies files matching include patterns', async () => {
556561
// Given
557562
vi.mocked(fs.glob).mockResolvedValue(['/test/extension/public/logo.png', '/test/extension/public/style.css'])
@@ -943,11 +948,13 @@ describe('executeIncludeAssetsStep', () => {
943948
})
944949

945950
test('writes manifest.json with files array when generatesAssetsManifest is true and only pattern inclusions exist', async () => {
946-
// Given — pattern entries contribute output paths to the manifest "files" array
951+
// Given — pattern entries contribute output paths to the manifest "files" array.
952+
// sourceDir must exist for copyByPattern's pre-glob fileExists check to pass;
953+
// everything else can read false (the parent beforeEach default).
947954
vi.mocked(fs.glob).mockResolvedValue(['/test/extension/public/logo.png'])
948955
vi.mocked(fs.copyFile).mockResolvedValue()
949956
vi.mocked(fs.mkdir).mockResolvedValue()
950-
vi.mocked(fs.fileExists).mockResolvedValue(false)
957+
vi.mocked(fs.fileExists).mockImplementation(async (path) => String(path) === '/test/extension/public')
951958
vi.mocked(fs.writeFile).mockResolvedValue()
952959

953960
const step: LifecycleStep = {

0 commit comments

Comments
 (0)