nebula-cms 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/astro/index.d.ts +43 -0
- package/dist/astro/index.d.ts.map +1 -0
- package/dist/astro/index.js +223 -0
- package/{src → dist}/client/Admin.svelte +20 -11
- package/dist/client/Admin.svelte.d.ts +11 -0
- package/dist/client/Admin.svelte.d.ts.map +1 -0
- package/dist/client/components/BackendPicker.svelte.d.ts +4 -0
- package/dist/client/components/BackendPicker.svelte.d.ts.map +1 -0
- package/dist/client/components/DraftChip.svelte.d.ts +10 -0
- package/dist/client/components/DraftChip.svelte.d.ts.map +1 -0
- package/dist/client/components/MetadataForm.svelte.d.ts +12 -0
- package/dist/client/components/MetadataForm.svelte.d.ts.map +1 -0
- package/dist/client/components/ThemeToggle.svelte.d.ts +19 -0
- package/dist/client/components/ThemeToggle.svelte.d.ts.map +1 -0
- package/dist/client/components/dialogs/DeleteDraftDialog.svelte.d.ts +11 -0
- package/dist/client/components/dialogs/DeleteDraftDialog.svelte.d.ts.map +1 -0
- package/{src → dist}/client/components/dialogs/FilenameDialog.svelte +1 -2
- package/dist/client/components/dialogs/FilenameDialog.svelte.d.ts +13 -0
- package/dist/client/components/dialogs/FilenameDialog.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/EditorPane.svelte.d.ts +4 -0
- package/dist/client/components/editor/EditorPane.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/EditorTabs.svelte.d.ts +8 -0
- package/dist/client/components/editor/EditorTabs.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/EditorToolbar.svelte.d.ts +4 -0
- package/dist/client/components/editor/EditorToolbar.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/FormatSelector.svelte.d.ts +4 -0
- package/dist/client/components/editor/FormatSelector.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/Toolbar.svelte.d.ts +19 -0
- package/dist/client/components/editor/Toolbar.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/ArrayField.svelte.d.ts +15 -0
- package/dist/client/components/fields/ArrayField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/ArrayItem.svelte.d.ts +28 -0
- package/dist/client/components/fields/ArrayItem.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/BooleanField.svelte.d.ts +16 -0
- package/dist/client/components/fields/BooleanField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/DateField.svelte.d.ts +16 -0
- package/dist/client/components/fields/DateField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/EnumField.svelte.d.ts +17 -0
- package/dist/client/components/fields/EnumField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/FieldWrapper.svelte.d.ts +18 -0
- package/dist/client/components/fields/FieldWrapper.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/NumberField.svelte.d.ts +16 -0
- package/dist/client/components/fields/NumberField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/ObjectField.svelte.d.ts +16 -0
- package/dist/client/components/fields/ObjectField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/SchemaField.svelte.d.ts +16 -0
- package/dist/client/components/fields/SchemaField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/StringField.svelte.d.ts +16 -0
- package/dist/client/components/fields/StringField.svelte.d.ts.map +1 -0
- package/{src → dist}/client/components/sidebar/AdminSidebar.svelte +2 -4
- package/dist/client/components/sidebar/AdminSidebar.svelte.d.ts +19 -0
- package/dist/client/components/sidebar/AdminSidebar.svelte.d.ts.map +1 -0
- package/dist/client/components/sidebar/AdminSidebarSort.svelte.d.ts +12 -0
- package/dist/client/components/sidebar/AdminSidebarSort.svelte.d.ts.map +1 -0
- package/dist/client/css/icons.css +29 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/js/drafts/merge.svelte.d.ts +24 -0
- package/dist/client/js/drafts/merge.svelte.d.ts.map +1 -0
- package/dist/client/js/drafts/merge.svelte.js +106 -0
- package/dist/client/js/drafts/ops.svelte.d.ts +31 -0
- package/dist/client/js/drafts/ops.svelte.d.ts.map +1 -0
- package/dist/client/js/drafts/ops.svelte.js +182 -0
- package/dist/client/js/drafts/storage.d.ts +45 -0
- package/dist/client/js/drafts/storage.d.ts.map +1 -0
- package/dist/client/js/drafts/storage.js +76 -0
- package/dist/client/js/drafts/workers/diff.d.ts +2 -0
- package/dist/client/js/drafts/workers/diff.d.ts.map +1 -0
- package/dist/client/js/drafts/workers/diff.js +20 -0
- package/dist/client/js/editor/editor.svelte.d.ts +124 -0
- package/dist/client/js/editor/editor.svelte.d.ts.map +1 -0
- package/dist/client/js/editor/editor.svelte.js +294 -0
- package/dist/client/js/editor/languages.d.ts +11 -0
- package/dist/client/js/editor/languages.d.ts.map +1 -0
- package/dist/client/js/editor/languages.js +93 -0
- package/dist/client/js/editor/link-wrap.d.ts +6 -0
- package/dist/client/js/editor/link-wrap.d.ts.map +1 -0
- package/{src/client/js/editor/link-wrap.ts → dist/client/js/editor/link-wrap.js} +17 -24
- package/dist/client/js/editor/markdown-shortcuts.d.ts +4 -0
- package/dist/client/js/editor/markdown-shortcuts.d.ts.map +1 -0
- package/dist/client/js/editor/markdown-shortcuts.js +219 -0
- package/dist/client/js/handlers/admin.d.ts +64 -0
- package/dist/client/js/handlers/admin.d.ts.map +1 -0
- package/dist/client/js/handlers/admin.js +186 -0
- package/dist/client/js/state/dialogs.svelte.d.ts +16 -0
- package/dist/client/js/state/dialogs.svelte.d.ts.map +1 -0
- package/dist/client/js/state/dialogs.svelte.js +28 -0
- package/dist/client/js/state/router.svelte.d.ts +44 -0
- package/dist/client/js/state/router.svelte.d.ts.map +1 -0
- package/dist/client/js/state/router.svelte.js +141 -0
- package/dist/client/js/state/schema.svelte.d.ts +51 -0
- package/dist/client/js/state/schema.svelte.d.ts.map +1 -0
- package/{src/client/js/state/schema.svelte.ts → dist/client/js/state/schema.svelte.js} +55 -70
- package/dist/client/js/state/state.svelte.d.ts +68 -0
- package/dist/client/js/state/state.svelte.d.ts.map +1 -0
- package/dist/client/js/state/state.svelte.js +300 -0
- package/dist/client/js/state/theme.svelte.d.ts +24 -0
- package/dist/client/js/state/theme.svelte.d.ts.map +1 -0
- package/{src/client/js/state/theme.svelte.ts → dist/client/js/state/theme.svelte.js} +54 -91
- package/dist/client/js/storage/adapter.d.ts +130 -0
- package/dist/client/js/storage/adapter.d.ts.map +1 -0
- package/dist/client/js/storage/adapter.js +5 -0
- package/dist/client/js/storage/client.d.ts +72 -0
- package/dist/client/js/storage/client.d.ts.map +1 -0
- package/dist/client/js/storage/client.js +121 -0
- package/dist/client/js/storage/db.d.ts +8 -0
- package/dist/client/js/storage/db.d.ts.map +1 -0
- package/dist/client/js/storage/db.js +35 -0
- package/dist/client/js/storage/fsa.d.ts +51 -0
- package/dist/client/js/storage/fsa.d.ts.map +1 -0
- package/dist/client/js/storage/fsa.js +91 -0
- package/dist/client/js/storage/github.d.ts +62 -0
- package/dist/client/js/storage/github.d.ts.map +1 -0
- package/dist/client/js/storage/github.js +216 -0
- package/dist/client/js/storage/storage.d.ts +32 -0
- package/dist/client/js/storage/storage.d.ts.map +1 -0
- package/dist/client/js/storage/storage.js +68 -0
- package/dist/client/js/storage/workers/frontmatter.d.ts +2 -0
- package/dist/client/js/storage/workers/frontmatter.d.ts.map +1 -0
- package/dist/client/js/storage/workers/frontmatter.js +253 -0
- package/dist/client/js/storage/workers/storage.d.ts +2 -0
- package/dist/client/js/storage/workers/storage.d.ts.map +1 -0
- package/dist/client/js/storage/workers/storage.js +167 -0
- package/dist/client/js/storage/workers/toml-parser.d.ts +2 -0
- package/dist/client/js/storage/workers/toml-parser.d.ts.map +1 -0
- package/dist/client/js/storage/workers/toml-parser.js +75 -0
- package/dist/client/js/storage/workers/yaml-parser.d.ts +2 -0
- package/dist/client/js/storage/workers/yaml-parser.d.ts.map +1 -0
- package/dist/client/js/storage/workers/yaml-parser.js +100 -0
- package/dist/client/js/utils/file-types.d.ts +58 -0
- package/dist/client/js/utils/file-types.d.ts.map +1 -0
- package/{src/client/js/utils/file-types.ts → dist/client/js/utils/file-types.js} +75 -107
- package/dist/client/js/utils/format.d.ts +8 -0
- package/dist/client/js/utils/format.d.ts.map +1 -0
- package/{src/client/js/utils/format.ts → dist/client/js/utils/format.js} +5 -6
- package/dist/client/js/utils/frontmatter.d.ts +12 -0
- package/dist/client/js/utils/frontmatter.d.ts.map +1 -0
- package/dist/client/js/utils/frontmatter.js +29 -0
- package/dist/client/js/utils/schema-utils.d.ts +110 -0
- package/dist/client/js/utils/schema-utils.d.ts.map +1 -0
- package/dist/client/js/utils/schema-utils.js +242 -0
- package/dist/client/js/utils/slug.d.ts +8 -0
- package/dist/client/js/utils/slug.d.ts.map +1 -0
- package/{src/client/js/utils/slug.ts → dist/client/js/utils/slug.js} +6 -7
- package/dist/client/js/utils/sort.d.ts +41 -0
- package/dist/client/js/utils/sort.d.ts.map +1 -0
- package/dist/client/js/utils/sort.js +65 -0
- package/dist/client/js/utils/stable-stringify.d.ts +8 -0
- package/dist/client/js/utils/stable-stringify.d.ts.map +1 -0
- package/dist/client/js/utils/stable-stringify.js +23 -0
- package/dist/client/js/utils/url-utils.d.ts +11 -0
- package/dist/client/js/utils/url-utils.d.ts.map +1 -0
- package/{src/client/js/utils/url-utils.ts → dist/client/js/utils/url-utils.js} +22 -23
- package/dist/client/types/browser-apis.d.ts +39 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +13 -3
- package/.github/workflows/ci.yml +0 -27
- package/.github/workflows/publish.yml +0 -34
- package/.mcp.json +0 -12
- package/.prettierignore +0 -5
- package/.prettierrc.cjs +0 -22
- package/AGENTS.md +0 -183
- package/playground/astro.config.mjs +0 -7
- package/playground/node_modules/.bin/astro +0 -21
- package/playground/node_modules/.vite/deps/@astrojs_svelte_client__js.js +0 -85
- package/playground/node_modules/.vite/deps/@astrojs_svelte_client__js.js.map +0 -7
- package/playground/node_modules/.vite/deps/_metadata.json +0 -184
- package/playground/node_modules/.vite/deps/astro___aria-query.js +0 -6776
- package/playground/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
- package/playground/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
- package/playground/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
- package/playground/node_modules/.vite/deps/astro___html-escaper.js +0 -34
- package/playground/node_modules/.vite/deps/astro___html-escaper.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-AJXJMYAF.js +0 -0
- package/playground/node_modules/.vite/deps/chunk-AJXJMYAF.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
- package/playground/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-CNYJBM5F.js +0 -21
- package/playground/node_modules/.vite/deps/chunk-CNYJBM5F.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-DBPNBGEI.js +0 -223
- package/playground/node_modules/.vite/deps/chunk-DBPNBGEI.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-FPEUJ7DG.js +0 -27
- package/playground/node_modules/.vite/deps/chunk-FPEUJ7DG.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-MHDZ3SK7.js +0 -1005
- package/playground/node_modules/.vite/deps/chunk-MHDZ3SK7.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-RBDTDTPY.js +0 -204
- package/playground/node_modules/.vite/deps/chunk-RBDTDTPY.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-RJGEXL5C.js +0 -688
- package/playground/node_modules/.vite/deps/chunk-RJGEXL5C.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-YL4MIWGJ.js +0 -5099
- package/playground/node_modules/.vite/deps/chunk-YL4MIWGJ.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-ZOV3DWEJ.js +0 -4376
- package/playground/node_modules/.vite/deps/chunk-ZOV3DWEJ.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-ZP4UNCSN.js +0 -23
- package/playground/node_modules/.vite/deps/chunk-ZP4UNCSN.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-ZREFNRZZ.js +0 -148
- package/playground/node_modules/.vite/deps/chunk-ZREFNRZZ.js.map +0 -7
- package/playground/node_modules/.vite/deps/package.json +0 -3
- package/playground/node_modules/.vite/deps/smol-toml.js +0 -843
- package/playground/node_modules/.vite/deps/smol-toml.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte.js +0 -55
- package/playground/node_modules/.vite/deps/svelte.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte___clsx.js +0 -9
- package/playground/node_modules/.vite/deps/svelte___clsx.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_animate.js +0 -57
- package/playground/node_modules/.vite/deps/svelte_animate.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_attachments.js +0 -15
- package/playground/node_modules/.vite/deps/svelte_attachments.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_easing.js +0 -67
- package/playground/node_modules/.vite/deps/svelte_easing.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_events.js +0 -11
- package/playground/node_modules/.vite/deps/svelte_events.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal.js +0 -5
- package/playground/node_modules/.vite/deps/svelte_internal.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_client.js +0 -402
- package/playground/node_modules/.vite/deps/svelte_internal_client.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_disclose-version.js +0 -10
- package/playground/node_modules/.vite/deps/svelte_internal_disclose-version.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_flags_async.js +0 -8
- package/playground/node_modules/.vite/deps/svelte_internal_flags_async.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_flags_legacy.js +0 -8
- package/playground/node_modules/.vite/deps/svelte_internal_flags_legacy.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_flags_tracing.js +0 -8
- package/playground/node_modules/.vite/deps/svelte_internal_flags_tracing.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_legacy.js +0 -35
- package/playground/node_modules/.vite/deps/svelte_legacy.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_motion.js +0 -545
- package/playground/node_modules/.vite/deps/svelte_motion.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_reactivity.js +0 -29
- package/playground/node_modules/.vite/deps/svelte_reactivity.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_reactivity_window.js +0 -127
- package/playground/node_modules/.vite/deps/svelte_reactivity_window.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_store.js +0 -103
- package/playground/node_modules/.vite/deps/svelte_store.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_transition.js +0 -208
- package/playground/node_modules/.vite/deps/svelte_transition.js.map +0 -7
- package/playground/package.json +0 -16
- package/playground/pnpm-lock.yaml +0 -3167
- package/playground/src/content/authors/jane-doe.json +0 -8
- package/playground/src/content/config/build.toml +0 -2
- package/playground/src/content/courses/web-fundamentals.json +0 -29
- package/playground/src/content/docs/advanced.mdx +0 -6
- package/playground/src/content/docs/intro.md +0 -6
- package/playground/src/content/guides/getting-started.mdx +0 -6
- package/playground/src/content/posts/hello-world.md +0 -7
- package/playground/src/content/products/t-shirt.json +0 -16
- package/playground/src/content/recipes/pancakes.mdoc +0 -8
- package/playground/src/content/settings/site.yml +0 -2
- package/playground/src/content.config.ts +0 -198
- package/playground/src/env.d.ts +0 -1
- package/playground/src/pages/index.astro +0 -11
- package/playground/src/pages/nebula.astro +0 -14
- package/pnpm-workspace.yaml +0 -2
- package/scripts/subset-icons.mjs +0 -178
- package/src/astro/index.ts +0 -295
- package/src/client/js/drafts/merge.svelte.ts +0 -121
- package/src/client/js/drafts/ops.svelte.ts +0 -227
- package/src/client/js/drafts/storage.ts +0 -108
- package/src/client/js/drafts/workers/diff.ts +0 -40
- package/src/client/js/editor/editor.svelte.ts +0 -343
- package/src/client/js/editor/languages.ts +0 -98
- package/src/client/js/editor/markdown-shortcuts.ts +0 -261
- package/src/client/js/handlers/admin.ts +0 -246
- package/src/client/js/state/dialogs.svelte.ts +0 -35
- package/src/client/js/state/router.svelte.ts +0 -156
- package/src/client/js/state/state.svelte.ts +0 -334
- package/src/client/js/storage/adapter.ts +0 -102
- package/src/client/js/storage/client.ts +0 -150
- package/src/client/js/storage/db.ts +0 -36
- package/src/client/js/storage/fsa.ts +0 -110
- package/src/client/js/storage/github.ts +0 -297
- package/src/client/js/storage/storage.ts +0 -83
- package/src/client/js/storage/workers/frontmatter.ts +0 -320
- package/src/client/js/storage/workers/storage.ts +0 -177
- package/src/client/js/storage/workers/toml-parser.ts +0 -106
- package/src/client/js/storage/workers/yaml-parser.ts +0 -132
- package/src/client/js/utils/frontmatter.ts +0 -38
- package/src/client/js/utils/schema-utils.ts +0 -295
- package/src/client/js/utils/sort.ts +0 -84
- package/src/client/js/utils/stable-stringify.ts +0 -27
- package/src/types.ts +0 -25
- package/svelte.config.js +0 -4
- package/tests/astro/build.test.ts +0 -63
- package/tests/astro/index.test.ts +0 -689
- package/tests/client/components/Admin.test.ts +0 -446
- package/tests/client/components/BackendPicker.test.ts +0 -239
- package/tests/client/components/DraftChip.test.ts +0 -53
- package/tests/client/components/MetadataForm.test.ts +0 -164
- package/tests/client/components/dialogs/DeleteDraftDialog.test.ts +0 -91
- package/tests/client/components/dialogs/FilenameDialog.test.ts +0 -209
- package/tests/client/components/dialogs/dialog-stubs.ts +0 -19
- package/tests/client/components/editor/EditorPane.test.ts +0 -100
- package/tests/client/components/editor/EditorTabs.test.ts +0 -253
- package/tests/client/components/editor/EditorToolbar.test.ts +0 -252
- package/tests/client/components/editor/fixtures.ts +0 -31
- package/tests/client/components/fields/ArrayField.test.ts +0 -197
- package/tests/client/components/fields/BooleanField.test.ts +0 -206
- package/tests/client/components/fields/DateField.test.ts +0 -210
- package/tests/client/components/fields/EnumField.test.ts +0 -246
- package/tests/client/components/fields/NumberField.test.ts +0 -240
- package/tests/client/components/fields/ObjectField.test.ts +0 -157
- package/tests/client/components/fields/SchemaField.test.ts +0 -190
- package/tests/client/components/fields/StringField.test.ts +0 -223
- package/tests/client/components/sidebar/AdminSidebar.test.ts +0 -285
- package/tests/client/components/sidebar/AdminSidebarSort.test.ts +0 -135
- package/tests/client/components/sidebar/sort-mock.ts +0 -23
- package/tests/client/js/drafts/fixtures.ts +0 -22
- package/tests/client/js/drafts/merge.test.ts +0 -282
- package/tests/client/js/drafts/ops.test.ts +0 -658
- package/tests/client/js/drafts/storage.test.ts +0 -200
- package/tests/client/js/drafts/workers/diff.test.ts +0 -165
- package/tests/client/js/editor/editor.test.ts +0 -616
- package/tests/client/js/editor/link-wrap.test.ts +0 -225
- package/tests/client/js/editor/markdown-shortcuts.test.ts +0 -370
- package/tests/client/js/handlers/admin.test.ts +0 -467
- package/tests/client/js/state/router.test.ts +0 -619
- package/tests/client/js/state/schema.test.ts +0 -266
- package/tests/client/js/state/state.test.ts +0 -328
- package/tests/client/js/storage/adapter.test.ts +0 -115
- package/tests/client/js/storage/client.test.ts +0 -250
- package/tests/client/js/storage/db.test.ts +0 -59
- package/tests/client/js/storage/fsa.test.ts +0 -284
- package/tests/client/js/storage/github.test.ts +0 -349
- package/tests/client/js/storage/mock-port.ts +0 -95
- package/tests/client/js/storage/storage.test.ts +0 -77
- package/tests/client/js/storage/workers/frontmatter.test.ts +0 -479
- package/tests/client/js/storage/workers/storage.test.ts +0 -299
- package/tests/client/js/storage/workers/toml-parser.test.ts +0 -169
- package/tests/client/js/storage/workers/yaml-parser.test.ts +0 -168
- package/tests/client/js/utils/file-types.test.ts +0 -268
- package/tests/client/js/utils/frontmatter.test.ts +0 -87
- package/tests/client/js/utils/schema-utils.test.ts +0 -318
- package/tests/client/js/utils/slug.test.ts +0 -58
- package/tests/client/js/utils/sort.test.ts +0 -276
- package/tests/client/js/utils/stable-stringify.test.ts +0 -68
- package/tests/client/js/utils/url-utils.test.ts +0 -70
- package/tests/e2e/backend-connection.test.ts +0 -301
- package/tests/e2e/draft-lifecycle.test.ts +0 -388
- package/tests/e2e/editing.test.ts +0 -355
- package/tests/e2e/github-adapter.test.ts +0 -330
- package/tests/e2e/helpers/mock-adapter.ts +0 -166
- package/tests/e2e/helpers/test-app.ts +0 -155
- package/tests/e2e/navigation.test.ts +0 -358
- package/tests/e2e/publishing.test.ts +0 -345
- package/tests/e2e/unsaved-changes.test.ts +0 -317
- package/tests/setup.ts +0 -2
- package/tests/stubs/codemirror.ts +0 -197
- package/tsconfig.json +0 -19
- package/vitest.config.ts +0 -178
- /package/{src → dist}/client/components/BackendPicker.svelte +0 -0
- /package/{src → dist}/client/components/DraftChip.svelte +0 -0
- /package/{src → dist}/client/components/MetadataForm.svelte +0 -0
- /package/{src → dist}/client/components/ThemeToggle.svelte +0 -0
- /package/{src → dist}/client/components/dialogs/DeleteDraftDialog.svelte +0 -0
- /package/{src → dist}/client/components/editor/EditorPane.svelte +0 -0
- /package/{src → dist}/client/components/editor/EditorTabs.svelte +0 -0
- /package/{src → dist}/client/components/editor/EditorToolbar.svelte +0 -0
- /package/{src → dist}/client/components/editor/FormatSelector.svelte +0 -0
- /package/{src → dist}/client/components/editor/Toolbar.svelte +0 -0
- /package/{src → dist}/client/components/fields/ArrayField.svelte +0 -0
- /package/{src → dist}/client/components/fields/ArrayItem.svelte +0 -0
- /package/{src → dist}/client/components/fields/BooleanField.svelte +0 -0
- /package/{src → dist}/client/components/fields/DateField.svelte +0 -0
- /package/{src → dist}/client/components/fields/EnumField.svelte +0 -0
- /package/{src → dist}/client/components/fields/FieldWrapper.svelte +0 -0
- /package/{src → dist}/client/components/fields/NumberField.svelte +0 -0
- /package/{src → dist}/client/components/fields/ObjectField.svelte +0 -0
- /package/{src → dist}/client/components/fields/SchemaField.svelte +0 -0
- /package/{src → dist}/client/components/fields/StringField.svelte +0 -0
- /package/{src → dist}/client/components/sidebar/AdminSidebarSort.svelte +0 -0
- /package/{src → dist}/client/css/a11y.css +0 -0
- /package/{src → dist}/client/css/btn.css +0 -0
- /package/{src → dist}/client/css/dialog.css +0 -0
- /package/{src → dist}/client/css/field-input.css +0 -0
- /package/{src → dist}/client/css/reset.css +0 -0
- /package/{src → dist}/client/css/theme.css +0 -0
- /package/{src/client/index.ts → dist/client/index.js} +0 -0
- /package/{src → dist}/virtual.d.ts +0 -0
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
-
import { render, cleanup, fireEvent } from '@testing-library/svelte';
|
|
3
|
-
import EditorTabs from '../../../../src/client/components/editor/EditorTabs.svelte';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Tests for the EditorTabs component.
|
|
7
|
-
* Mocks schema-utils and editor.svelte to control tab data without
|
|
8
|
-
* triggering Svelte 5 rune initialization in the jsdom environment.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// vi.hoisted ensures these declarations are available when vi.mock factories run,
|
|
12
|
-
// since vi.mock calls are hoisted to the top of the file by Vitest.
|
|
13
|
-
const { mockActiveTab, mockSetActiveTab, mockExtractTabs, mockEditorFile } =
|
|
14
|
-
vi.hoisted(() => ({
|
|
15
|
-
mockActiveTab: vi.fn(() => 'metadata'),
|
|
16
|
-
mockSetActiveTab: vi.fn(),
|
|
17
|
-
mockExtractTabs: vi.fn(() => [] as string[]),
|
|
18
|
-
mockEditorFile: vi.fn(() => null),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
vi.mock('../../../../src/client/js/utils/schema-utils', () => ({
|
|
22
|
-
extractTabs: mockExtractTabs,
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
vi.mock('../../../../src/client/js/editor/editor.svelte', () => ({
|
|
26
|
-
editor: {
|
|
27
|
-
get tab() {
|
|
28
|
-
return mockActiveTab();
|
|
29
|
-
},
|
|
30
|
-
get data() {
|
|
31
|
-
return {};
|
|
32
|
-
},
|
|
33
|
-
get originalFilename() {
|
|
34
|
-
return '';
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
setActiveTab: mockSetActiveTab,
|
|
38
|
-
getEditorFile: mockEditorFile,
|
|
39
|
-
}));
|
|
40
|
-
|
|
41
|
-
// Prevent accumulated renders from bleeding between tests
|
|
42
|
-
afterEach(() => cleanup());
|
|
43
|
-
|
|
44
|
-
describe('EditorTabs', () => {
|
|
45
|
-
/*
|
|
46
|
-
//////////////////////////////
|
|
47
|
-
// Default tabs
|
|
48
|
-
//////////////////////////////
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
it('always renders the Metadata and Body tabs', () => {
|
|
52
|
-
const { container } = render(EditorTabs, {
|
|
53
|
-
props: { schema: null },
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const buttons = Array.from(container.querySelectorAll('.tabs__tab'));
|
|
57
|
-
const labels = buttons.map((b) => b.textContent?.trim());
|
|
58
|
-
|
|
59
|
-
expect(labels).toContain('Metadata');
|
|
60
|
-
expect(labels).toContain('Body');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('renders Metadata before Body in tab order', () => {
|
|
64
|
-
const { container } = render(EditorTabs, {
|
|
65
|
-
props: { schema: null },
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const buttons = Array.from(container.querySelectorAll('.tabs__tab'));
|
|
69
|
-
const labels = buttons.map((b) => b.textContent?.trim());
|
|
70
|
-
|
|
71
|
-
expect(labels.indexOf('Metadata')).toBeLessThan(labels.indexOf('Body'));
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
/*
|
|
75
|
-
//////////////////////////////
|
|
76
|
-
// Schema-derived custom tabs
|
|
77
|
-
//////////////////////////////
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
it('renders custom tabs returned by extractTabs', () => {
|
|
81
|
-
mockExtractTabs.mockReturnValueOnce(['seo', 'social']);
|
|
82
|
-
|
|
83
|
-
const { container } = render(EditorTabs, {
|
|
84
|
-
props: {
|
|
85
|
-
schema: {
|
|
86
|
-
properties: {
|
|
87
|
-
seoTitle: { type: 'string', tab: ['seo'] },
|
|
88
|
-
ogImage: { type: 'string', tab: ['social'] },
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const buttons = Array.from(container.querySelectorAll('.tabs__tab'));
|
|
95
|
-
const labels = buttons.map((b) => b.textContent?.trim());
|
|
96
|
-
|
|
97
|
-
expect(labels).toContain('Seo');
|
|
98
|
-
expect(labels).toContain('Social');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('capitalizes custom tab labels', () => {
|
|
102
|
-
mockExtractTabs.mockReturnValueOnce(['advanced']);
|
|
103
|
-
|
|
104
|
-
const { container } = render(EditorTabs, {
|
|
105
|
-
props: { schema: { properties: {} } },
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const buttons = Array.from(container.querySelectorAll('.tabs__tab'));
|
|
109
|
-
const labels = buttons.map((b) => b.textContent?.trim());
|
|
110
|
-
expect(labels).toContain('Advanced');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('renders no custom tabs when schema is null', () => {
|
|
114
|
-
mockExtractTabs.mockReturnValueOnce([]);
|
|
115
|
-
|
|
116
|
-
const { container } = render(EditorTabs, {
|
|
117
|
-
props: { schema: null },
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const buttons = container.querySelectorAll('.tabs__tab');
|
|
121
|
-
// Only Metadata and Body should be present
|
|
122
|
-
expect(buttons.length).toBe(2);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
/*
|
|
126
|
-
//////////////////////////////
|
|
127
|
-
// Active tab state
|
|
128
|
-
//////////////////////////////
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
it('marks the active tab with tabs__tab--active class', () => {
|
|
132
|
-
mockActiveTab.mockReturnValue('body');
|
|
133
|
-
mockExtractTabs.mockReturnValueOnce([]);
|
|
134
|
-
|
|
135
|
-
const { container } = render(EditorTabs, {
|
|
136
|
-
props: { schema: null },
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const buttons = Array.from(container.querySelectorAll('.tabs__tab'));
|
|
140
|
-
const active = buttons.find((b) =>
|
|
141
|
-
b.classList.contains('tabs__tab--active'),
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
expect(active?.textContent?.trim()).toBe('Body');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('sets aria-selected="true" on the active tab', () => {
|
|
148
|
-
mockActiveTab.mockReturnValue('metadata');
|
|
149
|
-
mockExtractTabs.mockReturnValueOnce([]);
|
|
150
|
-
|
|
151
|
-
const { container } = render(EditorTabs, {
|
|
152
|
-
props: { schema: null },
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const buttons = Array.from(container.querySelectorAll('.tabs__tab'));
|
|
156
|
-
const activeBtn = buttons.find(
|
|
157
|
-
(b) => b.getAttribute('aria-selected') === 'true',
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
expect(activeBtn?.textContent?.trim()).toBe('Metadata');
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
/*
|
|
164
|
-
//////////////////////////////
|
|
165
|
-
// Click interaction
|
|
166
|
-
//////////////////////////////
|
|
167
|
-
*/
|
|
168
|
-
|
|
169
|
-
it('calls setActiveTab with the clicked tab identifier', async () => {
|
|
170
|
-
mockSetActiveTab.mockClear();
|
|
171
|
-
mockActiveTab.mockReturnValue('metadata');
|
|
172
|
-
mockExtractTabs.mockReturnValueOnce([]);
|
|
173
|
-
|
|
174
|
-
const { container } = render(EditorTabs, {
|
|
175
|
-
props: { schema: null },
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
const buttons = Array.from(
|
|
179
|
-
container.querySelectorAll('.tabs__tab'),
|
|
180
|
-
) as HTMLButtonElement[];
|
|
181
|
-
const bodyBtn = buttons.find((b) => b.textContent?.trim() === 'Body')!;
|
|
182
|
-
await fireEvent.click(bodyBtn);
|
|
183
|
-
|
|
184
|
-
expect(mockSetActiveTab).toHaveBeenCalledOnce();
|
|
185
|
-
expect(mockSetActiveTab).toHaveBeenCalledWith('body');
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it('calls setActiveTab with "metadata" when the Metadata tab is clicked', async () => {
|
|
189
|
-
mockSetActiveTab.mockClear();
|
|
190
|
-
mockActiveTab.mockReturnValue('body');
|
|
191
|
-
mockExtractTabs.mockReturnValueOnce([]);
|
|
192
|
-
|
|
193
|
-
const { container } = render(EditorTabs, {
|
|
194
|
-
props: { schema: null },
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
const buttons = Array.from(
|
|
198
|
-
container.querySelectorAll('.tabs__tab'),
|
|
199
|
-
) as HTMLButtonElement[];
|
|
200
|
-
const metaBtn = buttons.find((b) => b.textContent?.trim() === 'Metadata')!;
|
|
201
|
-
await fireEvent.click(metaBtn);
|
|
202
|
-
|
|
203
|
-
expect(mockSetActiveTab).toHaveBeenCalledWith('metadata');
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
/*
|
|
207
|
-
//////////////////////////////
|
|
208
|
-
// Body tab visibility by file type
|
|
209
|
-
//////////////////////////////
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
it('shows the Body tab when the open file is a .md file', () => {
|
|
213
|
-
mockEditorFile.mockReturnValueOnce({ filename: 'post.md' });
|
|
214
|
-
mockExtractTabs.mockReturnValueOnce([]);
|
|
215
|
-
|
|
216
|
-
const { container } = render(EditorTabs, {
|
|
217
|
-
props: { schema: null },
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
const buttons = Array.from(container.querySelectorAll('.tabs__tab'));
|
|
221
|
-
const labels = buttons.map((b) => b.textContent?.trim());
|
|
222
|
-
|
|
223
|
-
expect(labels).toContain('Body');
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('hides the Body tab when the open file is a .json file', () => {
|
|
227
|
-
mockEditorFile.mockReturnValueOnce({ filename: 'data.json' });
|
|
228
|
-
mockExtractTabs.mockReturnValueOnce([]);
|
|
229
|
-
|
|
230
|
-
const { container } = render(EditorTabs, {
|
|
231
|
-
props: { schema: null },
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
const buttons = Array.from(container.querySelectorAll('.tabs__tab'));
|
|
235
|
-
const labels = buttons.map((b) => b.textContent?.trim());
|
|
236
|
-
|
|
237
|
-
expect(labels).not.toContain('Body');
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
it('shows the Body tab when no file is open (fallback default)', () => {
|
|
241
|
-
mockEditorFile.mockReturnValueOnce(null);
|
|
242
|
-
mockExtractTabs.mockReturnValueOnce([]);
|
|
243
|
-
|
|
244
|
-
const { container } = render(EditorTabs, {
|
|
245
|
-
props: { schema: null },
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
const buttons = Array.from(container.querySelectorAll('.tabs__tab'));
|
|
249
|
-
const labels = buttons.map((b) => b.textContent?.trim());
|
|
250
|
-
|
|
251
|
-
expect(labels).toContain('Body');
|
|
252
|
-
});
|
|
253
|
-
});
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
-
import { render, cleanup, fireEvent } from '@testing-library/svelte';
|
|
3
|
-
import EditorToolbar from '../../../../src/client/components/editor/EditorToolbar.svelte';
|
|
4
|
-
import { makeEditorFile } from './fixtures';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Tests for the EditorToolbar component.
|
|
8
|
-
* The component imports state modules directly rather than receiving props,
|
|
9
|
-
* so we mock each module to control rendering and verify interactions.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// vi.hoisted ensures these declarations are available when vi.mock factories run,
|
|
13
|
-
// since vi.mock calls are hoisted to the top of the file by Vitest.
|
|
14
|
-
const {
|
|
15
|
-
mockGetEditorFile,
|
|
16
|
-
mockHandleSave,
|
|
17
|
-
mockHandlePublish,
|
|
18
|
-
mockOpenDialog,
|
|
19
|
-
mockComputePublishDisabled,
|
|
20
|
-
} = vi.hoisted(() => ({
|
|
21
|
-
mockGetEditorFile: vi.fn(),
|
|
22
|
-
mockHandleSave: vi.fn(),
|
|
23
|
-
mockHandlePublish: vi.fn(() => Promise.resolve({ status: 'ok' as const })),
|
|
24
|
-
mockOpenDialog: vi.fn(),
|
|
25
|
-
mockComputePublishDisabled: vi.fn(() => false),
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
vi.mock('../../../../src/client/js/editor/editor.svelte', () => ({
|
|
29
|
-
getEditorFile: mockGetEditorFile,
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
vi.mock('../../../../src/client/js/state/router.svelte', () => ({
|
|
33
|
-
nav: {
|
|
34
|
-
get route() {
|
|
35
|
-
return { view: 'file', collection: 'posts', slug: 'hello' };
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
vi.mock('../../../../src/client/js/state/schema.svelte', () => ({
|
|
41
|
-
schema: {
|
|
42
|
-
get active() {
|
|
43
|
-
return null;
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
vi.mock('../../../../src/client/js/handlers/admin', () => ({
|
|
49
|
-
handleSave: mockHandleSave,
|
|
50
|
-
handlePublish: mockHandlePublish,
|
|
51
|
-
computePublishDisabled: mockComputePublishDisabled,
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
vi.mock('../../../../src/client/js/state/dialogs.svelte', () => ({
|
|
55
|
-
dialog: {
|
|
56
|
-
open: mockOpenDialog,
|
|
57
|
-
},
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
// Prevent accumulated renders from bleeding between tests
|
|
61
|
-
afterEach(() => cleanup());
|
|
62
|
-
|
|
63
|
-
describe('EditorToolbar', () => {
|
|
64
|
-
/*
|
|
65
|
-
//////////////////////////////
|
|
66
|
-
// Renders when file is open
|
|
67
|
-
//////////////////////////////
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
it('renders the toolbar header when a file is open', () => {
|
|
71
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile());
|
|
72
|
-
|
|
73
|
-
const { container } = render(EditorToolbar);
|
|
74
|
-
|
|
75
|
-
expect(container.querySelector('.toolbar')).not.toBeNull();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('renders nothing when no file is open', () => {
|
|
79
|
-
mockGetEditorFile.mockReturnValue(null);
|
|
80
|
-
|
|
81
|
-
const { container } = render(EditorToolbar);
|
|
82
|
-
|
|
83
|
-
expect(container.querySelector('.toolbar')).toBeNull();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
/*
|
|
87
|
-
//////////////////////////////
|
|
88
|
-
// Title display
|
|
89
|
-
//////////////////////////////
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
it('shows the title from formData when present', () => {
|
|
93
|
-
mockGetEditorFile.mockReturnValue(
|
|
94
|
-
makeEditorFile({ formData: { title: 'My Great Post' } }),
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
const { container } = render(EditorToolbar);
|
|
98
|
-
|
|
99
|
-
expect(container.querySelector('.toolbar__title')?.textContent).toContain(
|
|
100
|
-
'My Great Post',
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('falls back to the filename when formData has no title', () => {
|
|
105
|
-
mockGetEditorFile.mockReturnValue(
|
|
106
|
-
makeEditorFile({ filename: 'my-post.md' }),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const { container } = render(EditorToolbar);
|
|
110
|
-
|
|
111
|
-
expect(container.querySelector('.toolbar__title')?.textContent).toContain(
|
|
112
|
-
'my-post.md',
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('shows "Untitled Draft" when there is no title and no filename', () => {
|
|
117
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile({ filename: '' }));
|
|
118
|
-
|
|
119
|
-
const { container } = render(EditorToolbar);
|
|
120
|
-
|
|
121
|
-
expect(container.querySelector('.toolbar__title')?.textContent).toContain(
|
|
122
|
-
'Untitled Draft',
|
|
123
|
-
);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
/*
|
|
127
|
-
//////////////////////////////
|
|
128
|
-
// Save button
|
|
129
|
-
//////////////////////////////
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
it('renders the Save button', () => {
|
|
133
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile());
|
|
134
|
-
|
|
135
|
-
const { container } = render(EditorToolbar);
|
|
136
|
-
|
|
137
|
-
const saveBtn = container.querySelector('.btn--save-outline');
|
|
138
|
-
expect(saveBtn).not.toBeNull();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('disables Save when file is not dirty', () => {
|
|
142
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile({ dirty: false }));
|
|
143
|
-
|
|
144
|
-
const { container } = render(EditorToolbar);
|
|
145
|
-
|
|
146
|
-
const saveBtn = container.querySelector(
|
|
147
|
-
'.btn--save-outline',
|
|
148
|
-
) as HTMLButtonElement;
|
|
149
|
-
expect(saveBtn?.disabled).toBe(true);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it('calls handleSave when the Save button is clicked', async () => {
|
|
153
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile({ dirty: true }));
|
|
154
|
-
|
|
155
|
-
const { container } = render(EditorToolbar);
|
|
156
|
-
|
|
157
|
-
await fireEvent.click(container.querySelector('.btn--save-outline')!);
|
|
158
|
-
expect(mockHandleSave).toHaveBeenCalledOnce();
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
/*
|
|
162
|
-
//////////////////////////////
|
|
163
|
-
// Publish button
|
|
164
|
-
//////////////////////////////
|
|
165
|
-
*/
|
|
166
|
-
|
|
167
|
-
it('renders the Publish button', () => {
|
|
168
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile());
|
|
169
|
-
|
|
170
|
-
const { container } = render(EditorToolbar);
|
|
171
|
-
|
|
172
|
-
expect(container.querySelector('.btn--primary')).not.toBeNull();
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it('disables the Publish button when computePublishDisabled returns true', () => {
|
|
176
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile());
|
|
177
|
-
mockComputePublishDisabled.mockReturnValue(true);
|
|
178
|
-
|
|
179
|
-
const { container } = render(EditorToolbar);
|
|
180
|
-
|
|
181
|
-
const publishBtn = container.querySelector(
|
|
182
|
-
'.btn--primary',
|
|
183
|
-
) as HTMLButtonElement;
|
|
184
|
-
expect(publishBtn?.disabled).toBe(true);
|
|
185
|
-
|
|
186
|
-
mockComputePublishDisabled.mockReturnValue(false);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('enables the Publish button when not disabled and not saving', () => {
|
|
190
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile({ saving: false }));
|
|
191
|
-
mockComputePublishDisabled.mockReturnValue(false);
|
|
192
|
-
|
|
193
|
-
const { container } = render(EditorToolbar);
|
|
194
|
-
|
|
195
|
-
const publishBtn = container.querySelector(
|
|
196
|
-
'.btn--primary',
|
|
197
|
-
) as HTMLButtonElement;
|
|
198
|
-
expect(publishBtn?.disabled).toBe(false);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('calls handlePublish when the Publish button is clicked', async () => {
|
|
202
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile());
|
|
203
|
-
|
|
204
|
-
const { container } = render(EditorToolbar);
|
|
205
|
-
|
|
206
|
-
await fireEvent.click(container.querySelector('.btn--primary')!);
|
|
207
|
-
expect(mockHandlePublish).toHaveBeenCalledOnce();
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it('shows filename dialog when publish needs a filename', async () => {
|
|
211
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile());
|
|
212
|
-
mockHandlePublish.mockResolvedValueOnce({ status: 'needs-filename' });
|
|
213
|
-
|
|
214
|
-
const { container } = render(EditorToolbar);
|
|
215
|
-
|
|
216
|
-
await fireEvent.click(container.querySelector('.btn--primary')!);
|
|
217
|
-
expect(mockOpenDialog).toHaveBeenCalledWith('filename');
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
/*
|
|
221
|
-
//////////////////////////////
|
|
222
|
-
// Delete Draft button
|
|
223
|
-
//////////////////////////////
|
|
224
|
-
*/
|
|
225
|
-
|
|
226
|
-
it('renders the Delete Draft button when draftId is set', () => {
|
|
227
|
-
mockGetEditorFile.mockReturnValue(
|
|
228
|
-
makeEditorFile({ draftId: 'draft-abc-123' }),
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
const { container } = render(EditorToolbar);
|
|
232
|
-
|
|
233
|
-
expect(container.querySelector('.btn--danger-outline')).not.toBeNull();
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('does not render the Delete Draft button when draftId is null', () => {
|
|
237
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile({ draftId: null }));
|
|
238
|
-
|
|
239
|
-
const { container } = render(EditorToolbar);
|
|
240
|
-
|
|
241
|
-
expect(container.querySelector('.btn--danger-outline')).toBeNull();
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
it('calls showDeleteDialog when the Delete Draft button is clicked', async () => {
|
|
245
|
-
mockGetEditorFile.mockReturnValue(makeEditorFile({ draftId: 'draft-abc' }));
|
|
246
|
-
|
|
247
|
-
const { container } = render(EditorToolbar);
|
|
248
|
-
|
|
249
|
-
await fireEvent.click(container.querySelector('.btn--danger-outline')!);
|
|
250
|
-
expect(mockOpenDialog).toHaveBeenCalledWith('delete');
|
|
251
|
-
});
|
|
252
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* Shared test fixtures for editor component tests. */
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Builds a minimal EditorFile fixture with sensible defaults.
|
|
5
|
-
* @param {Partial<Record<string, unknown>>} overrides - Fields to override on the default file
|
|
6
|
-
* @return {Record<string, unknown>} A minimal EditorFile-like object
|
|
7
|
-
*/
|
|
8
|
-
export function makeEditorFile(
|
|
9
|
-
overrides: Partial<{
|
|
10
|
-
filename: string;
|
|
11
|
-
dirty: boolean;
|
|
12
|
-
saving: boolean;
|
|
13
|
-
draftId: string | null;
|
|
14
|
-
formData: Record<string, unknown>;
|
|
15
|
-
body: string;
|
|
16
|
-
bodyLoaded: boolean;
|
|
17
|
-
isNewDraft: boolean;
|
|
18
|
-
}> = {},
|
|
19
|
-
) {
|
|
20
|
-
return {
|
|
21
|
-
filename: 'my-post.md',
|
|
22
|
-
dirty: false,
|
|
23
|
-
saving: false,
|
|
24
|
-
draftId: null,
|
|
25
|
-
formData: {},
|
|
26
|
-
body: '',
|
|
27
|
-
bodyLoaded: true,
|
|
28
|
-
isNewDraft: false,
|
|
29
|
-
...overrides,
|
|
30
|
-
};
|
|
31
|
-
}
|