From 11fe360e7b02c17c3c25456c54c1639e78000aab Mon Sep 17 00:00:00 2001 From: Thomas Kelly Date: Mon, 16 Jun 2025 14:44:32 -0400 Subject: [PATCH 1/2] chore: Add block fixture + assertions for dev command test --- package-lock.json | 4 ++-- test/commands/theme/component/dev.test.ts | 2 ++ .../components/with-setup/setup/blocks/_with-setup.liquid | 0 .../components/with-setup/setup/blocks/with-setup.liquid | 0 4 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/collection/components/with-setup/setup/blocks/_with-setup.liquid create mode 100644 test/fixtures/collection/components/with-setup/setup/blocks/with-setup.liquid diff --git a/package-lock.json b/package-lock.json index 053c568..cebce07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "plugin-devkit", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "plugin-devkit", - "version": "1.0.3", + "version": "1.0.4", "license": "MIT", "dependencies": { "@oclif/core": "^4", diff --git a/test/commands/theme/component/dev.test.ts b/test/commands/theme/component/dev.test.ts index da6fa5b..82cf391 100644 --- a/test/commands/theme/component/dev.test.ts +++ b/test/commands/theme/component/dev.test.ts @@ -37,6 +37,8 @@ describe('theme component dev', () => { await runCommand(['theme', 'component', 'dev', '-t', testThemePath]) expect(fs.existsSync(path.join(testCollectionPath, '.dev', 'sections', 'with-setup.liquid'))).to.be.true expect(fs.existsSync(path.join(testCollectionPath, '.dev', 'templates', 'index.with-setup.liquid'))).to.be.true + expect(fs.existsSync(path.join(testCollectionPath, '.dev', 'blocks', 'with-setup.liquid'))).to.be.true + expect(fs.existsSync(path.join(testCollectionPath, '.dev', 'blocks', '_with-setup.liquid'))).to.be.true }) it('merges the settings_schema.json setup files', async () => { diff --git a/test/fixtures/collection/components/with-setup/setup/blocks/_with-setup.liquid b/test/fixtures/collection/components/with-setup/setup/blocks/_with-setup.liquid new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/collection/components/with-setup/setup/blocks/with-setup.liquid b/test/fixtures/collection/components/with-setup/setup/blocks/with-setup.liquid new file mode 100644 index 0000000..e69de29 From 0f561e4865ea4ad972c4eef15d3d3ff6ddbd940a Mon Sep 17 00:00:00 2001 From: Thomas Kelly Date: Mon, 16 Jun 2025 14:57:16 -0400 Subject: [PATCH 2/2] Add block test to map command --- test/commands/theme/component/map.test.ts | 12 ++++++++++++ .../section-with-block-snippet.liquid | 0 .../snippets/section-with-block-snippet.block.liquid | 0 .../blocks/section-with-block-snippet.block.liquid | 1 + .../theme/sections/section-with-block-snippet.liquid | 1 + 5 files changed, 14 insertions(+) create mode 100644 test/fixtures/collection/components/section-with-block-snippet/section-with-block-snippet.liquid create mode 100644 test/fixtures/collection/components/section-with-block-snippet/snippets/section-with-block-snippet.block.liquid create mode 100644 test/fixtures/theme/blocks/section-with-block-snippet.block.liquid create mode 100644 test/fixtures/theme/sections/section-with-block-snippet.liquid diff --git a/test/commands/theme/component/map.test.ts b/test/commands/theme/component/map.test.ts index 7b3c040..6d34946 100644 --- a/test/commands/theme/component/map.test.ts +++ b/test/commands/theme/component/map.test.ts @@ -96,6 +96,18 @@ describe('theme component map', () => { expect(data.files.snippets['child.liquid']).to.equal('@archetype-themes/test-collection') }) + it('adds entries for blocks', async () => { + const beforeData = JSON.parse(fs.readFileSync(path.join(testThemePath, 'component.manifest.json'), 'utf8')) + expect(beforeData.files.snippets['section-with-block-snippet.liquid']).to.be.undefined + expect(beforeData.files.snippets['section-with-block-snippet.block.liquid']).to.be.undefined + + await runCommand(['theme', 'component', 'map', testThemePath]) + + const data = JSON.parse(fs.readFileSync(path.join(testThemePath, 'component.manifest.json'), 'utf8')) + expect(data.files.snippets['section-with-block-snippet.liquid']).to.equal('@archetype-themes/test-collection') + expect(data.files.snippets['section-with-block-snippet.block.liquid']).to.equal('@archetype-themes/test-collection') + }) + it('throws a warning if there is a potential conflict with an entry in the current collection', async () => { const {stdout} = await runCommand(['theme', 'component', 'map', testThemePath]) const data = JSON.parse(fs.readFileSync(path.join(testThemePath, 'component.manifest.json'), 'utf8')) diff --git a/test/fixtures/collection/components/section-with-block-snippet/section-with-block-snippet.liquid b/test/fixtures/collection/components/section-with-block-snippet/section-with-block-snippet.liquid new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/collection/components/section-with-block-snippet/snippets/section-with-block-snippet.block.liquid b/test/fixtures/collection/components/section-with-block-snippet/snippets/section-with-block-snippet.block.liquid new file mode 100644 index 0000000..e69de29 diff --git a/test/fixtures/theme/blocks/section-with-block-snippet.block.liquid b/test/fixtures/theme/blocks/section-with-block-snippet.block.liquid new file mode 100644 index 0000000..cb55000 --- /dev/null +++ b/test/fixtures/theme/blocks/section-with-block-snippet.block.liquid @@ -0,0 +1 @@ +{% render 'section-with-block-snippet.block' %} \ No newline at end of file diff --git a/test/fixtures/theme/sections/section-with-block-snippet.liquid b/test/fixtures/theme/sections/section-with-block-snippet.liquid new file mode 100644 index 0000000..49a4a77 --- /dev/null +++ b/test/fixtures/theme/sections/section-with-block-snippet.liquid @@ -0,0 +1 @@ +{% render 'section-with-block-snippet' %} \ No newline at end of file