@mapomodule/uikit 2.0.0-beta.2 → 2.0.0-beta.20
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 +46 -142
- package/dist/__tests__/MapoConfirmDialog.component.test.d.ts +2 -0
- package/dist/__tests__/MapoConfirmDialog.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoDetail.component.test.d.ts +2 -0
- package/dist/__tests__/MapoDetail.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoDetailLangSwitch.component.test.d.ts +2 -0
- package/dist/__tests__/MapoDetailLangSwitch.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoList.component.test.d.ts +2 -0
- package/dist/__tests__/MapoList.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoListActions.component.test.d.ts +2 -0
- package/dist/__tests__/MapoListActions.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoListTable.component.test.d.ts +2 -0
- package/dist/__tests__/MapoListTable.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMediaEditor.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaEditor.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMediaFolderPicker.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaFolderPicker.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMediaFolders.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaFolders.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMediaGallery.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaGallery.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMediaUploadHandover.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMediaUploadHandover.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoMenuManager.component.test.d.ts +2 -0
- package/dist/__tests__/MapoMenuManager.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoSnackBar.component.test.d.ts +2 -0
- package/dist/__tests__/MapoSnackBar.component.test.d.ts.map +1 -0
- package/dist/__tests__/__mocks__/nuxt-app.d.ts +9 -0
- package/dist/__tests__/__mocks__/nuxt-app.d.ts.map +1 -0
- package/dist/__tests__/langInfo.test.d.ts +2 -0
- package/dist/__tests__/langInfo.test.d.ts.map +1 -0
- package/dist/__tests__/listTable.test.d.ts +2 -0
- package/dist/__tests__/listTable.test.d.ts.map +1 -0
- package/dist/__tests__/mediaDrag.test.d.ts +2 -0
- package/dist/__tests__/mediaDrag.test.d.ts.map +1 -0
- package/dist/__tests__/mediaFolders.test.d.ts +2 -0
- package/dist/__tests__/mediaFolders.test.d.ts.map +1 -0
- package/dist/__tests__/mediaLanguages.test.d.ts +2 -0
- package/dist/__tests__/mediaLanguages.test.d.ts.map +1 -0
- package/dist/__tests__/mediaMetadata.test.d.ts +2 -0
- package/dist/__tests__/mediaMetadata.test.d.ts.map +1 -0
- package/dist/__tests__/mediaStore.test.d.ts +2 -0
- package/dist/__tests__/mediaStore.test.d.ts.map +1 -0
- package/dist/__tests__/mediaUrl.test.d.ts +2 -0
- package/dist/__tests__/mediaUrl.test.d.ts.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/module.d.mts +48 -1
- package/dist/module.d.ts +44 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +71 -2
- package/dist/runtime/adapters/defaultMediaAdapter.d.ts +15 -0
- package/dist/runtime/adapters/defaultMediaAdapter.d.ts.map +1 -0
- package/dist/runtime/adapters/defaultMediaAdapter.js +35 -0
- package/dist/runtime/assets/main.css +1 -1
- package/dist/runtime/components/MapoConfirmDialog.vue +23 -4
- package/dist/runtime/components/MapoConfirmDialog.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetail.vue +127 -55
- package/dist/runtime/components/MapoDetail.vue.d.ts +102 -5
- package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetailLangSwitch.vue +22 -26
- package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts +4 -3
- package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDropArea.vue +110 -0
- package/dist/runtime/components/MapoDropArea.vue.d.ts +33 -0
- package/dist/runtime/components/MapoDropArea.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoLangSwitcher.vue +39 -0
- package/dist/runtime/components/MapoLangSwitcher.vue.d.ts +18 -0
- package/dist/runtime/components/MapoLangSwitcher.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoList.vue +45 -31
- package/dist/runtime/components/MapoList.vue.d.ts +18 -5
- package/dist/runtime/components/MapoList.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListActions.vue +27 -13
- package/dist/runtime/components/MapoListActions.vue.d.ts +4 -0
- package/dist/runtime/components/MapoListActions.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListFilters.vue +4 -2
- package/dist/runtime/components/MapoListFilters.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListQuickEdit.vue +20 -10
- package/dist/runtime/components/MapoListQuickEdit.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListTable.vue +125 -49
- package/dist/runtime/components/MapoListTable.vue.d.ts +13 -5
- package/dist/runtime/components/MapoListTable.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoLogin.vue +13 -10
- package/dist/runtime/components/MapoLogin.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoLogoutButton.vue +4 -2
- package/dist/runtime/components/MapoLogoutButton.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue +47 -0
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts +4 -0
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaEditor.vue +382 -0
- package/dist/runtime/components/MapoMediaEditor.vue.d.ts +13 -0
- package/dist/runtime/components/MapoMediaEditor.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaFileChanger.vue +112 -0
- package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts +15 -0
- package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaFolderPicker.vue +129 -0
- package/dist/runtime/components/MapoMediaFolderPicker.vue.d.ts +33 -0
- package/dist/runtime/components/MapoMediaFolderPicker.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaFolders.vue +402 -0
- package/dist/runtime/components/MapoMediaFolders.vue.d.ts +4 -0
- package/dist/runtime/components/MapoMediaFolders.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaGallery.vue +304 -0
- package/dist/runtime/components/MapoMediaGallery.vue.d.ts +8 -0
- package/dist/runtime/components/MapoMediaGallery.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaManager.vue +144 -0
- package/dist/runtime/components/MapoMediaManager.vue.d.ts +44 -0
- package/dist/runtime/components/MapoMediaManager.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaManagerDialog.vue +116 -0
- package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts +41 -0
- package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaPreview.vue +94 -0
- package/dist/runtime/components/MapoMediaPreview.vue.d.ts +19 -0
- package/dist/runtime/components/MapoMediaPreview.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaUploader.vue +294 -0
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts +8 -0
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuManager.vue +301 -0
- package/dist/runtime/components/MapoMenuManager.vue.d.ts +92 -0
- package/dist/runtime/components/MapoMenuManager.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuNodeEditor.vue +201 -0
- package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts +61 -0
- package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuTreeview.vue +181 -0
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts +57 -0
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuTreeviewNode.vue +175 -0
- package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts +27 -0
- package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoSidebar.vue +3 -1
- package/dist/runtime/components/MapoSidebar.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoSidebarList.vue +1 -1
- package/dist/runtime/components/MapoSidebarProfile.vue +6 -2
- package/dist/runtime/components/MapoSidebarProfile.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoSnackBar.vue +11 -0
- package/dist/runtime/components/MapoSnackBar.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoThemeToggle.vue +5 -1
- package/dist/runtime/components/MapoThemeToggle.vue.d.ts.map +1 -1
- package/dist/runtime/components/menuDndContext.d.ts +19 -0
- package/dist/runtime/components/menuDndContext.d.ts.map +1 -0
- package/dist/runtime/components/menuDndContext.js +3 -0
- package/dist/runtime/page-meta.nuxt.d.ts +4 -0
- package/dist/runtime/pages/index.vue +4 -3
- package/dist/runtime/pages/index.vue.d.ts.map +1 -1
- package/dist/runtime/pages/login.vue +0 -4
- package/dist/runtime/pages/login.vue.d.ts.map +1 -1
- package/dist/runtime/plugins/media-adapter.d.ts +18 -0
- package/dist/runtime/plugins/media-adapter.d.ts.map +1 -0
- package/dist/runtime/plugins/media-adapter.js +8 -0
- package/dist/runtime/stores/media.d.ts +505 -0
- package/dist/runtime/stores/media.d.ts.map +1 -0
- package/dist/runtime/stores/media.js +545 -0
- package/dist/runtime/types/list.d.ts +10 -2
- package/dist/runtime/types/list.d.ts.map +1 -1
- package/dist/runtime/types/media.d.ts +131 -0
- package/dist/runtime/types/media.d.ts.map +1 -0
- package/dist/runtime/types/media.js +0 -0
- package/dist/runtime/types/menu.d.ts +66 -0
- package/dist/runtime/types/menu.d.ts.map +1 -0
- package/dist/runtime/types/menu.js +30 -0
- package/dist/runtime/utils/contentLanguages.d.ts +9 -0
- package/dist/runtime/utils/contentLanguages.d.ts.map +1 -0
- package/dist/runtime/utils/contentLanguages.js +8 -0
- package/dist/runtime/utils/langInfo.d.ts +43 -0
- package/dist/runtime/utils/langInfo.d.ts.map +1 -0
- package/dist/runtime/utils/langInfo.js +17 -0
- package/dist/runtime/utils/listTable.d.ts +29 -0
- package/dist/runtime/utils/listTable.d.ts.map +1 -0
- package/dist/runtime/utils/listTable.js +21 -0
- package/dist/runtime/utils/mediaDrag.d.ts +21 -0
- package/dist/runtime/utils/mediaDrag.d.ts.map +1 -0
- package/dist/runtime/utils/mediaDrag.js +11 -0
- package/dist/runtime/utils/mediaFolders.d.ts +65 -0
- package/dist/runtime/utils/mediaFolders.d.ts.map +1 -0
- package/dist/runtime/utils/mediaFolders.js +97 -0
- package/dist/runtime/utils/mediaMetadata.d.ts +39 -0
- package/dist/runtime/utils/mediaMetadata.d.ts.map +1 -0
- package/dist/runtime/utils/mediaMetadata.js +97 -0
- package/dist/runtime/utils/mediaUrl.d.ts +16 -0
- package/dist/runtime/utils/mediaUrl.d.ts.map +1 -0
- package/dist/runtime/utils/mediaUrl.js +12 -0
- package/dist/types.d.mts +1 -1
- package/package.json +15 -11
- package/src/__tests__/MapoConfirmDialog.component.test.ts +165 -0
- package/src/__tests__/MapoDetail.component.test.ts +393 -0
- package/src/__tests__/MapoDetailLangSwitch.component.test.ts +145 -0
- package/src/__tests__/MapoList.component.test.ts +166 -0
- package/src/__tests__/MapoListActions.component.test.ts +175 -0
- package/src/__tests__/MapoListTable.component.test.ts +545 -0
- package/src/__tests__/MapoMediaEditor.component.test.ts +447 -0
- package/src/__tests__/MapoMediaFolderPicker.component.test.ts +220 -0
- package/src/__tests__/MapoMediaFolders.component.test.ts +519 -0
- package/src/__tests__/MapoMediaGallery.component.test.ts +211 -0
- package/src/__tests__/MapoMediaUploadHandover.component.test.ts +241 -0
- package/src/__tests__/MapoMenuManager.component.test.ts +175 -0
- package/src/__tests__/MapoSnackBar.component.test.ts +79 -0
- package/src/__tests__/__mocks__/nuxt-app.ts +8 -0
- package/src/__tests__/langInfo.test.ts +85 -0
- package/src/__tests__/listTable.test.ts +82 -0
- package/src/__tests__/mediaDrag.test.ts +42 -0
- package/src/__tests__/mediaFolders.test.ts +204 -0
- package/src/__tests__/mediaLanguages.test.ts +66 -0
- package/src/__tests__/mediaMetadata.test.ts +169 -0
- package/src/__tests__/mediaStore.test.ts +569 -0
- package/src/__tests__/mediaUrl.test.ts +44 -0
- package/src/index.ts +21 -0
- package/src/module.ts +155 -0
- package/src/runtime/adapters/defaultMediaAdapter.ts +67 -0
- package/src/runtime/assets/main.css +9 -0
- package/src/runtime/components/MapoConfirmDialog.vue +33 -4
- package/src/runtime/components/MapoDetail.vue +229 -73
- package/src/runtime/components/MapoDetailLangSwitch.vue +27 -28
- package/src/runtime/components/MapoDropArea.vue +145 -0
- package/src/runtime/components/MapoLangSwitcher.vue +74 -0
- package/src/runtime/components/MapoList.vue +65 -34
- package/src/runtime/components/MapoListActions.vue +32 -14
- package/src/runtime/components/MapoListFilters.vue +5 -2
- package/src/runtime/components/MapoListQuickEdit.vue +22 -10
- package/src/runtime/components/MapoListTable.vue +159 -59
- package/src/runtime/components/MapoLogin.vue +13 -10
- package/src/runtime/components/MapoLogoutButton.vue +4 -2
- package/src/runtime/components/MapoMediaBreadcrumbs.vue +53 -0
- package/src/runtime/components/MapoMediaEditor.vue +447 -0
- package/src/runtime/components/MapoMediaFileChanger.vue +136 -0
- package/src/runtime/components/MapoMediaFolderPicker.vue +176 -0
- package/src/runtime/components/MapoMediaFolders.vue +478 -0
- package/src/runtime/components/MapoMediaGallery.vue +350 -0
- package/src/runtime/components/MapoMediaManager.vue +194 -0
- package/src/runtime/components/MapoMediaManagerDialog.vue +148 -0
- package/src/runtime/components/MapoMediaPreview.vue +116 -0
- package/src/runtime/components/MapoMediaUploader.vue +362 -0
- package/src/runtime/components/MapoMenuManager.vue +454 -0
- package/src/runtime/components/MapoMenuNodeEditor.vue +282 -0
- package/src/runtime/components/MapoMenuTreeview.vue +264 -0
- package/src/runtime/components/MapoMenuTreeviewNode.vue +234 -0
- package/src/runtime/components/MapoSidebar.vue +3 -1
- package/src/runtime/components/MapoSidebarList.vue +1 -1
- package/src/runtime/components/MapoSidebarProfile.vue +6 -2
- package/src/runtime/components/MapoSnackBar.vue +12 -0
- package/src/runtime/components/MapoThemeToggle.vue +5 -1
- package/src/runtime/components/menuDndContext.ts +22 -0
- package/src/runtime/page-meta.nuxt.d.ts +4 -0
- package/src/runtime/pages/index.vue +4 -3
- package/src/runtime/pages/login.vue +0 -4
- package/src/runtime/plugins/media-adapter.ts +33 -0
- package/src/runtime/stores/media.ts +820 -0
- package/src/runtime/types/list.ts +10 -2
- package/src/runtime/types/media.ts +144 -0
- package/src/runtime/types/menu.ts +105 -0
- package/src/runtime/utils/contentLanguages.ts +18 -0
- package/src/runtime/utils/langInfo.ts +63 -0
- package/src/runtime/utils/listTable.ts +54 -0
- package/src/runtime/utils/mediaDrag.ts +29 -0
- package/src/runtime/utils/mediaFolders.ts +182 -0
- package/src/runtime/utils/mediaMetadata.ts +165 -0
- package/src/runtime/utils/mediaUrl.ts +30 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/uikit",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.20",
|
|
4
4
|
"description": "Mapo UI components: Sidebar, Topbar, Login, SnackBar, ConfirmDialog, List, Detail, Media",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,31 +40,35 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "nuxt-module-build build && vue-tsc -p tsconfig.build-types.json && node ../../../scripts/clean-empty-vue-dts.mjs dist",
|
|
42
42
|
"dev": "nuxt-module-build build --stub --watch",
|
|
43
|
-
"prepack": "pnpm build",
|
|
44
43
|
"dev:prepare": "nuxt-module-build build --stub",
|
|
45
44
|
"typecheck": "vue-tsc --noEmit",
|
|
46
45
|
"lint": "eslint src"
|
|
47
46
|
},
|
|
48
47
|
"dependencies": {
|
|
49
|
-
"@mapomodule/form": "2.0.0-beta.
|
|
50
|
-
"@mapomodule/
|
|
51
|
-
"@mapomodule/
|
|
52
|
-
"@mapomodule/
|
|
48
|
+
"@mapomodule/form": "2.0.0-beta.17",
|
|
49
|
+
"@mapomodule/i18n": "2.0.0-beta.8",
|
|
50
|
+
"@mapomodule/store": "2.0.0-beta.6",
|
|
51
|
+
"@mapomodule/utils": "2.0.0-beta.7",
|
|
52
|
+
"@mapomodule/core": "2.0.0-beta.12",
|
|
53
|
+
"tailwindcss": "^4.0.0",
|
|
54
|
+
"vue-draggable-plus": "^0.6.0",
|
|
55
|
+
"vue-i18n": "^11.4.8"
|
|
53
56
|
},
|
|
54
57
|
"peerDependencies": {
|
|
55
58
|
"@nuxt/ui": ">=4.0.0",
|
|
56
|
-
"nuxt": ">=4.0.0"
|
|
59
|
+
"nuxt": ">=4.0.0",
|
|
60
|
+
"pinia": ">=3.0.0"
|
|
57
61
|
},
|
|
58
62
|
"devDependencies": {
|
|
59
63
|
"@nuxt/kit": "4.4.2",
|
|
60
64
|
"@nuxt/module-builder": "^1.0.2",
|
|
61
65
|
"@nuxt/schema": "4.4.2",
|
|
62
|
-
"tailwindcss": "^4.0.0",
|
|
63
66
|
"@nuxt/ui": "^4.7.0",
|
|
64
67
|
"@tanstack/vue-table": "^8.21.3",
|
|
65
|
-
"nuxt": "^4.
|
|
66
|
-
"
|
|
67
|
-
"vue
|
|
68
|
+
"nuxt": "^4.5.1",
|
|
69
|
+
"pinia": "^3.0.4",
|
|
70
|
+
"vue": "^3.5.40",
|
|
71
|
+
"vue-router": "^5.2.0",
|
|
68
72
|
"vue-tsc": "^3.3.4"
|
|
69
73
|
}
|
|
70
74
|
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { createRenderer, h, nextTick, onUnmounted, ref } from "vue";
|
|
3
|
+
import type { App, Component, SetupContext } from "vue";
|
|
4
|
+
import { createPinia, setActivePinia } from "pinia";
|
|
5
|
+
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
6
|
+
|
|
7
|
+
import MapoConfirmDialog from "../runtime/components/MapoConfirmDialog.vue";
|
|
8
|
+
|
|
9
|
+
vi.mock("vue-i18n", () => ({ useI18n: () => ({ t: (key: string) => key }) }));
|
|
10
|
+
|
|
11
|
+
// Tests run in Node without a DOM. A renderer whose nodes are plain objects is
|
|
12
|
+
// enough to mount the component with real reactivity, watchers and events.
|
|
13
|
+
interface HeadlessNode {
|
|
14
|
+
parent: HeadlessNode | null;
|
|
15
|
+
children: HeadlessNode[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const headlessNode = (): HeadlessNode => ({ parent: null, children: [] });
|
|
19
|
+
|
|
20
|
+
const { createApp } = createRenderer<HeadlessNode, HeadlessNode>({
|
|
21
|
+
createElement: headlessNode,
|
|
22
|
+
createText: headlessNode,
|
|
23
|
+
createComment: headlessNode,
|
|
24
|
+
setText: () => {},
|
|
25
|
+
setElementText: () => {},
|
|
26
|
+
patchProp: () => {},
|
|
27
|
+
insert(child, parent, anchor) {
|
|
28
|
+
child.parent = parent;
|
|
29
|
+
const at = anchor ? parent.children.indexOf(anchor) : -1;
|
|
30
|
+
parent.children.splice(at < 0 ? parent.children.length : at, 0, child);
|
|
31
|
+
},
|
|
32
|
+
remove(child) {
|
|
33
|
+
child.parent?.children.splice(child.parent.children.indexOf(child), 1);
|
|
34
|
+
child.parent = null;
|
|
35
|
+
},
|
|
36
|
+
parentNode: (node) => node.parent,
|
|
37
|
+
nextSibling: (node) =>
|
|
38
|
+
node.parent?.children[node.parent.children.indexOf(node) + 1] ?? null,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const passthrough = (name: string): Component => ({
|
|
42
|
+
name,
|
|
43
|
+
inheritAttrs: false,
|
|
44
|
+
setup(_props: unknown, { slots }: SetupContext) {
|
|
45
|
+
return () => h("div", null, slots.default?.());
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Nuxt UI overlays have no z-index: they stack in the order their portals enter
|
|
50
|
+
// <body>, which is the order the overlays mount. The stubs record that order.
|
|
51
|
+
const mountOrder: string[] = [];
|
|
52
|
+
|
|
53
|
+
// `UModal` declares what the dialog binds: `open` in, and `after:leave` out once
|
|
54
|
+
// the close animation has ended.
|
|
55
|
+
let modal: { readonly open: boolean | undefined; finishLeave(): void } | null =
|
|
56
|
+
null;
|
|
57
|
+
|
|
58
|
+
const UModal: Component = {
|
|
59
|
+
name: "UModal",
|
|
60
|
+
props: { open: Boolean, dismissible: Boolean },
|
|
61
|
+
emits: ["after:leave"],
|
|
62
|
+
setup(props: { open?: boolean }, { emit }: SetupContext<["after:leave"]>) {
|
|
63
|
+
mountOrder.push("confirm");
|
|
64
|
+
modal = {
|
|
65
|
+
get open() {
|
|
66
|
+
return props.open;
|
|
67
|
+
},
|
|
68
|
+
finishLeave: () => emit("after:leave"),
|
|
69
|
+
};
|
|
70
|
+
onUnmounted(() => {
|
|
71
|
+
modal = null;
|
|
72
|
+
});
|
|
73
|
+
return () => h("div");
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// An overlay that a page opens once the layout is already there, like the media
|
|
78
|
+
// editor drawer.
|
|
79
|
+
const Drawer: Component = {
|
|
80
|
+
name: "Drawer",
|
|
81
|
+
setup() {
|
|
82
|
+
mountOrder.push("drawer");
|
|
83
|
+
return () => h("div");
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const drawerOpen = ref(false);
|
|
88
|
+
|
|
89
|
+
let app: App<HeadlessNode> | undefined;
|
|
90
|
+
|
|
91
|
+
/** Mounts the dialog the way the layout does; returns the store that drives it. */
|
|
92
|
+
function mountLayout() {
|
|
93
|
+
const pinia = createPinia();
|
|
94
|
+
setActivePinia(pinia);
|
|
95
|
+
const root: Component = {
|
|
96
|
+
// The page comes first, then the root components, as in `mapo-default`.
|
|
97
|
+
render: () => [
|
|
98
|
+
drawerOpen.value ? h(Drawer) : null,
|
|
99
|
+
h(MapoConfirmDialog as Component),
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
app = createApp(root);
|
|
103
|
+
app.use(pinia);
|
|
104
|
+
app.component("UModal", UModal);
|
|
105
|
+
app.component("UButton", passthrough("UButton"));
|
|
106
|
+
app.mount(headlessNode());
|
|
107
|
+
return useConfirmStore();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
beforeEach(() => {
|
|
111
|
+
mountOrder.length = 0;
|
|
112
|
+
drawerOpen.value = false;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
afterEach(() => {
|
|
116
|
+
app?.unmount();
|
|
117
|
+
app = undefined;
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe("MapoConfirmDialog", () => {
|
|
121
|
+
it("opens above an overlay the page opened after the layout", async () => {
|
|
122
|
+
const confirm = mountLayout();
|
|
123
|
+
drawerOpen.value = true;
|
|
124
|
+
await nextTick();
|
|
125
|
+
|
|
126
|
+
void confirm.ask({ message: "Delete?" });
|
|
127
|
+
await nextTick();
|
|
128
|
+
|
|
129
|
+
expect(modal?.open).toBe(true);
|
|
130
|
+
expect(mountOrder).toEqual(["drawer", "confirm"]);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("stays mounted until its close animation has ended", async () => {
|
|
134
|
+
const confirm = mountLayout();
|
|
135
|
+
const answer = confirm.ask({ message: "Delete?" });
|
|
136
|
+
await nextTick();
|
|
137
|
+
|
|
138
|
+
confirm.confirm();
|
|
139
|
+
await nextTick();
|
|
140
|
+
|
|
141
|
+
expect(modal?.open).toBe(false);
|
|
142
|
+
modal?.finishLeave();
|
|
143
|
+
await nextTick();
|
|
144
|
+
|
|
145
|
+
expect(modal).toBeNull();
|
|
146
|
+
await expect(answer).resolves.toBe(true);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("stays open when asked again while it was closing", async () => {
|
|
150
|
+
const confirm = mountLayout();
|
|
151
|
+
void confirm.ask({ message: "First?" });
|
|
152
|
+
await nextTick();
|
|
153
|
+
confirm.cancel();
|
|
154
|
+
await nextTick();
|
|
155
|
+
const closing = modal;
|
|
156
|
+
|
|
157
|
+
void confirm.ask({ message: "Second?" });
|
|
158
|
+
await nextTick();
|
|
159
|
+
// The first close animation reports its end after the second question.
|
|
160
|
+
closing?.finishLeave();
|
|
161
|
+
await nextTick();
|
|
162
|
+
|
|
163
|
+
expect(modal?.open).toBe(true);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { createRenderer, h, onUnmounted } from "vue";
|
|
3
|
+
import type { App, Component, SetupContext, VNode } from "vue";
|
|
4
|
+
|
|
5
|
+
import MapoDetail from "../runtime/components/MapoDetail.vue";
|
|
6
|
+
|
|
7
|
+
type AfterEachHook = (to: unknown, from: unknown, failure?: unknown) => void;
|
|
8
|
+
|
|
9
|
+
// The detail reads the router, the stores and the CRUD layer at setup: replace
|
|
10
|
+
// them with in-memory doubles. `vi.hoisted` lets the mock factories share them.
|
|
11
|
+
const router = vi.hoisted(() => ({
|
|
12
|
+
back: vi.fn(),
|
|
13
|
+
replace: vi.fn(),
|
|
14
|
+
afterEach: vi.fn<(hook: AfterEachHook) => () => void>(),
|
|
15
|
+
// Vue Router keeps the previous location of the current entry in `state.back`.
|
|
16
|
+
options: { history: { state: { back: "/news" as string | null } } },
|
|
17
|
+
}));
|
|
18
|
+
const crud = vi.hoisted(() => ({
|
|
19
|
+
options: vi.fn(),
|
|
20
|
+
detail: vi.fn(),
|
|
21
|
+
create: vi.fn(),
|
|
22
|
+
partialUpdate: vi.fn(),
|
|
23
|
+
update: vi.fn(),
|
|
24
|
+
delete: vi.fn(),
|
|
25
|
+
}));
|
|
26
|
+
const confirm = vi.hoisted(() => ({ ask: vi.fn() }));
|
|
27
|
+
const mapoFormProps: Array<{ notifyErrors: boolean }> = [];
|
|
28
|
+
|
|
29
|
+
// The app's `mapo.uikit` runtime config, changed by the content-language tests.
|
|
30
|
+
const runtimeConfig = vi.hoisted(() => ({
|
|
31
|
+
public: { mapoUikit: { contentLanguages: [] as string[] } },
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
vi.mock("#app", () => ({
|
|
35
|
+
useRouter: () => router,
|
|
36
|
+
onBeforeRouteLeave: () => {},
|
|
37
|
+
useNuxtApp: () => ({ $mapoFormRegistry: {} }),
|
|
38
|
+
useRuntimeConfig: () => runtimeConfig,
|
|
39
|
+
}));
|
|
40
|
+
vi.mock("vue-i18n", () => ({ useI18n: () => ({ t: (key: string) => key }) }));
|
|
41
|
+
vi.mock("@mapomodule/core/runtime/api/crud", () => ({ useCrud: () => crud }));
|
|
42
|
+
vi.mock("@mapomodule/store/runtime/stores/snack", () => ({
|
|
43
|
+
useSnackStore: () => ({ show: vi.fn() }),
|
|
44
|
+
}));
|
|
45
|
+
vi.mock("@mapomodule/store/runtime/stores/confirm", () => ({
|
|
46
|
+
useConfirmStore: () => confirm,
|
|
47
|
+
}));
|
|
48
|
+
vi.mock("@mapomodule/store/runtime/composables/usePermissions", () => ({
|
|
49
|
+
usePermissions: () => ({
|
|
50
|
+
canAdd: () => true,
|
|
51
|
+
canChange: () => true,
|
|
52
|
+
canDelete: () => true,
|
|
53
|
+
}),
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
// Tests run in Node without a DOM. A renderer whose nodes are plain objects is
|
|
57
|
+
// enough to mount the component with real reactivity, watchers and events.
|
|
58
|
+
interface HeadlessNode {
|
|
59
|
+
parent: HeadlessNode | null;
|
|
60
|
+
children: HeadlessNode[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const headlessNode = (): HeadlessNode => ({ parent: null, children: [] });
|
|
64
|
+
|
|
65
|
+
const { createApp } = createRenderer<HeadlessNode, HeadlessNode>({
|
|
66
|
+
createElement: headlessNode,
|
|
67
|
+
createText: headlessNode,
|
|
68
|
+
createComment: headlessNode,
|
|
69
|
+
setText: () => {},
|
|
70
|
+
setElementText: () => {},
|
|
71
|
+
patchProp: () => {},
|
|
72
|
+
insert(child, parent, anchor) {
|
|
73
|
+
child.parent = parent;
|
|
74
|
+
const at = anchor ? parent.children.indexOf(anchor) : -1;
|
|
75
|
+
parent.children.splice(at < 0 ? parent.children.length : at, 0, child);
|
|
76
|
+
},
|
|
77
|
+
remove(child) {
|
|
78
|
+
child.parent?.children.splice(child.parent.children.indexOf(child), 1);
|
|
79
|
+
child.parent = null;
|
|
80
|
+
},
|
|
81
|
+
parentNode: (node) => node.parent,
|
|
82
|
+
nextSibling: (node) =>
|
|
83
|
+
node.parent?.children[node.parent.children.indexOf(node) + 1] ?? null,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const passthrough = (name: string): Component => ({
|
|
87
|
+
name,
|
|
88
|
+
inheritAttrs: false,
|
|
89
|
+
setup(_props: unknown, { slots }: SetupContext) {
|
|
90
|
+
return () => h("div", null, slots.default?.());
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const slotText = (nodes: VNode[] | undefined) =>
|
|
95
|
+
(nodes ?? [])
|
|
96
|
+
.map((node) => (typeof node.children === "string" ? node.children : ""))
|
|
97
|
+
.join("")
|
|
98
|
+
.trim();
|
|
99
|
+
|
|
100
|
+
// `UButton` declares what the detail binds: `loading` and `disabled` in, `click`
|
|
101
|
+
// out. Like the real one, a loading or disabled button emits no click.
|
|
102
|
+
interface ButtonStub {
|
|
103
|
+
readonly label: string;
|
|
104
|
+
readonly loading: boolean;
|
|
105
|
+
readonly disabled: boolean;
|
|
106
|
+
click(): void;
|
|
107
|
+
}
|
|
108
|
+
const buttons: ButtonStub[] = [];
|
|
109
|
+
|
|
110
|
+
const UButton: Component = {
|
|
111
|
+
name: "UButton",
|
|
112
|
+
props: { loading: Boolean, disabled: Boolean },
|
|
113
|
+
emits: ["click"],
|
|
114
|
+
setup(
|
|
115
|
+
props: { loading?: boolean; disabled?: boolean },
|
|
116
|
+
{ emit, slots }: SetupContext<["click"]>,
|
|
117
|
+
) {
|
|
118
|
+
const stub: ButtonStub = {
|
|
119
|
+
get label() {
|
|
120
|
+
return slotText(slots.default?.());
|
|
121
|
+
},
|
|
122
|
+
get loading() {
|
|
123
|
+
return props.loading ?? false;
|
|
124
|
+
},
|
|
125
|
+
get disabled() {
|
|
126
|
+
return props.disabled ?? false;
|
|
127
|
+
},
|
|
128
|
+
click() {
|
|
129
|
+
if (stub.loading) return;
|
|
130
|
+
if (stub.disabled) return;
|
|
131
|
+
emit("click");
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
buttons.push(stub);
|
|
135
|
+
onUnmounted(() => {
|
|
136
|
+
buttons.splice(buttons.indexOf(stub), 1);
|
|
137
|
+
});
|
|
138
|
+
return () => h("button", null, slots.default?.());
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// The language switch the detail renders, with what it was given.
|
|
143
|
+
let langSwitch: { readonly langs: string[]; readonly value: string } | null =
|
|
144
|
+
null;
|
|
145
|
+
|
|
146
|
+
const stubs: Record<string, Component> = {
|
|
147
|
+
UButton,
|
|
148
|
+
UCard: passthrough("UCard"),
|
|
149
|
+
UAlert: passthrough("UAlert"),
|
|
150
|
+
UIcon: passthrough("UIcon"),
|
|
151
|
+
UModal: passthrough("UModal"),
|
|
152
|
+
MapoForm: {
|
|
153
|
+
name: "MapoForm",
|
|
154
|
+
props: { notifyErrors: { type: Boolean, default: true } },
|
|
155
|
+
setup(props: { notifyErrors?: boolean }, { slots }: SetupContext) {
|
|
156
|
+
const formProps = { notifyErrors: props.notifyErrors ?? true };
|
|
157
|
+
mapoFormProps.push(formProps);
|
|
158
|
+
onUnmounted(() => {
|
|
159
|
+
mapoFormProps.splice(mapoFormProps.indexOf(formProps), 1);
|
|
160
|
+
});
|
|
161
|
+
return () => h("div", null, slots.default?.());
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
MapoDetailLangSwitch: {
|
|
165
|
+
name: "MapoDetailLangSwitch",
|
|
166
|
+
props: { modelValue: String, langs: Array },
|
|
167
|
+
setup(props: { modelValue?: string; langs?: string[] }) {
|
|
168
|
+
langSwitch = {
|
|
169
|
+
get langs() {
|
|
170
|
+
return props.langs ?? [];
|
|
171
|
+
},
|
|
172
|
+
get value() {
|
|
173
|
+
return props.modelValue ?? "";
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
onUnmounted(() => {
|
|
177
|
+
langSwitch = null;
|
|
178
|
+
});
|
|
179
|
+
return () => h("div");
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const button = (label: string) => {
|
|
185
|
+
const found = buttons.find((stub) => stub.label === label);
|
|
186
|
+
if (!found) throw new Error(`no button ${label}`);
|
|
187
|
+
return found;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/** What a custom action panel reads from the `side-buttons` slot. */
|
|
191
|
+
interface ActionBindings {
|
|
192
|
+
isSaving: boolean;
|
|
193
|
+
save: (andBack?: boolean) => Promise<void>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
let app: App<HeadlessNode> | undefined;
|
|
197
|
+
|
|
198
|
+
function mountDetail(
|
|
199
|
+
slots: Record<string, (bindings: never) => VNode[]> = {},
|
|
200
|
+
props: Record<string, unknown> = {},
|
|
201
|
+
) {
|
|
202
|
+
const root: Component = {
|
|
203
|
+
render: () =>
|
|
204
|
+
h(
|
|
205
|
+
MapoDetail as Component,
|
|
206
|
+
{ endpoint: "/api/news/", id: 5, ...props },
|
|
207
|
+
slots,
|
|
208
|
+
),
|
|
209
|
+
};
|
|
210
|
+
app = createApp(root);
|
|
211
|
+
for (const [name, stub] of Object.entries(stubs)) app.component(name, stub);
|
|
212
|
+
app.mount(headlessNode());
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Runs the pending CRUD promises and the renders they trigger.
|
|
216
|
+
const settle = () => new Promise((resolve) => setTimeout(resolve));
|
|
217
|
+
|
|
218
|
+
const afterEachHooks = new Set<AfterEachHook>();
|
|
219
|
+
|
|
220
|
+
/** Ends the navigation router.back() started; `failure` as Vue Router reports it. */
|
|
221
|
+
const finishNavigation = (failure?: Error) => {
|
|
222
|
+
for (const hook of [...afterEachHooks]) hook({}, {}, failure);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const record = { id: 5, title: "News" };
|
|
226
|
+
|
|
227
|
+
beforeEach(() => {
|
|
228
|
+
runtimeConfig.public.mapoUikit.contentLanguages = [];
|
|
229
|
+
router.back.mockReset();
|
|
230
|
+
router.replace.mockReset();
|
|
231
|
+
router.afterEach.mockReset();
|
|
232
|
+
router.afterEach.mockImplementation((hook) => {
|
|
233
|
+
afterEachHooks.add(hook);
|
|
234
|
+
return () => afterEachHooks.delete(hook);
|
|
235
|
+
});
|
|
236
|
+
router.options.history.state.back = "/news";
|
|
237
|
+
afterEachHooks.clear();
|
|
238
|
+
for (const fn of Object.values(crud)) fn.mockReset();
|
|
239
|
+
crud.options.mockResolvedValue({});
|
|
240
|
+
crud.detail.mockResolvedValue(record);
|
|
241
|
+
crud.partialUpdate.mockResolvedValue(record);
|
|
242
|
+
crud.delete.mockResolvedValue(undefined);
|
|
243
|
+
confirm.ask.mockReset();
|
|
244
|
+
confirm.ask.mockResolvedValue(true);
|
|
245
|
+
mapoFormProps.length = 0;
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
afterEach(() => {
|
|
249
|
+
app?.unmount();
|
|
250
|
+
app = undefined;
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
describe("MapoDetail actions", () => {
|
|
254
|
+
it("shows server error toasts only from the main form when sidebar fields are present", async () => {
|
|
255
|
+
mountDetail(
|
|
256
|
+
{},
|
|
257
|
+
{
|
|
258
|
+
fields: [{ key: "title", type: "text" }],
|
|
259
|
+
sidebarFields: [{ key: "slug", type: "text" }],
|
|
260
|
+
},
|
|
261
|
+
);
|
|
262
|
+
await settle();
|
|
263
|
+
|
|
264
|
+
expect(mapoFormProps).toHaveLength(2);
|
|
265
|
+
expect(mapoFormProps.map(({ notifyErrors }) => notifyErrors)).toEqual([
|
|
266
|
+
true,
|
|
267
|
+
false,
|
|
268
|
+
]);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it("keeps the buttons busy until the page has gone back after Save", async () => {
|
|
272
|
+
mountDetail();
|
|
273
|
+
await settle();
|
|
274
|
+
|
|
275
|
+
button("mapo.save").click();
|
|
276
|
+
await settle();
|
|
277
|
+
|
|
278
|
+
expect(crud.partialUpdate).toHaveBeenCalledTimes(1);
|
|
279
|
+
expect(router.back).toHaveBeenCalledTimes(1);
|
|
280
|
+
// The page is still on screen while the previous route loads.
|
|
281
|
+
expect(button("mapo.save").loading).toBe(true);
|
|
282
|
+
expect(button("mapo.saveContinue").disabled).toBe(true);
|
|
283
|
+
expect(button("mapo.back").disabled).toBe(true);
|
|
284
|
+
expect(button("mapo.delete").disabled).toBe(true);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it("frees the buttons when the navigation back is cancelled", async () => {
|
|
288
|
+
mountDetail();
|
|
289
|
+
await settle();
|
|
290
|
+
button("mapo.save").click();
|
|
291
|
+
await settle();
|
|
292
|
+
|
|
293
|
+
// A guard kept the page, such as the unsaved-changes one.
|
|
294
|
+
finishNavigation(new Error("aborted"));
|
|
295
|
+
await settle();
|
|
296
|
+
|
|
297
|
+
expect(button("mapo.save").loading).toBe(false);
|
|
298
|
+
expect(button("mapo.back").disabled).toBe(false);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it("saves once and stays busy when a custom button saves twice", async () => {
|
|
302
|
+
let bindings: ActionBindings | undefined;
|
|
303
|
+
mountDetail({
|
|
304
|
+
"side-buttons": (slotProps: ActionBindings) => {
|
|
305
|
+
bindings = slotProps;
|
|
306
|
+
return [];
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
await settle();
|
|
310
|
+
|
|
311
|
+
void bindings?.save(true);
|
|
312
|
+
void bindings?.save(true);
|
|
313
|
+
await settle();
|
|
314
|
+
|
|
315
|
+
expect(crud.partialUpdate).toHaveBeenCalledTimes(1);
|
|
316
|
+
expect(router.back).toHaveBeenCalledTimes(1);
|
|
317
|
+
expect(bindings?.isSaving).toBe(true);
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it("goes back once when Back is clicked twice", async () => {
|
|
321
|
+
mountDetail();
|
|
322
|
+
await settle();
|
|
323
|
+
|
|
324
|
+
button("mapo.back").click();
|
|
325
|
+
button("mapo.back").click();
|
|
326
|
+
await settle();
|
|
327
|
+
|
|
328
|
+
expect(router.back).toHaveBeenCalledTimes(1);
|
|
329
|
+
expect(button("mapo.back").loading).toBe(true);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it("does not lock the buttons when there is no previous page", async () => {
|
|
333
|
+
router.options.history.state.back = null;
|
|
334
|
+
mountDetail();
|
|
335
|
+
await settle();
|
|
336
|
+
|
|
337
|
+
button("mapo.save").click();
|
|
338
|
+
await settle();
|
|
339
|
+
|
|
340
|
+
expect(router.back).toHaveBeenCalledTimes(1);
|
|
341
|
+
expect(button("mapo.save").loading).toBe(false);
|
|
342
|
+
expect(button("mapo.back").disabled).toBe(false);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it("keeps Delete busy until the page has gone back", async () => {
|
|
346
|
+
mountDetail();
|
|
347
|
+
await settle();
|
|
348
|
+
|
|
349
|
+
button("mapo.delete").click();
|
|
350
|
+
await settle();
|
|
351
|
+
button("mapo.delete").click();
|
|
352
|
+
await settle();
|
|
353
|
+
|
|
354
|
+
expect(crud.delete).toHaveBeenCalledTimes(1);
|
|
355
|
+
expect(confirm.ask).toHaveBeenCalledTimes(1);
|
|
356
|
+
expect(button("mapo.delete").loading).toBe(true);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
describe("MapoDetail content languages", () => {
|
|
361
|
+
it("keeps only the app's content languages, and hides a single one", async () => {
|
|
362
|
+
runtimeConfig.public.mapoUikit.contentLanguages = ["it"];
|
|
363
|
+
mountDetail({}, { languages: ["it", "en"] });
|
|
364
|
+
await settle();
|
|
365
|
+
|
|
366
|
+
expect(langSwitch).toBeNull();
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it("follows the app's order, so its first language is the starting one", async () => {
|
|
370
|
+
runtimeConfig.public.mapoUikit.contentLanguages = ["en", "it"];
|
|
371
|
+
mountDetail({}, { languages: ["it", "en"] });
|
|
372
|
+
await settle();
|
|
373
|
+
|
|
374
|
+
expect(langSwitch?.langs).toEqual(["en", "it"]);
|
|
375
|
+
expect(langSwitch?.value).toBe("en");
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it("never adds a language the page does not declare", async () => {
|
|
379
|
+
runtimeConfig.public.mapoUikit.contentLanguages = ["it", "de"];
|
|
380
|
+
mountDetail({}, { languages: ["it", "en"] });
|
|
381
|
+
await settle();
|
|
382
|
+
|
|
383
|
+
expect(langSwitch).toBeNull();
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it("lets forceLanguages bypass it", async () => {
|
|
387
|
+
runtimeConfig.public.mapoUikit.contentLanguages = ["it"];
|
|
388
|
+
mountDetail({}, { languages: ["it", "en"], forceLanguages: ["it", "en"] });
|
|
389
|
+
await settle();
|
|
390
|
+
|
|
391
|
+
expect(langSwitch?.langs).toEqual(["it", "en"]);
|
|
392
|
+
});
|
|
393
|
+
});
|