@n8n/frontend-module-inbox 0.0.0-stage → 0.1.0
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/LICENSE.md +88 -0
- package/README.md +59 -2
- package/biome.jsonc +4 -0
- package/eslint.config.mjs +4 -0
- package/package.json +62 -3
- package/src/__tests__/design-system-icons.test.ts +24 -0
- package/src/__tests__/setup.ts +4 -0
- package/src/components/InboxEmptyState.vue +86 -0
- package/src/components/InboxList.test.ts +229 -0
- package/src/components/InboxList.vue +195 -0
- package/src/components/InboxListItem.vue +134 -0
- package/src/components/InboxListSection.vue +168 -0
- package/src/composables/useReviewInboxSectionCollapse.test.ts +66 -0
- package/src/composables/useReviewInboxSectionCollapse.ts +42 -0
- package/src/inbox.api.ts +20 -0
- package/src/inbox.constants.ts +16 -0
- package/src/inbox.module.ts +50 -0
- package/src/inbox.routes.test.ts +111 -0
- package/src/inbox.routes.ts +30 -0
- package/src/inbox.store.test.ts +349 -0
- package/src/inbox.store.ts +305 -0
- package/src/index.ts +5 -0
- package/src/reviews/WorkflowReviewDetail.test.ts +647 -0
- package/src/reviews/WorkflowReviewDetail.vue +257 -0
- package/src/reviews/components/WorkflowReviewActivityFeed.test.ts +923 -0
- package/src/reviews/components/WorkflowReviewActivityFeed.vue +312 -0
- package/src/reviews/components/WorkflowReviewChangesSection.test.ts +327 -0
- package/src/reviews/components/WorkflowReviewChangesSection.vue +219 -0
- package/src/reviews/components/WorkflowReviewCommentComposer.test.ts +175 -0
- package/src/reviews/components/WorkflowReviewCommentComposer.vue +83 -0
- package/src/reviews/components/WorkflowReviewDecisionPopover.test.ts +288 -0
- package/src/reviews/components/WorkflowReviewDecisionPopover.vue +203 -0
- package/src/reviews/components/WorkflowReviewDetailMetadata.test.ts +206 -0
- package/src/reviews/components/WorkflowReviewDetailMetadata.vue +241 -0
- package/src/reviews/components/WorkflowReviewDetailTabs.decisionNote.test.ts +90 -0
- package/src/reviews/components/WorkflowReviewDetailTabs.test.ts +434 -0
- package/src/reviews/components/WorkflowReviewDetailTabs.vue +311 -0
- package/src/reviews/components/WorkflowReviewStatusDot.vue +67 -0
- package/src/reviews/components/_activity-card.scss +36 -0
- package/src/reviews/components/activity-entries/WorkflowReviewActivityActorAvatar.vue +50 -0
- package/src/reviews/components/activity-entries/WorkflowReviewActivityComment.test.ts +103 -0
- package/src/reviews/components/activity-entries/WorkflowReviewActivityComment.vue +116 -0
- package/src/reviews/components/activity-entries/WorkflowReviewActivityEventEntry.vue +361 -0
- package/src/reviews/components/activity-entries/WorkflowReviewActivityFallback.vue +49 -0
- package/src/reviews/components/activity-entries/WorkflowReviewActivityWorkflowLink.vue +36 -0
- package/src/reviews/components/activityEntryRegistry.ts +27 -0
- package/src/reviews/constants.ts +41 -0
- package/src/reviews/reviewActivity.store.test.ts +463 -0
- package/src/reviews/reviewActivity.store.ts +186 -0
- package/src/reviews/reviewDetail.store.test.ts +135 -0
- package/src/reviews/reviewDetail.store.ts +74 -0
- package/src/reviews/workflowReviewStatus.utils.ts +44 -0
- package/src/reviews/workflowReviews.api.ts +61 -0
- package/src/reviews/workflowReviews.utils.ts +18 -0
- package/src/views/InboxView.test.ts +525 -0
- package/src/views/InboxView.vue +251 -0
- package/stylelint.config.mjs +9 -0
- package/vite.config.ts +52 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
Portions of this software are licensed as follows:
|
|
4
|
+
|
|
5
|
+
- Content of branches other than the main branch (i.e. "master") are not licensed.
|
|
6
|
+
- Source code files that contain ".ee." in their filename or ".ee" in their dirname are NOT licensed under
|
|
7
|
+
the Sustainable Use License.
|
|
8
|
+
To use source code files that contain ".ee." in their filename or ".ee" in their dirname you must hold a
|
|
9
|
+
valid n8n Enterprise License specifically allowing you access to such source code files and as defined
|
|
10
|
+
in "LICENSE_EE.md".
|
|
11
|
+
- All third party components incorporated into the n8n Software are licensed under the original license
|
|
12
|
+
provided by the owner of the applicable component.
|
|
13
|
+
- Content outside of the above mentioned files or restrictions is available under the "Sustainable Use
|
|
14
|
+
License" as defined below.
|
|
15
|
+
|
|
16
|
+
## Sustainable Use License
|
|
17
|
+
|
|
18
|
+
Version 1.0
|
|
19
|
+
|
|
20
|
+
### Acceptance
|
|
21
|
+
|
|
22
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
23
|
+
|
|
24
|
+
### Copyright License
|
|
25
|
+
|
|
26
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
|
|
27
|
+
to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
|
|
28
|
+
to the limitations below.
|
|
29
|
+
|
|
30
|
+
### Limitations
|
|
31
|
+
|
|
32
|
+
You may use or modify the software only for your own internal business purposes or for non-commercial or
|
|
33
|
+
personal use. You may distribute the software or provide it to others only if you do so free of charge for
|
|
34
|
+
non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
|
|
35
|
+
the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
36
|
+
|
|
37
|
+
### Patents
|
|
38
|
+
|
|
39
|
+
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
|
|
40
|
+
license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
|
|
41
|
+
subject to the limitations and conditions in this license. This license does not cover any patent claims that
|
|
42
|
+
you cause to be infringed by modifications or additions to the software. If you or your company make any
|
|
43
|
+
written claim that the software infringes or contributes to infringement of any patent, your patent license
|
|
44
|
+
for the software granted under these terms ends immediately. If your company makes such a claim, your patent
|
|
45
|
+
license ends immediately for work on behalf of your company.
|
|
46
|
+
|
|
47
|
+
### Notices
|
|
48
|
+
|
|
49
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
|
|
50
|
+
terms. If you modify the software, you must include in any modified copies of the software a prominent notice
|
|
51
|
+
stating that you have modified the software.
|
|
52
|
+
|
|
53
|
+
### No Other Rights
|
|
54
|
+
|
|
55
|
+
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
56
|
+
|
|
57
|
+
### Termination
|
|
58
|
+
|
|
59
|
+
If you use the software in violation of these terms, such use is not licensed, and your license will
|
|
60
|
+
automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
|
|
61
|
+
violation of this license no later than 30 days after you receive that notice, your license will be reinstated
|
|
62
|
+
retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
|
|
63
|
+
terms will cause your license to terminate automatically and permanently.
|
|
64
|
+
|
|
65
|
+
### No Liability
|
|
66
|
+
|
|
67
|
+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
|
|
68
|
+
not be liable to you for any damages arising out of these terms or the use or nature of the software, under
|
|
69
|
+
any kind of legal claim.
|
|
70
|
+
|
|
71
|
+
### Definitions
|
|
72
|
+
|
|
73
|
+
The “licensor” is the entity offering these terms.
|
|
74
|
+
|
|
75
|
+
The “software” is the software the licensor makes available under these terms, including any portion of it.
|
|
76
|
+
|
|
77
|
+
“You” refers to the individual or entity agreeing to these terms.
|
|
78
|
+
|
|
79
|
+
“Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
|
|
80
|
+
all organizations that have control over, are under the control of, or are under common control with that
|
|
81
|
+
organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
|
|
82
|
+
management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
83
|
+
|
|
84
|
+
“Your license” is the license granted to you for the software under these terms.
|
|
85
|
+
|
|
86
|
+
“Use” means anything you do with the software requiring your license.
|
|
87
|
+
|
|
88
|
+
“Trademark” means trademarks, service marks, and similar rights.
|
package/README.md
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @n8n/frontend-module-inbox
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The shared Inbox lists workflow reviews. Review details, comments, and decisions live in `src/reviews`. The editor supplies only the workflow diff renderer through the SDK component registry. Backend services keep their existing access rules and actions.
|
|
4
|
+
|
|
5
|
+
Open has two groups: Waiting for review and Authored by you. Each group has its
|
|
6
|
+
own cursor, Load more button, and retry.
|
|
7
|
+
Closed is a flat list with infinite scroll. Group collapse state persists per user.
|
|
8
|
+
|
|
9
|
+
Review decisions update the loaded rows and counts in place. Approving a selected
|
|
10
|
+
review opens the Closed tab, as before.
|
|
11
|
+
|
|
12
|
+
Frontend feature module. Consumed from source by the editor-ui shell through
|
|
13
|
+
`src/app/modules.manifest.ts`; there is no build step and no `dist`.
|
|
14
|
+
|
|
15
|
+
Read the full guide at `packages/@n8n/module-cli/frontend-module-guide.md`. It gives the
|
|
16
|
+
descriptor contract, the registration points and the known problems. This README gives a
|
|
17
|
+
summary only.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm turbo typecheck --filter=@n8n/frontend-module-inbox
|
|
21
|
+
pnpm turbo lint --filter=@n8n/frontend-module-inbox
|
|
22
|
+
pnpm turbo lint:styles --filter=@n8n/frontend-module-inbox
|
|
23
|
+
pnpm turbo test --filter=@n8n/frontend-module-inbox
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Go through turbo, not `pnpm --filter <pkg> typecheck`: this package is consumed
|
|
27
|
+
from source, and on a cold tree its platform dependencies have not been built
|
|
28
|
+
yet. Turbo builds them first; the bare pnpm form does not.
|
|
29
|
+
|
|
30
|
+
## Import rules
|
|
31
|
+
|
|
32
|
+
- Depend on foundation and platform packages only (`@n8n/design-system`,
|
|
33
|
+
`@n8n/stores`, `@n8n/composables`, `@n8n/i18n`, `@n8n/rest-api-client`,
|
|
34
|
+
`@n8n/api-types`, `@n8n/permissions`, `@n8n/frontend-constants`, `n8n-workflow`,
|
|
35
|
+
`@n8n/frontend-module-sdk`). Never import another
|
|
36
|
+
`@n8n/frontend-module-*`, and never import `@/…` from the shell.
|
|
37
|
+
- `@n8n/stores` and `@n8n/composables` are **subpath-only** — import
|
|
38
|
+
`@n8n/stores/settings.store`, not `@n8n/stores`.
|
|
39
|
+
- The no-cross-module rule is currently a convention: the shared tsconfig base
|
|
40
|
+
omits sibling modules from `paths`, which blocks an accidental import but not
|
|
41
|
+
a deliberate one (declaring the dependency makes it typecheck clean). The
|
|
42
|
+
ESLint rule that actually enforces it is CAT-3692.
|
|
43
|
+
|
|
44
|
+
## Adding UI
|
|
45
|
+
|
|
46
|
+
`vite.config.ts` already carries the three plugins a design-system consumer
|
|
47
|
+
needs, so a `.vue` file compiles in tests without further setup:
|
|
48
|
+
|
|
49
|
+
- `@vitejs/plugin-vue` — single-file components.
|
|
50
|
+
- `unplugin-icons` — the `~icons/lucide/*` virtual modules behind `N8nIcon`.
|
|
51
|
+
- `vite-svg-loader` — design-system's `custom/*.svg` icon components. Without
|
|
52
|
+
it an `.svg` import is a data-URI string, which Vue renders as a tag name.
|
|
53
|
+
|
|
54
|
+
`src/__tests__/design-system-icons.test.ts` renders one icon of each kind, so a
|
|
55
|
+
plugin dropped from `vite.config.ts` fails this package's own suite. Keep that
|
|
56
|
+
test while the module renders any design-system component.
|
|
57
|
+
|
|
58
|
+
SCSS goes in a scoped `<style lang="scss">` block, with tokens from
|
|
59
|
+
design-system — `stylelint.config.mjs` holds this package to the same rules the
|
|
60
|
+
shell uses. Route components must load lazily.
|
package/biome.jsonc
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/frontend-module-inbox",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/index.ts"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@n8n/api-types": "1.44.0",
|
|
11
|
+
"@n8n/composables": "1.34.0",
|
|
12
|
+
"@n8n/design-system": "2.43.0",
|
|
13
|
+
"@n8n/frontend-module-sdk": "0.14.0",
|
|
14
|
+
"@n8n/i18n": "2.44.0",
|
|
15
|
+
"@n8n/rest-api-client": "2.44.0",
|
|
16
|
+
"@n8n/stores": "2.44.0",
|
|
17
|
+
"n8n-workflow": "2.44.0",
|
|
18
|
+
"pinia": "^2.2.4",
|
|
19
|
+
"vue": "^3.5.13",
|
|
20
|
+
"vue-router": "^4.5.0",
|
|
21
|
+
"@n8n/frontend-constants": "0.10.0",
|
|
22
|
+
"@vueuse/core": "^14.3.0",
|
|
23
|
+
"lodash": "4.18.1",
|
|
24
|
+
"vue-i18n": "^11.4.4"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@iconify/json": "^2.2.488",
|
|
28
|
+
"@n8n/eslint-config": "0.0.1",
|
|
29
|
+
"@n8n/frontend-test-utils": "0.1.0",
|
|
30
|
+
"@n8n/frontend-vite-config": "0.1.0",
|
|
31
|
+
"@n8n/playwright-janitor": "0.1.0",
|
|
32
|
+
"@n8n/stylelint-config": "0.0.1",
|
|
33
|
+
"@n8n/typescript-config": "1.12.0",
|
|
34
|
+
"@n8n/vitest-config": "1.24.0",
|
|
35
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
36
|
+
"@testing-library/vue": "^8.1.0",
|
|
37
|
+
"@vitejs/plugin-vue": "^6.0.8",
|
|
38
|
+
"eslint": "9.29.0",
|
|
39
|
+
"stylelint": "^16.23.0",
|
|
40
|
+
"typescript": "6.0.2",
|
|
41
|
+
"unplugin-icons": "^23.0.1",
|
|
42
|
+
"vite": "^8.0.2",
|
|
43
|
+
"vite-svg-loader": "5.1.0",
|
|
44
|
+
"vitest": "5.0.1",
|
|
45
|
+
"vue-tsc": "^2.2.8",
|
|
46
|
+
"@pinia/testing": "^0.1.6",
|
|
47
|
+
"@testing-library/user-event": "^14.6.1",
|
|
48
|
+
"@types/lodash": "4.17.17",
|
|
49
|
+
"@n8n/utils": "1.51.0"
|
|
50
|
+
},
|
|
51
|
+
"license": "LicenseRef-n8n-sustainable-use",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"clean": "rimraf .turbo",
|
|
54
|
+
"typecheck": "vue-tsc --noEmit",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:changed": "janitor test-scoped",
|
|
57
|
+
"test:dev": "vitest",
|
|
58
|
+
"lint": "eslint src --quiet",
|
|
59
|
+
"lint:fix": "eslint src --fix",
|
|
60
|
+
"lint:styles": "stylelint \"src/**/*.{scss,sass,vue}\" --cache --allow-empty-input",
|
|
61
|
+
"lint:styles:fix": "stylelint \"src/**/*.{scss,sass,vue}\" --fix --cache --allow-empty-input",
|
|
62
|
+
"format": "biome format --write . && prettier --write . --ignore-path ../../../../.prettierignore",
|
|
63
|
+
"format:check": "biome ci . && prettier --check . --ignore-path ../../../../.prettierignore"
|
|
64
|
+
}
|
|
6
65
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { N8nIcon } from '@n8n/design-system';
|
|
2
|
+
import { render } from '@testing-library/vue';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A build-config test, not a feature test. `@n8n/design-system` is consumed from source, so its
|
|
6
|
+
* two icon mechanisms are this package's problem, and each package carries its own
|
|
7
|
+
* `vite.config.ts`. Both cases fail loudly when a plugin goes missing from that file:
|
|
8
|
+
*
|
|
9
|
+
* - `box` comes from `~icons/lucide/box`, which only `unplugin-icons` resolves.
|
|
10
|
+
* - `webhook` comes from `custom/webhook.svg`, which only `svgLoader` turns into a component.
|
|
11
|
+
* Without it the import is a data-URI string, which Vue renders as a tag name.
|
|
12
|
+
*
|
|
13
|
+
* Keep this test while the module renders any design-system component.
|
|
14
|
+
*/
|
|
15
|
+
describe('design-system icons', () => {
|
|
16
|
+
it.each([
|
|
17
|
+
['a lucide icon', 'box'],
|
|
18
|
+
['a custom svg icon', 'webhook'],
|
|
19
|
+
])('renders %s', (_case, icon) => {
|
|
20
|
+
const { container } = render(N8nIcon, { props: { icon } });
|
|
21
|
+
|
|
22
|
+
expect(container.querySelector('svg')).not.toBeNull();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// The shared frontend test harness: the jsdom environment, english messages, and a fresh pinia
|
|
2
|
+
// per test. It lives in `@n8n/frontend-test-utils` rather than in `@n8n/vitest-config`, because
|
|
3
|
+
// `@n8n/i18n` devDepends on the latter and importing i18n there closes a cycle in the turbo graph.
|
|
4
|
+
import '@n8n/frontend-test-utils/setup';
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { N8nEmptyState, N8nLoading, type EmptyStateIconCards } from '@n8n/design-system';
|
|
3
|
+
import { useI18n } from '@n8n/i18n';
|
|
4
|
+
import { storeToRefs } from 'pinia';
|
|
5
|
+
import { computed } from 'vue';
|
|
6
|
+
|
|
7
|
+
import { useInboxStore } from '../inbox.store';
|
|
8
|
+
|
|
9
|
+
const store = useInboxStore();
|
|
10
|
+
const {
|
|
11
|
+
activeTab,
|
|
12
|
+
hasItems,
|
|
13
|
+
loading,
|
|
14
|
+
initialLoadFailed,
|
|
15
|
+
partial,
|
|
16
|
+
isEmpty,
|
|
17
|
+
openCount,
|
|
18
|
+
closedCount,
|
|
19
|
+
} = storeToRefs(store);
|
|
20
|
+
const i18n = useI18n();
|
|
21
|
+
const alertIcon = { type: 'icon', value: 'circle-alert' } as const;
|
|
22
|
+
const inboxIcon: EmptyStateIconCards = {
|
|
23
|
+
type: 'cards',
|
|
24
|
+
center: 'message-square-text',
|
|
25
|
+
sides: ['file-diff', 'git-branch', 'circle-check', 'list', 'message-square'],
|
|
26
|
+
};
|
|
27
|
+
const noSelectionHeading = computed(() => {
|
|
28
|
+
const count = activeTab.value === 'closed' ? closedCount.value : openCount.value;
|
|
29
|
+
if (count === null) return i18n.baseText(`inbox.items.${activeTab.value}`);
|
|
30
|
+
return i18n.baseText(`inbox.noSelection.title.${activeTab.value}`, {
|
|
31
|
+
adjustToNumber: count,
|
|
32
|
+
interpolate: { count: String(count) },
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<N8nLoading v-if="loading" :loading="true" :rows="3" />
|
|
39
|
+
<div v-else :class="$style.emptyStateWrapper">
|
|
40
|
+
<N8nEmptyState
|
|
41
|
+
v-if="initialLoadFailed && !hasItems"
|
|
42
|
+
:class="$style.emptyState"
|
|
43
|
+
:icon="alertIcon"
|
|
44
|
+
:heading="i18n.baseText('workflowReviews.error.load')"
|
|
45
|
+
:button-text="i18n.baseText('generic.retry')"
|
|
46
|
+
@click:button="store.fetchActiveTab()"
|
|
47
|
+
/>
|
|
48
|
+
<N8nEmptyState
|
|
49
|
+
v-else-if="partial && !hasItems"
|
|
50
|
+
:class="$style.emptyState"
|
|
51
|
+
:icon="alertIcon"
|
|
52
|
+
:heading="i18n.baseText('inbox.partial')"
|
|
53
|
+
:button-text="i18n.baseText('generic.retry')"
|
|
54
|
+
@click:button="store.refreshListAndSummary()"
|
|
55
|
+
/>
|
|
56
|
+
<N8nEmptyState
|
|
57
|
+
v-else-if="isEmpty"
|
|
58
|
+
:class="$style.emptyState"
|
|
59
|
+
:icon="inboxIcon"
|
|
60
|
+
:heading="i18n.baseText(activeTab === 'open' ? 'inbox.empty.open' : 'inbox.empty.closed')"
|
|
61
|
+
:description="i18n.baseText(`inbox.empty.body.${activeTab}`)"
|
|
62
|
+
data-test-id="inbox-empty"
|
|
63
|
+
/>
|
|
64
|
+
<N8nEmptyState
|
|
65
|
+
v-else-if="hasItems"
|
|
66
|
+
:class="$style.emptyState"
|
|
67
|
+
:icon="inboxIcon"
|
|
68
|
+
:heading="noSelectionHeading"
|
|
69
|
+
:description="i18n.baseText('inbox.noSelection.body')"
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<style lang="scss" module>
|
|
75
|
+
.emptyStateWrapper {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
height: 100%;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.emptyStateWrapper .emptyState {
|
|
83
|
+
border: none;
|
|
84
|
+
padding: 0;
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import type { InboxWorkflowReviewItem } from '@n8n/api-types';
|
|
2
|
+
import { createComponentRenderer } from '@n8n/frontend-test-utils';
|
|
3
|
+
import { useUsersStore } from '@n8n/stores/users.store';
|
|
4
|
+
import { fireEvent, within } from '@testing-library/vue';
|
|
5
|
+
import { useIntersectionObserver } from '@vueuse/core';
|
|
6
|
+
|
|
7
|
+
import InboxList from './InboxList.vue';
|
|
8
|
+
import type { InboxListSection } from './InboxListSection.vue';
|
|
9
|
+
|
|
10
|
+
vi.mock('@vueuse/core', async (importOriginal) => ({
|
|
11
|
+
...(await importOriginal<typeof import('@vueuse/core')>()),
|
|
12
|
+
useIntersectionObserver: vi.fn(),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
function section(
|
|
16
|
+
key: InboxListSection['key'],
|
|
17
|
+
props: Partial<InboxListSection> = {},
|
|
18
|
+
): InboxListSection {
|
|
19
|
+
return {
|
|
20
|
+
key,
|
|
21
|
+
items: [],
|
|
22
|
+
loading: false,
|
|
23
|
+
loadingMore: false,
|
|
24
|
+
hasMore: false,
|
|
25
|
+
error: null,
|
|
26
|
+
failedRequest: null,
|
|
27
|
+
partial: false,
|
|
28
|
+
...props,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function review(): InboxWorkflowReviewItem {
|
|
32
|
+
return {
|
|
33
|
+
type: 'workflow_review',
|
|
34
|
+
id: 'review',
|
|
35
|
+
state: 'open',
|
|
36
|
+
decision: 'pending',
|
|
37
|
+
projectId: 'project',
|
|
38
|
+
title: 'Review my workflow',
|
|
39
|
+
workflowName: 'My workflow',
|
|
40
|
+
workflowVersionId: null,
|
|
41
|
+
requester: null,
|
|
42
|
+
authors: [],
|
|
43
|
+
reviewers: [],
|
|
44
|
+
createdAt: '2026-01-01T00:00:00.000Z',
|
|
45
|
+
updatedAt: '2026-01-01T00:00:00.000Z',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const renderComponent = createComponentRenderer(InboxList, {
|
|
49
|
+
props: {
|
|
50
|
+
sections: [section('waiting'), section('authored')],
|
|
51
|
+
activeTab: 'open',
|
|
52
|
+
selectedKey: null,
|
|
53
|
+
openCount: null,
|
|
54
|
+
closedCount: null,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
beforeEach(() => localStorage.clear());
|
|
58
|
+
function intersect(isIntersecting = true) {
|
|
59
|
+
const onIntersect = vi.mocked(useIntersectionObserver).mock.calls.at(-1)![1];
|
|
60
|
+
onIntersect([{ isIntersecting } as IntersectionObserverEntry], {} as IntersectionObserver);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
it('shows one initial skeleton without empty group headers', () => {
|
|
64
|
+
const { getAllByTestId, queryByTestId } = renderComponent({
|
|
65
|
+
props: {
|
|
66
|
+
sections: [section('waiting', { loading: true }), section('authored', { loading: true })],
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
expect(getAllByTestId('inbox-list-skeleton')).toHaveLength(1);
|
|
70
|
+
expect(queryByTestId('inbox-section-header')).not.toBeInTheDocument();
|
|
71
|
+
});
|
|
72
|
+
it('offers one retry when the first load fails without rows', () => {
|
|
73
|
+
const { getAllByRole, queryByTestId, emitted } = renderComponent({
|
|
74
|
+
props: {
|
|
75
|
+
sections: [
|
|
76
|
+
section('waiting', { error: new Error('Request failed'), failedRequest: 'list' }),
|
|
77
|
+
section('authored', { error: new Error('Request failed'), failedRequest: 'list' }),
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const buttons = getAllByRole('button', { name: 'Retry' });
|
|
82
|
+
expect(buttons).toHaveLength(1);
|
|
83
|
+
buttons[0].click();
|
|
84
|
+
expect(emitted('retryActiveTab')).toEqual([[]]);
|
|
85
|
+
expect(queryByTestId('inbox-section-header')).not.toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
it('retries the failed page after all loaded rows leave the list', () => {
|
|
88
|
+
const { getByRole, emitted } = renderComponent({
|
|
89
|
+
props: {
|
|
90
|
+
sections: [
|
|
91
|
+
section('waiting', {
|
|
92
|
+
hasMore: true,
|
|
93
|
+
error: new Error('Page failed'),
|
|
94
|
+
failedRequest: 'loadMore',
|
|
95
|
+
}),
|
|
96
|
+
section('authored'),
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
getByRole('button', { name: 'Retry' }).click();
|
|
101
|
+
expect(emitted('retry')).toEqual([['waiting']]);
|
|
102
|
+
expect(emitted('retryActiveTab')).toBeUndefined();
|
|
103
|
+
expect(getByRole('button', { name: 'Waiting for your review' })).toBeInTheDocument();
|
|
104
|
+
});
|
|
105
|
+
it('keeps healthy rows visible beside a failed group', () => {
|
|
106
|
+
const { queryByRole, getByRole, emitted } = renderComponent({
|
|
107
|
+
props: {
|
|
108
|
+
sections: [
|
|
109
|
+
section('waiting', { items: [review()] }),
|
|
110
|
+
section('authored', { error: new Error('Request failed') }),
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
expect(getByRole('option')).toHaveTextContent('Review my workflow');
|
|
115
|
+
getByRole('button', { name: 'Retry' }).click();
|
|
116
|
+
expect(emitted('retry')).toEqual([['authored']]);
|
|
117
|
+
expect(queryByRole('button', { name: 'Load more' })).not.toBeInTheDocument();
|
|
118
|
+
});
|
|
119
|
+
it('hides settled empty group headers', () => {
|
|
120
|
+
const { queryByTestId } = renderComponent();
|
|
121
|
+
expect(queryByTestId('inbox-section-header')).not.toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
it('keeps a partial empty group visible with its own retry', () => {
|
|
124
|
+
const { getByRole, emitted } = renderComponent({
|
|
125
|
+
props: { sections: [section('waiting', { partial: true }), section('authored')] },
|
|
126
|
+
});
|
|
127
|
+
expect(getByRole('button', { name: 'Waiting for your review' })).toBeInTheDocument();
|
|
128
|
+
getByRole('button', { name: 'Retry' }).click();
|
|
129
|
+
expect(emitted('refreshSection')).toEqual([['waiting']]);
|
|
130
|
+
});
|
|
131
|
+
it('collapses groups without requesting more data', async () => {
|
|
132
|
+
const { getByRole, queryByRole, emitted } = renderComponent({
|
|
133
|
+
props: { sections: [section('waiting', { items: [review()] })] },
|
|
134
|
+
});
|
|
135
|
+
const header = getByRole('button', { name: 'Waiting for your review' });
|
|
136
|
+
await fireEvent.click(header);
|
|
137
|
+
expect(header).toHaveAttribute('aria-expanded', 'false');
|
|
138
|
+
expect(queryByRole('option')).not.toBeInTheDocument();
|
|
139
|
+
await fireEvent.click(header);
|
|
140
|
+
expect(getByRole('option')).toHaveTextContent('Review my workflow');
|
|
141
|
+
expect(emitted('loadMore')).toBeUndefined();
|
|
142
|
+
});
|
|
143
|
+
it('uses the impersonal waiting label for administrators', () => {
|
|
144
|
+
vi.spyOn(useUsersStore(), 'isAdminOrOwner', 'get').mockReturnValue(true);
|
|
145
|
+
const { getByRole } = renderComponent({
|
|
146
|
+
props: { sections: [section('waiting', { items: [review()] })] },
|
|
147
|
+
});
|
|
148
|
+
expect(getByRole('button', { name: 'Waiting for review' })).toBeInTheDocument();
|
|
149
|
+
});
|
|
150
|
+
it('keeps loading open groups explicit and identifies the group', () => {
|
|
151
|
+
const { emitted, getByRole } = renderComponent({
|
|
152
|
+
props: { sections: [section('authored', { hasMore: true })] },
|
|
153
|
+
});
|
|
154
|
+
intersect();
|
|
155
|
+
expect(emitted('loadMore')).toBeUndefined();
|
|
156
|
+
getByRole('button', { name: 'Load more' }).click();
|
|
157
|
+
expect(emitted('loadMore')).toEqual([['authored']]);
|
|
158
|
+
});
|
|
159
|
+
it('loads Closed at the bottom without group headers or a Load more button', () => {
|
|
160
|
+
const { emitted, queryByRole, queryByTestId } = renderComponent({
|
|
161
|
+
props: { activeTab: 'closed', sections: [section('closed', { hasMore: true })] },
|
|
162
|
+
});
|
|
163
|
+
intersect(false);
|
|
164
|
+
expect(emitted('loadMore')).toBeUndefined();
|
|
165
|
+
intersect();
|
|
166
|
+
expect(emitted('loadMore')).toEqual([['closed']]);
|
|
167
|
+
expect(queryByRole('button', { name: 'Load more' })).not.toBeInTheDocument();
|
|
168
|
+
expect(queryByTestId('inbox-section-header')).not.toBeInTheDocument();
|
|
169
|
+
});
|
|
170
|
+
it.each([{ loading: true }, { loadingMore: true }, { hasMore: false }])(
|
|
171
|
+
'does not automatically load Closed with %o',
|
|
172
|
+
(props) => {
|
|
173
|
+
const { emitted } = renderComponent({
|
|
174
|
+
props: { activeTab: 'closed', sections: [section('closed', { hasMore: true, ...props })] },
|
|
175
|
+
});
|
|
176
|
+
intersect();
|
|
177
|
+
expect(emitted('loadMore')).toBeUndefined();
|
|
178
|
+
},
|
|
179
|
+
);
|
|
180
|
+
it('waits for Retry after a failed Closed page and removes the sentinel on Open', async () => {
|
|
181
|
+
const closed = section('closed', { hasMore: true, items: [{ ...review(), state: 'closed' }] });
|
|
182
|
+
const { rerender, emitted } = renderComponent({
|
|
183
|
+
props: { activeTab: 'closed', sections: [closed] },
|
|
184
|
+
});
|
|
185
|
+
const target = vi.mocked(useIntersectionObserver).mock.calls.at(-1)![0];
|
|
186
|
+
expect(target).not.toHaveProperty('value', null);
|
|
187
|
+
intersect();
|
|
188
|
+
await rerender({ sections: [{ ...closed, loadingMore: true }] });
|
|
189
|
+
expect(target).toHaveProperty('value', null);
|
|
190
|
+
intersect();
|
|
191
|
+
expect(emitted('loadMore')).toHaveLength(1);
|
|
192
|
+
await rerender({
|
|
193
|
+
sections: [{ ...closed, error: new Error('Page failed') }],
|
|
194
|
+
});
|
|
195
|
+
expect(target).toHaveProperty('value', null);
|
|
196
|
+
intersect();
|
|
197
|
+
expect(emitted('loadMore')).toHaveLength(1);
|
|
198
|
+
await rerender({ sections: [closed] });
|
|
199
|
+
expect(target).not.toHaveProperty('value', null);
|
|
200
|
+
intersect();
|
|
201
|
+
expect(emitted('loadMore')).toHaveLength(2);
|
|
202
|
+
await rerender({ activeTab: 'open', sections: [section('waiting')] });
|
|
203
|
+
expect(target).toHaveProperty('value', null);
|
|
204
|
+
});
|
|
205
|
+
it('separates partial-source recovery from a failed page retry', () => {
|
|
206
|
+
const { getByTestId, emitted } = renderComponent({
|
|
207
|
+
props: { sections: [section('waiting', { partial: true, error: new Error('Page failed') })] },
|
|
208
|
+
});
|
|
209
|
+
within(getByTestId('inbox-partial')).getByRole('button', { name: 'Retry' }).click();
|
|
210
|
+
expect(emitted('refreshSection')).toEqual([['waiting']]);
|
|
211
|
+
expect(emitted('retry')).toBeUndefined();
|
|
212
|
+
within(getByTestId('inbox-list-error')).getByRole('button', { name: 'Retry' }).click();
|
|
213
|
+
expect(emitted('retry')).toEqual([['waiting']]);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it('keeps review selection and keyboard activation across the extracted row', async () => {
|
|
217
|
+
const item = review();
|
|
218
|
+
const { getByRole, emitted } = renderComponent({
|
|
219
|
+
props: {
|
|
220
|
+
selectedKey: `${item.type}:${item.id}`,
|
|
221
|
+
sections: [section('waiting', { items: [item] })],
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
const row = getByRole('option', { selected: true });
|
|
225
|
+
expect(row).toHaveTextContent(item.title);
|
|
226
|
+
await fireEvent.keyDown(row, { key: 'Enter' });
|
|
227
|
+
await fireEvent.keyDown(row, { key: ' ' });
|
|
228
|
+
expect(emitted('select')).toEqual([[item], [item]]);
|
|
229
|
+
});
|