@webiny/app-website-builder-workflows 6.6.0-alpha.12 → 6.6.0-alpha.13
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/Components/ContentReviews/WbContentReviews.js.map +1 -1
- package/Components/ContentReviews/WbContentReviews.smoke.test.js +1 -1
- package/Components/ContentReviews/WbContentReviews.smoke.test.js.map +1 -1
- package/Components/ContentReviews/WbContentReviewsSidebarItem.js +17 -7
- package/Components/ContentReviews/WbContentReviewsSidebarItem.js.map +1 -1
- package/Components/ContentReviews/WbContentReviewsSidebarItem.test.js +122 -11
- package/Components/ContentReviews/WbContentReviewsSidebarItem.test.js.map +1 -1
- package/Components/PageEditor/PageBasePublishDecorator.js +1 -1
- package/Components/PageEditor/PageBasePublishDecorator.js.map +1 -1
- package/Components/PageEditor/PageEditorAutoSave.js +1 -1
- package/Components/PageEditor/PageEditorAutoSave.js.map +1 -1
- package/Components/PageEditor/PageEditorAutoSave.test.js +1 -1
- package/Components/PageEditor/PageEditorAutoSave.test.js.map +1 -1
- package/Components/PageEditor/PageEditorLayout.js +1 -1
- package/Components/PageEditor/PageEditorLayout.js.map +1 -1
- package/Components/PageEditor/PageEditorLayout.test.js +1 -1
- package/Components/PageEditor/PageEditorLayout.test.js.map +1 -1
- package/Components/PageEditor/PageEditorTopBar.js +1 -1
- package/Components/PageEditor/PageEditorTopBar.js.map +1 -1
- package/Components/PageEditor/PageEditorTopBar.test.js +1 -1
- package/Components/PageEditor/PageEditorTopBar.test.js.map +1 -1
- package/Components/PageEditor/PageNewRevisionDecorator.js +1 -1
- package/Components/PageEditor/PageNewRevisionDecorator.js.map +1 -1
- package/Components/PageEditor/PageNewRevisionDecorator.test.js +1 -1
- package/Components/PageEditor/PageNewRevisionDecorator.test.js.map +1 -1
- package/Components/PageEditor/PageReviewPublishAction.js +1 -1
- package/Components/PageEditor/PageReviewPublishAction.js.map +1 -1
- package/Components/PageEditor/PageScheduleDecorator.js +6 -2
- package/Components/PageEditor/PageScheduleDecorator.js.map +1 -1
- package/Components/PageEditor/PageScheduleDecorator.test.js +13 -3
- package/Components/PageEditor/PageScheduleDecorator.test.js.map +1 -1
- package/Components/PageEditor/getPageReadOnlyReason.js +1 -7
- package/Components/PageEditor/getPageReadOnlyReason.js.map +1 -1
- package/Components/PageEditor/getPageReadOnlyReason.test.js +4 -6
- package/Components/PageEditor/getPageReadOnlyReason.test.js.map +1 -1
- package/Components/PageEditor/pageReviewMatrix.test.js +5 -7
- package/Components/PageEditor/pageReviewMatrix.test.js.map +1 -1
- package/Components/PageEditor/publishMatrix.test.js +1 -1
- package/Components/PageEditor/publishMatrix.test.js.map +1 -1
- package/Components/PagesList/PageBulkPublishBlocked.d.ts +5 -0
- package/Components/PagesList/PageBulkPublishBlocked.js +23 -0
- package/Components/PagesList/PageBulkPublishBlocked.js.map +1 -0
- package/Components/PagesList/PageBulkPublishGate.d.ts +7 -0
- package/Components/PagesList/PageBulkPublishGate.js +33 -0
- package/Components/PagesList/PageBulkPublishGate.js.map +1 -0
- package/Components/PagesList/PageBulkPublishGate.test.d.ts +1 -0
- package/Components/PagesList/PageBulkPublishGate.test.js +148 -0
- package/Components/PagesList/PageBulkPublishGate.test.js.map +1 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.d.ts +2 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.js +16 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.js.map +1 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.test.d.ts +1 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.test.js +44 -0
- package/Components/PagesList/PageListReviewBulkPublishAction.test.js.map +1 -0
- package/Components/PagesList/PageListReviewGatedActions.js +11 -15
- package/Components/PagesList/PageListReviewGatedActions.js.map +1 -1
- package/Components/PagesList/PageListReviewGatedActions.test.js +141 -27
- package/Components/PagesList/PageListReviewGatedActions.test.js.map +1 -1
- package/Components/PagesList/PageListReviewMoveAction.d.ts +2 -0
- package/Components/PagesList/PageListReviewMoveAction.js +16 -0
- package/Components/PagesList/PageListReviewMoveAction.js.map +1 -0
- package/Components/PagesList/PageListReviewMoveAction.test.d.ts +1 -0
- package/Components/PagesList/PageListReviewMoveAction.test.js +102 -0
- package/Components/PagesList/PageListReviewMoveAction.test.js.map +1 -0
- package/Components/PagesList/PageMoveBlocked.d.ts +2 -0
- package/Components/PagesList/PageMoveBlocked.js +26 -0
- package/Components/PagesList/PageMoveBlocked.js.map +1 -0
- package/Components/PagesList/PageMoveGate.d.ts +5 -0
- package/Components/PagesList/PageMoveGate.js +12 -0
- package/Components/PagesList/PageMoveGate.js.map +1 -0
- package/Components/PagesList/PagePublishBlocked.d.ts +5 -0
- package/Components/PagesList/PagePublishBlocked.js +26 -0
- package/Components/PagesList/PagePublishBlocked.js.map +1 -0
- package/Components/PagesList/PagePublishGate.d.ts +7 -0
- package/Components/PagesList/PagePublishGate.js +21 -0
- package/Components/PagesList/PagePublishGate.js.map +1 -0
- package/Components/PagesList/PageScheduleGate.d.ts +7 -0
- package/Components/PagesList/PageScheduleGate.js +13 -0
- package/Components/PagesList/PageScheduleGate.js.map +1 -0
- package/Components/PagesList/PagesList.js +3 -1
- package/Components/PagesList/PagesList.js.map +1 -1
- package/Components/PagesList/PagesList.test.js +18 -0
- package/Components/PagesList/PagesList.test.js.map +1 -1
- package/Components/PagesList/ignoreAction.d.ts +1 -0
- package/Components/PagesList/ignoreAction.js +4 -0
- package/Components/PagesList/ignoreAction.js.map +1 -0
- package/Components/PagesList/toListPublishRow.d.ts +8 -0
- package/Components/PagesList/toListPublishRow.js +10 -0
- package/Components/PagesList/toListPublishRow.js.map +1 -0
- package/Components/PagesList/toListPublishRow.test.d.ts +1 -0
- package/Components/PagesList/toListPublishRow.test.js +38 -0
- package/Components/PagesList/toListPublishRow.test.js.map +1 -0
- package/Components/PagesList/usePageRowPublishDisabledReason.d.ts +1 -0
- package/Components/PagesList/usePageRowPublishDisabledReason.js +25 -0
- package/Components/PagesList/usePageRowPublishDisabledReason.js.map +1 -0
- package/Routes/WebsiteBuilderWorkflowsMenu.test.js +1 -1
- package/Routes/WebsiteBuilderWorkflowsMenu.test.js.map +1 -1
- package/editorGlue.wiring.test.js +1 -1
- package/editorGlue.wiring.test.js.map +1 -1
- package/features/editorGateway/WbWorkflowEditorGateway/WbWorkflowEditorGateway.test.js +8 -0
- package/features/editorGateway/WbWorkflowEditorGateway/WbWorkflowEditorGateway.test.js.map +1 -1
- package/features/editorGateway/feature.test.js +1 -0
- package/features/editorGateway/feature.test.js.map +1 -1
- package/features/gateway/WbReviewGateway/WbReviewGateway.js +2 -3
- package/features/gateway/WbReviewGateway/WbReviewGateway.js.map +1 -1
- package/features/gateway/WbReviewGateway/WbReviewGateway.test.js +7 -10
- package/features/gateway/WbReviewGateway/WbReviewGateway.test.js.map +1 -1
- package/features/gateway/contentReviewsBindings.test.js +2 -2
- package/features/gateway/contentReviewsBindings.test.js.map +1 -1
- package/features/gateway/graphql/listWebsiteBuilderPageReviews.d.ts +1 -1
- package/features/gateway/graphql/listWebsiteBuilderPageReviews.js +2 -2
- package/features/gateway/graphql/listWebsiteBuilderPageReviews.js.map +1 -1
- package/features/gateway/graphql/listWebsiteBuilderPageWorkflows.d.ts +1 -1
- package/package.json +18 -18
- package/pageListChangeStatus.wiring.test.js +53 -15
- package/pageListChangeStatus.wiring.test.js.map +1 -1
- package/publishAutosave.wiring.test.js +1 -1
- package/publishAutosave.wiring.test.js.map +1 -1
- package/routes.d.ts +2 -1
- package/routes.js +2 -1
- package/routes.js.map +1 -1
- package/testing/WbEditorHarness.js +1 -1
- package/testing/WbEditorHarness.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/ContentReviews/WbContentReviews.js","sources":["../../../src/Components/ContentReviews/WbContentReviews.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport type { IReviewContentTypesSource } from \"@webiny/app-workflows/review/presentation/reviewList/IReviewContentTypesSource.js\";\nimport { ReviewContentReviewsMenu } from \"@webiny/app-workflows/review/mounting/components/ReviewContentReviewsMenu.js\";\nimport { ReviewContentReviewsRoute } from \"@webiny/app-workflows/review/mounting/components/ReviewContentReviewsRoute.js\";\nimport { ReviewDashboardWidgets } from \"@webiny/app-workflows/review/mounting/components/ReviewDashboardWidgets.js\";\nimport { WB_PAGE_APP } from \"~/constants.js\";\nimport { WbReviewFeature } from \"~/features/gateway/feature.js\";\nimport { Routes } from \"~/routes.js\";\n\nconst NAMESPACES = [WB_PAGE_APP];\n\n// Pages need nothing loaded: one fixed namespace and no content types.\nconst CONTENT_TYPES: IReviewContentTypesSource = {\n vm: { loading: false, namespaces: NAMESPACES, options: [] }\n};\n\n/*\n * Mounts the shared Content Reviews route, menu item and dashboard widgets for the `wb` app.\n * Pages have no content
|
|
1
|
+
{"version":3,"file":"Components/ContentReviews/WbContentReviews.js","sources":["../../../src/Components/ContentReviews/WbContentReviews.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport type { IReviewContentTypesSource } from \"@webiny/app-workflows/review/presentation/reviewList/IReviewContentTypesSource.js\";\nimport { ReviewContentReviewsMenu } from \"@webiny/app-workflows/review/mounting/components/ReviewContentReviewsMenu.js\";\nimport { ReviewContentReviewsRoute } from \"@webiny/app-workflows/review/mounting/components/ReviewContentReviewsRoute.js\";\nimport { ReviewDashboardWidgets } from \"@webiny/app-workflows/review/mounting/components/ReviewDashboardWidgets.js\";\nimport { WB_PAGE_APP } from \"~/constants.js\";\nimport { WbReviewFeature } from \"~/features/gateway/feature.js\";\nimport { Routes } from \"~/routes.js\";\n\nconst NAMESPACES = [WB_PAGE_APP];\n\n// Pages need nothing loaded: one fixed namespace and no content types.\nconst CONTENT_TYPES: IReviewContentTypesSource = {\n vm: { loading: false, namespaces: NAMESPACES, options: [] }\n};\n\n/*\n * Mounts the shared Content Reviews route, menu item and dashboard widgets for the `wb` app.\n * Pages have no content model: no Content model column and no filter (D113, B6). The widgets are\n * always mounted: a widget that mounts after the first render is not registered on the dashboard.\n */\nexport const WbContentReviews = () => {\n const { rowProvider } = useFeature(WbReviewFeature);\n\n return (\n <>\n <ReviewContentReviewsRoute\n route={Routes.Pages.WorkflowStateList}\n app=\"wb\"\n rowProvider={rowProvider}\n showContentType={false}\n contentTypes={CONTENT_TYPES}\n breadcrumbName=\"wb.content-reviews\"\n />\n <ReviewContentReviewsMenu\n name=\"workflows.wb.contentReviews\"\n route={Routes.Pages.WorkflowStateList}\n parent=\"wb\"\n />\n <ReviewDashboardWidgets\n prefix=\"wb\"\n namespaces={NAMESPACES}\n rowProvider={rowProvider}\n viewAllRoute={Routes.Pages.WorkflowStateList}\n />\n </>\n );\n};\n"],"names":["NAMESPACES","WB_PAGE_APP","CONTENT_TYPES","WbContentReviews","rowProvider","useFeature","WbReviewFeature","ReviewContentReviewsRoute","Routes","ReviewContentReviewsMenu","ReviewDashboardWidgets"],"mappings":";;;;;;;;AAUA,MAAMA,aAAa;IAACC;CAAY;AAGhC,MAAMC,gBAA2C;IAC7C,IAAI;QAAE,SAAS;QAAO,YAAYF;QAAY,SAAS,EAAE;IAAC;AAC9D;AAOO,MAAMG,mBAAmB;IAC5B,MAAM,EAAEC,WAAW,EAAE,GAAGC,WAAWC;IAEnC,OAAO,WAAP,GACI,wDACI,oBAACC,2BAAyBA;QACtB,OAAOC,OAAO,KAAK,CAAC,iBAAiB;QACrC,KAAI;QACJ,aAAaJ;QACb,iBAAiB;QACjB,cAAcF;QACd,gBAAe;sBAEnB,oBAACO,0BAAwBA;QACrB,MAAK;QACL,OAAOD,OAAO,KAAK,CAAC,iBAAiB;QACrC,QAAO;sBAEX,oBAACE,wBAAsBA;QACnB,QAAO;QACP,YAAYV;QACZ,aAAaI;QACb,cAAcI,OAAO,KAAK,CAAC,iBAAiB;;AAI5D"}
|
|
@@ -15,7 +15,7 @@ vi.mock("@webiny/app-admin", async (importOriginal)=>{
|
|
|
15
15
|
...actual,
|
|
16
16
|
useRouter: ()=>({
|
|
17
17
|
getLink: (route, params)=>{
|
|
18
|
-
if (params) return `${route.path}?
|
|
18
|
+
if (params) return `${route.path}?scope=${params.scope}&state=${params.state}`;
|
|
19
19
|
return route.path;
|
|
20
20
|
}
|
|
21
21
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/ContentReviews/WbContentReviews.smoke.test.js","sources":["../../../src/Components/ContentReviews/WbContentReviews.smoke.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { Container } from \"@webiny/di\";\nimport { DiContainerProvider } from \"@webiny/app\";\nimport { RouterWithConfig } from \"@webiny/app/config/RouterConfig.js\";\nimport { useRouterConfig } from \"@webiny/app/config/RouterConfig.js\";\nimport { AdminConfigPlugin } from \"@webiny/app-admin/config/AdminConfig.js\";\nimport { AdminWithConfig } from \"@webiny/app-admin/config/AdminConfig.js\";\nimport { useAdminConfig } from \"@webiny/app-admin/config/AdminConfig.js\";\nimport { CompositionProvider } from \"@webiny/react-composition\";\nimport type { IReviewContentAdapter } from \"@webiny/app-workflows/review/content/IReviewContentAdapter.js\";\nimport type { IReviewRowProvider } from \"@webiny/app-workflows/review/presentation/reviewList/abstractions.js\";\nimport { WbReviewContentAdapter } from \"~/features/gateway/WbReviewContentAdapter/abstractions.js\";\nimport { WbReviewRowProvider } from \"~/features/gateway/WbReviewRowProvider/abstractions.js\";\nimport { WbContentReviews } from \"./WbContentReviews.js\";\n\ninterface RouteStub {\n path: string;\n}\n\ninterface RouteParamsStub {\n
|
|
1
|
+
{"version":3,"file":"Components/ContentReviews/WbContentReviews.smoke.test.js","sources":["../../../src/Components/ContentReviews/WbContentReviews.smoke.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { Container } from \"@webiny/di\";\nimport { DiContainerProvider } from \"@webiny/app\";\nimport { RouterWithConfig } from \"@webiny/app/config/RouterConfig.js\";\nimport { useRouterConfig } from \"@webiny/app/config/RouterConfig.js\";\nimport { AdminConfigPlugin } from \"@webiny/app-admin/config/AdminConfig.js\";\nimport { AdminWithConfig } from \"@webiny/app-admin/config/AdminConfig.js\";\nimport { useAdminConfig } from \"@webiny/app-admin/config/AdminConfig.js\";\nimport { CompositionProvider } from \"@webiny/react-composition\";\nimport type { IReviewContentAdapter } from \"@webiny/app-workflows/review/content/IReviewContentAdapter.js\";\nimport type { IReviewRowProvider } from \"@webiny/app-workflows/review/presentation/reviewList/abstractions.js\";\nimport { WbReviewContentAdapter } from \"~/features/gateway/WbReviewContentAdapter/abstractions.js\";\nimport { WbReviewRowProvider } from \"~/features/gateway/WbReviewRowProvider/abstractions.js\";\nimport { WbContentReviews } from \"./WbContentReviews.js\";\n\ninterface RouteStub {\n path: string;\n}\n\ninterface RouteParamsStub {\n scope: string;\n state: string;\n}\n\n// The router is not under test (only `getLink` is read).\nvi.mock(\"@webiny/app-admin\", async importOriginal => {\n const actual = await importOriginal<typeof import(\"@webiny/app-admin\")>();\n return {\n ...actual,\n useRouter: () => {\n return {\n getLink: (route: RouteStub, params?: RouteParamsStub) => {\n if (params) {\n return `${route.path}?scope=${params.scope}&state=${params.state}`;\n }\n return route.path;\n }\n };\n }\n };\n});\n\nconst Probe = () => {\n const adminConfig = useAdminConfig();\n const routerConfig = useRouterConfig();\n\n const menus = adminConfig.menus.map(menu => `${menu.name}:${menu.parent ?? \"\"}`);\n const widgets = adminConfig.widgets.map(widget => `${widget.name}:${widget.column}`);\n const routes = routerConfig.routes.map(item => item.route.name);\n\n return (\n <div\n data-testid=\"probe\"\n data-menus={menus.join(\",\")}\n data-widgets={widgets.join(\",\")}\n data-routes={routes.join(\",\")}\n />\n );\n};\n\ndescribe(\"WbContentReviews under the real admin and router configs\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it(\"registers the route, the menu item and the two widgets\", async () => {\n const container = new Container();\n container.registerInstance(WbReviewContentAdapter, {} as unknown as IReviewContentAdapter);\n container.registerInstance(WbReviewRowProvider, {\n getBinding: () => null\n } as IReviewRowProvider);\n\n render(\n <DiContainerProvider container={container}>\n <CompositionProvider>\n {/* Mirrors App.tsx: the config declarations and the admin plugin come before the router, which renders its children only after its first config flush. */}\n <WbContentReviews />\n <AdminWithConfig>\n {AdminConfigPlugin}\n <RouterWithConfig>\n <Probe />\n </RouterWithConfig>\n </AdminWithConfig>\n </CompositionProvider>\n </DiContainerProvider>\n );\n\n const probe = await screen.findByTestId(\"probe\");\n await vi.waitFor(() => {\n expect(probe.getAttribute(\"data-routes\")).toBe(\n \"WebsiteBuilder/Pages/WorkflowStateList\"\n );\n });\n expect(probe.getAttribute(\"data-menus\")).toBe(\"workflows.wb.contentReviews:wb\");\n expect(probe.getAttribute(\"data-widgets\")).toBe(\n \"workflows.wb.review:right,workflows.wb.requested:right\"\n );\n });\n});\n"],"names":["vi","importOriginal","actual","route","params","Probe","adminConfig","useAdminConfig","routerConfig","useRouterConfig","menus","menu","widgets","widget","routes","item","describe","afterEach","cleanup","it","container","Container","WbReviewContentAdapter","WbReviewRowProvider","render","DiContainerProvider","CompositionProvider","WbContentReviews","AdminWithConfig","AdminConfigPlugin","RouterWithConfig","probe","screen","expect"],"mappings":";;;;;;;;;;;AAiCAA,GAAG,IAAI,CAAC,qBAAqB,OAAMC;IAC/B,MAAMC,SAAS,MAAMD;IACrB,OAAO;QACH,GAAGC,MAAM;QACT,WAAW,IACA;gBACH,SAAS,CAACC,OAAkBC;oBACxB,IAAIA,QACA,OAAO,GAAGD,MAAM,IAAI,CAAC,OAAO,EAAEC,O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AAM,YAAY,CAAC,eAAe,IAAI,CAAC;QAC9CE,OAAOF,MAAM,YAAY,CAAC,iBAAiB,IAAI,CAC3C;IAER;AACJ"}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import react from "react";
|
|
2
|
+
import { useFeature } from "@webiny/app";
|
|
2
3
|
import { PageListConfig } from "@webiny/app-website-builder";
|
|
3
4
|
import { ReactComponent } from "@webiny/icons/flowchart.svg";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { ReviewContentReviewsOverlaySidebarItem } from "@webiny/app-workflows/review/mounting/components/ReviewContentReviewsOverlaySidebarItem.js";
|
|
6
|
+
import { WB_PAGE_APP } from "../../constants.js";
|
|
7
|
+
import { WbReviewFeature } from "../../features/gateway/feature.js";
|
|
8
|
+
const { Browser } = PageListConfig;
|
|
9
|
+
const NAMESPACES = [
|
|
10
|
+
WB_PAGE_APP
|
|
11
|
+
];
|
|
12
|
+
const ContentReviewsSidebarOverlay = ()=>{
|
|
13
|
+
const { rowProvider } = useFeature(WbReviewFeature);
|
|
14
|
+
return /*#__PURE__*/ react.createElement(ReviewContentReviewsOverlaySidebarItem, {
|
|
15
|
+
app: "wb",
|
|
16
|
+
rowProvider: rowProvider,
|
|
17
|
+
namespaces: NAMESPACES,
|
|
18
|
+
title: "Content Reviews - Pages",
|
|
10
19
|
icon: /*#__PURE__*/ react.createElement(ReactComponent, null)
|
|
11
20
|
});
|
|
21
|
+
};
|
|
12
22
|
const WbContentReviewsSidebarItem = ()=>/*#__PURE__*/ react.createElement(Browser.Sidebar.Footer, {
|
|
13
23
|
name: "contentReviews",
|
|
14
|
-
element: /*#__PURE__*/ react.createElement(
|
|
24
|
+
element: /*#__PURE__*/ react.createElement(ContentReviewsSidebarOverlay, null)
|
|
15
25
|
});
|
|
16
26
|
export { WbContentReviewsSidebarItem };
|
|
17
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/ContentReviews/WbContentReviewsSidebarItem.js","sources":["../../../src/Components/ContentReviews/WbContentReviewsSidebarItem.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageListConfig } from \"@webiny/app-website-builder\";\nimport { ReactComponent as ContentReviewsIcon } from \"@webiny/icons/flowchart.svg\";\nimport {
|
|
1
|
+
{"version":3,"file":"Components/ContentReviews/WbContentReviewsSidebarItem.js","sources":["../../../src/Components/ContentReviews/WbContentReviewsSidebarItem.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { PageListConfig } from \"@webiny/app-website-builder\";\nimport { ReactComponent as ContentReviewsIcon } from \"@webiny/icons/flowchart.svg\";\nimport { ReviewContentReviewsOverlaySidebarItem } from \"@webiny/app-workflows/review/mounting/components/ReviewContentReviewsOverlaySidebarItem.js\";\nimport { WB_PAGE_APP } from \"~/constants.js\";\nimport { WbReviewFeature } from \"~/features/gateway/feature.js\";\n\nconst { Browser } = PageListConfig;\n\nconst NAMESPACES = [WB_PAGE_APP];\n\n// Opens the page reviews in an overlay over the pages list, as the trash bin does.\nconst ContentReviewsSidebarOverlay = () => {\n const { rowProvider } = useFeature(WbReviewFeature);\n\n return (\n <ReviewContentReviewsOverlaySidebarItem\n app={\"wb\"}\n rowProvider={rowProvider}\n namespaces={NAMESPACES}\n title={\"Content Reviews - Pages\"}\n icon={<ContentReviewsIcon />}\n />\n );\n};\n\n// The \"Content Reviews\" item of the page list sidebar; it opens the page reviews overlay.\nexport const WbContentReviewsSidebarItem = () => {\n return (\n <Browser.Sidebar.Footer\n name={\"contentReviews\"}\n element={<ContentReviewsSidebarOverlay />}\n />\n );\n};\n"],"names":["Browser","PageListConfig","NAMESPACES","WB_PAGE_APP","ContentReviewsSidebarOverlay","rowProvider","useFeature","WbReviewFeature","ReviewContentReviewsOverlaySidebarItem","ContentReviewsIcon","WbContentReviewsSidebarItem"],"mappings":";;;;;;;AAQA,MAAM,EAAEA,OAAO,EAAE,GAAGC;AAEpB,MAAMC,aAAa;IAACC;CAAY;AAGhC,MAAMC,+BAA+B;IACjC,MAAM,EAAEC,WAAW,EAAE,GAAGC,WAAWC;IAEnC,OAAO,WAAP,GACI,oBAACC,wCAAsCA;QACnC,KAAK;QACL,aAAaH;QACb,YAAYH;QACZ,OAAO;QACP,oBAAM,oBAACO,gBAAkBA;;AAGrC;AAGO,MAAMC,8BAA8B,IAChC,WAAP,GACI,oBAACV,QAAQ,OAAO,CAAC,MAAM;QACnB,MAAM;QACN,uBAAS,oBAACI,8BAAAA"}
|
|
@@ -1,21 +1,66 @@
|
|
|
1
1
|
import react from "react";
|
|
2
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
-
import { Routes } from "../../routes.js";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
5
4
|
import { WbContentReviewsSidebarItem } from "./WbContentReviewsSidebarItem.js";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const router = vi.hoisted(()=>({
|
|
6
|
+
route: {
|
|
7
|
+
name: "WebsiteBuilder/Pages/List",
|
|
8
|
+
pathname: "/website-builder/pages",
|
|
9
|
+
params: {}
|
|
10
|
+
},
|
|
11
|
+
goToRoute: vi.fn(),
|
|
12
|
+
setRouteParams: vi.fn(),
|
|
13
|
+
replaceRouteParams: vi.fn()
|
|
14
|
+
}));
|
|
15
|
+
const rowProvider = vi.hoisted(()=>({
|
|
16
|
+
getBinding: ()=>null
|
|
17
|
+
}));
|
|
18
|
+
const viewProps = vi.hoisted(()=>({
|
|
19
|
+
current: null
|
|
9
20
|
}));
|
|
10
21
|
vi.mock("@webiny/app-admin", async (importOriginal)=>{
|
|
11
22
|
const actual = await importOriginal();
|
|
23
|
+
const React = await import("react");
|
|
24
|
+
const OverlayLayout = (props)=>React.createElement("div", {
|
|
25
|
+
"data-testid": "overlay"
|
|
26
|
+
}, React.createElement("div", {
|
|
27
|
+
"data-testid": "overlay-bar"
|
|
28
|
+
}, props.barLeft), React.createElement("button", {
|
|
29
|
+
onClick: props.onExited
|
|
30
|
+
}, "Close overlay"), props.children);
|
|
12
31
|
return {
|
|
13
32
|
...actual,
|
|
33
|
+
OverlayLayout,
|
|
14
34
|
useRouter: ()=>({
|
|
15
|
-
goToRoute: goToRoute
|
|
35
|
+
goToRoute: router.goToRoute
|
|
36
|
+
}),
|
|
37
|
+
useRoute: ()=>({
|
|
38
|
+
route: router.route,
|
|
39
|
+
setRouteParams: router.setRouteParams,
|
|
40
|
+
replaceRouteParams: router.replaceRouteParams
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
vi.mock("@webiny/app", async (importOriginal)=>{
|
|
45
|
+
const actual = await importOriginal();
|
|
46
|
+
return {
|
|
47
|
+
...actual,
|
|
48
|
+
useFeature: ()=>({
|
|
49
|
+
rowProvider
|
|
16
50
|
})
|
|
17
51
|
};
|
|
18
52
|
});
|
|
53
|
+
vi.mock("@webiny/app-workflows/review/presentation/reviewList/components/ReviewListView.js", async ()=>{
|
|
54
|
+
const React = await import("react");
|
|
55
|
+
return {
|
|
56
|
+
ReviewListView: (props)=>{
|
|
57
|
+
viewProps.current = props;
|
|
58
|
+
return React.createElement("div", {
|
|
59
|
+
"data-testid": "review-list"
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
});
|
|
19
64
|
vi.mock("@webiny/app-website-builder", async ()=>{
|
|
20
65
|
const React = await import("react");
|
|
21
66
|
const Footer = (props)=>React.createElement("div", {
|
|
@@ -39,28 +84,94 @@ vi.mock("@webiny/admin-ui", async (importOriginal)=>{
|
|
|
39
84
|
onClick: props.onClick
|
|
40
85
|
}, props.text);
|
|
41
86
|
const ItemIcon = ()=>React.createElement("span");
|
|
87
|
+
const ItemBadge = ()=>React.createElement("span");
|
|
42
88
|
return {
|
|
43
89
|
...actual,
|
|
44
90
|
Sidebar: {
|
|
45
91
|
...actual.Sidebar,
|
|
46
92
|
Item: Object.assign(Item, {
|
|
47
|
-
Icon: ItemIcon
|
|
93
|
+
Icon: ItemIcon,
|
|
94
|
+
Badge: ItemBadge
|
|
48
95
|
})
|
|
49
96
|
}
|
|
50
97
|
};
|
|
51
98
|
});
|
|
52
99
|
describe("WbContentReviewsSidebarItem", ()=>{
|
|
100
|
+
beforeEach(()=>{
|
|
101
|
+
router.route = {
|
|
102
|
+
name: "WebsiteBuilder/Pages/List",
|
|
103
|
+
pathname: "/website-builder/pages",
|
|
104
|
+
params: {}
|
|
105
|
+
};
|
|
106
|
+
viewProps.current = null;
|
|
107
|
+
});
|
|
53
108
|
afterEach(()=>{
|
|
54
109
|
cleanup();
|
|
110
|
+
router.goToRoute.mockReset();
|
|
111
|
+
router.setRouteParams.mockReset();
|
|
112
|
+
router.replaceRouteParams.mockReset();
|
|
55
113
|
});
|
|
56
|
-
it("adds a Content Reviews item to the page list footer that opens
|
|
114
|
+
it("adds a Content Reviews item to the page list footer that opens an overlay, not a route", ()=>{
|
|
57
115
|
render(/*#__PURE__*/ react.createElement(WbContentReviewsSidebarItem, null));
|
|
58
116
|
expect(screen.getByTestId("footer").getAttribute("data-name")).toBe("contentReviews");
|
|
117
|
+
expect(screen.queryByTestId("overlay")).toBeNull();
|
|
59
118
|
fireEvent.click(screen.getByRole("button", {
|
|
60
119
|
name: "Content Reviews"
|
|
61
120
|
}));
|
|
62
|
-
expect(
|
|
63
|
-
expect(
|
|
121
|
+
expect(screen.getByTestId("overlay")).toBeTruthy();
|
|
122
|
+
expect(screen.getByTestId("overlay-bar").textContent).toBe("Content Reviews - Pages");
|
|
123
|
+
expect(router.goToRoute).not.toHaveBeenCalled();
|
|
124
|
+
expect(router.setRouteParams).not.toHaveBeenCalled();
|
|
125
|
+
expect(router.replaceRouteParams).not.toHaveBeenCalled();
|
|
126
|
+
});
|
|
127
|
+
it("lists the page reviews, All with every state, without a content model or the URL", ()=>{
|
|
128
|
+
render(/*#__PURE__*/ react.createElement(WbContentReviewsSidebarItem, null));
|
|
129
|
+
fireEvent.click(screen.getByRole("button", {
|
|
130
|
+
name: "Content Reviews"
|
|
131
|
+
}));
|
|
132
|
+
expect(viewProps.current).toMatchObject({
|
|
133
|
+
app: "wb",
|
|
134
|
+
rowProvider,
|
|
135
|
+
namespaces: [
|
|
136
|
+
"wb.page"
|
|
137
|
+
],
|
|
138
|
+
fixedContentTypeId: null,
|
|
139
|
+
showContentType: false,
|
|
140
|
+
contentTypeFilter: null,
|
|
141
|
+
initialScope: "all",
|
|
142
|
+
initialState: "all",
|
|
143
|
+
title: null
|
|
144
|
+
});
|
|
145
|
+
expect(viewProps.current?.onRouteChange).toBeUndefined();
|
|
146
|
+
});
|
|
147
|
+
it("closes the overlay back to the pages list", ()=>{
|
|
148
|
+
render(/*#__PURE__*/ react.createElement(WbContentReviewsSidebarItem, null));
|
|
149
|
+
fireEvent.click(screen.getByRole("button", {
|
|
150
|
+
name: "Content Reviews"
|
|
151
|
+
}));
|
|
152
|
+
fireEvent.click(screen.getByRole("button", {
|
|
153
|
+
name: "Close overlay"
|
|
154
|
+
}));
|
|
155
|
+
expect(screen.queryByTestId("overlay")).toBeNull();
|
|
156
|
+
expect(screen.getByRole("button", {
|
|
157
|
+
name: "Content Reviews"
|
|
158
|
+
})).toBeTruthy();
|
|
159
|
+
expect(router.goToRoute).not.toHaveBeenCalled();
|
|
160
|
+
});
|
|
161
|
+
it("closes when Open content goes to the page editor", async ()=>{
|
|
162
|
+
const rendered = render(/*#__PURE__*/ react.createElement(WbContentReviewsSidebarItem, null));
|
|
163
|
+
fireEvent.click(screen.getByRole("button", {
|
|
164
|
+
name: "Content Reviews"
|
|
165
|
+
}));
|
|
166
|
+
router.route = {
|
|
167
|
+
name: "WebsiteBuilder/Pages/Editor",
|
|
168
|
+
pathname: "/website-builder/pages/editor/page-1%230001",
|
|
169
|
+
params: {
|
|
170
|
+
id: "page-1#0001"
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
rendered.rerender(/*#__PURE__*/ react.createElement(WbContentReviewsSidebarItem, null));
|
|
174
|
+
await waitFor(()=>expect(screen.queryByTestId("overlay")).toBeNull());
|
|
64
175
|
});
|
|
65
176
|
});
|
|
66
177
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/ContentReviews/WbContentReviewsSidebarItem.test.js","sources":["../../../src/Components/ContentReviews/WbContentReviewsSidebarItem.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { cleanup } from \"@testing-library/react\";\nimport { fireEvent } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { Routes } from \"~/routes.js\";\nimport { WbContentReviewsSidebarItem } from \"./WbContentReviewsSidebarItem.js\";\n\ninterface FooterStubProps {\n name: string;\n element: React.ReactElement;\n}\n\ninterface SidebarItemStubProps {\n text: string;\n onClick: () => void;\n}\n\nconst goToRoute = vi.hoisted(() => vi.fn());\n\nvi.mock(\"@webiny/icons/work_outline.svg\", () => {\n return { ReactComponent: () => null };\n});\n\nvi.mock(\"@webiny/app-admin\", async importOriginal => {\n const actual = await importOriginal<typeof import(\"@webiny/app-admin\")>();\n return {\n ...actual,\n useRouter: () => {\n return { goToRoute };\n }\n };\n});\n\nvi.mock(\"@webiny/app-website-builder\", async () => {\n const React = await import(\"react\");\n const Footer = (props: FooterStubProps) => {\n return React.createElement(\n \"div\",\n { \"data-testid\": \"footer\", \"data-name\": props.name },\n props.element\n );\n };\n return { PageListConfig: { Browser: { Sidebar: { Footer } } } };\n});\n\nvi.mock(\"@webiny/admin-ui\", async importOriginal => {\n const actual = await importOriginal<typeof import(\"@webiny/admin-ui\")>();\n const React = await import(\"react\");\n const Item = (props: SidebarItemStubProps) => {\n return React.createElement(\"button\", { onClick: props.onClick }, props.text);\n };\n const ItemIcon = () => React.createElement(\"span\");\n return {\n ...actual,\n Sidebar: { ...actual.Sidebar, Item: Object.assign(Item, { Icon: ItemIcon }) }\n };\n});\n\ndescribe(\"WbContentReviewsSidebarItem\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it(\"adds a Content Reviews item to the page list footer that opens the route\", () => {\n render(<WbContentReviewsSidebarItem />);\n\n expect(screen.getByTestId(\"footer\").getAttribute(\"data-name\")).toBe(\"contentReviews\");\n fireEvent.click(screen.getByRole(\"button\", { name: \"Content Reviews\" }));\n\n expect(goToRoute).toHaveBeenCalledTimes(1);\n expect(goToRoute).toHaveBeenCalledWith(Routes.Pages.WorkflowStateList);\n });\n});\n"],"names":["goToRoute","vi","importOriginal","actual","React","Footer","props","Item","ItemIcon","Object","describe","afterEach","cleanup","it","render","WbContentReviewsSidebarItem","expect","screen","fireEvent","Routes"],"mappings":";;;;;AAuBA,MAAMA,YAAYC,GAAG,OAAO,CAAC,IAAMA,GAAG,EAAE;AAExCA,GAAG,IAAI,CAAC,kCAAkC,IAC/B;QAAE,gBAAgB,IAAM;IAAK;AAGxCA,GAAG,IAAI,CAAC,qBAAqB,OAAMC;IAC/B,MAAMC,SAAS,MAAMD;IACrB,OAAO;QACH,GAAGC,MAAM;QACT,WAAW,IACA;gBAAEH,WAAAA;YAAU;IAE3B;AACJ;AAEAC,GAAG,IAAI,CAAC,+BAA+B;IACnC,MAAMG,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAMC,SAAS,CAACC,QACLF,MAAM,aAAa,CACtB,OACA;YAAE,eAAe;YAAU,aAAaE,MAAM,IAAI;QAAC,GACnDA,MAAM,OAAO;IAGrB,OAAO;QAAE,gBAAgB;YAAE,SAAS;gBAAE,SAAS;oBAAED;gBAAO;YAAE;QAAE;IAAE;AAClE;AAEAJ,GAAG,IAAI,CAAC,oBAAoB,OAAMC;IAC9B,MAAMC,SAAS,MAAMD;IACrB,MAAME,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAMG,OAAO,CAACD,QACHF,MAAM,aAAa,CAAC,UAAU;YAAE,SAASE,MAAM,OAAO;QAAC,GAAGA,MAAM,IAAI;IAE/E,MAAME,WAAW,IAAMJ,MAAM,aAAa,CAAC;IAC3C,OAAO;QACH,GAAGD,MAAM;QACT,SAAS;YAAE,GAAGA,OAAO,OAAO;YAAE,MAAMM,OAAO,MAAM,CAACF,MAAM;gBAAE,MAAMC;YAAS;QAAG;IAChF;AACJ;AAEAE,SAAS,+BAA+B;IACpCC,UAAU;QACNC;IACJ;IAEAC,GAAG,4EAA4E;QAC3EC,OAAO,WAADA,GAAC,oBAACC,6BAA2BA;QAEnCC,OAAOC,OAAO,WAAW,CAAC,UAAU,YAAY,CAAC,cAAc,IAAI,CAAC;QACpEC,UAAU,KAAK,CAACD,OAAO,SAAS,CAAC,UAAU;YAAE,MAAM;QAAkB;QAErED,OAAOhB,WAAW,qBAAqB,CAAC;QACxCgB,OAAOhB,WAAW,oBAAoB,CAACmB,OAAO,KAAK,CAAC,iBAAiB;IACzE;AACJ"}
|
|
1
|
+
{"version":3,"file":"Components/ContentReviews/WbContentReviewsSidebarItem.test.js","sources":["../../../src/Components/ContentReviews/WbContentReviewsSidebarItem.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { afterEach } from \"vitest\";\nimport { beforeEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { cleanup } from \"@testing-library/react\";\nimport { fireEvent } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { waitFor } from \"@testing-library/react\";\nimport type { ReviewListViewProps } from \"@webiny/app-workflows/review/presentation/reviewList/components/ReviewListView.js\";\nimport { WbContentReviewsSidebarItem } from \"./WbContentReviewsSidebarItem.js\";\n\ninterface FooterStubProps {\n name: string;\n element: React.ReactElement;\n}\n\ninterface SidebarItemStubProps {\n text: string;\n onClick: () => void;\n}\n\ninterface OverlayStubProps {\n barLeft: React.ReactNode;\n children: React.ReactNode;\n onExited: () => void;\n}\n\ninterface RouteStub {\n name: string;\n pathname: string;\n params: Record<string, unknown>;\n}\n\ninterface ViewPropsStub {\n current: ReviewListViewProps | null;\n}\n\nconst router = vi.hoisted(() => {\n return {\n route: {\n name: \"WebsiteBuilder/Pages/List\",\n pathname: \"/website-builder/pages\",\n params: {}\n } as RouteStub,\n goToRoute: vi.fn(),\n setRouteParams: vi.fn(),\n replaceRouteParams: vi.fn()\n };\n});\n\nconst rowProvider = vi.hoisted(() => {\n return { getBinding: () => null };\n});\n\n// The props the overlay gave the shared list view.\nconst viewProps = vi.hoisted((): ViewPropsStub => {\n return { current: null };\n});\n\nvi.mock(\"@webiny/app-admin\", async importOriginal => {\n const actual = await importOriginal<typeof import(\"@webiny/app-admin\")>();\n const React = await import(\"react\");\n const OverlayLayout = (props: OverlayStubProps) => {\n return React.createElement(\n \"div\",\n { \"data-testid\": \"overlay\" },\n React.createElement(\"div\", { \"data-testid\": \"overlay-bar\" }, props.barLeft),\n React.createElement(\"button\", { onClick: props.onExited }, \"Close overlay\"),\n props.children\n );\n };\n return {\n ...actual,\n OverlayLayout,\n useRouter: () => {\n return { goToRoute: router.goToRoute };\n },\n useRoute: () => {\n return {\n route: router.route,\n setRouteParams: router.setRouteParams,\n replaceRouteParams: router.replaceRouteParams\n };\n }\n };\n});\n\nvi.mock(\"@webiny/app\", async importOriginal => {\n const actual = await importOriginal<typeof import(\"@webiny/app\")>();\n return {\n ...actual,\n useFeature: () => {\n return { rowProvider };\n }\n };\n});\n\nvi.mock(\n \"@webiny/app-workflows/review/presentation/reviewList/components/ReviewListView.js\",\n async () => {\n const React = await import(\"react\");\n return {\n ReviewListView: (props: ReviewListViewProps) => {\n viewProps.current = props;\n return React.createElement(\"div\", { \"data-testid\": \"review-list\" });\n }\n };\n }\n);\n\nvi.mock(\"@webiny/app-website-builder\", async () => {\n const React = await import(\"react\");\n const Footer = (props: FooterStubProps) => {\n return React.createElement(\n \"div\",\n { \"data-testid\": \"footer\", \"data-name\": props.name },\n props.element\n );\n };\n return { PageListConfig: { Browser: { Sidebar: { Footer } } } };\n});\n\nvi.mock(\"@webiny/admin-ui\", async importOriginal => {\n const actual = await importOriginal<typeof import(\"@webiny/admin-ui\")>();\n const React = await import(\"react\");\n const Item = (props: SidebarItemStubProps) => {\n return React.createElement(\"button\", { onClick: props.onClick }, props.text);\n };\n const ItemIcon = () => React.createElement(\"span\");\n const ItemBadge = () => React.createElement(\"span\");\n return {\n ...actual,\n Sidebar: {\n ...actual.Sidebar,\n Item: Object.assign(Item, { Icon: ItemIcon, Badge: ItemBadge })\n }\n };\n});\n\ndescribe(\"WbContentReviewsSidebarItem\", () => {\n beforeEach(() => {\n router.route = {\n name: \"WebsiteBuilder/Pages/List\",\n pathname: \"/website-builder/pages\",\n params: {}\n };\n viewProps.current = null;\n });\n\n afterEach(() => {\n cleanup();\n router.goToRoute.mockReset();\n router.setRouteParams.mockReset();\n router.replaceRouteParams.mockReset();\n });\n\n it(\"adds a Content Reviews item to the page list footer that opens an overlay, not a route\", () => {\n render(<WbContentReviewsSidebarItem />);\n\n expect(screen.getByTestId(\"footer\").getAttribute(\"data-name\")).toBe(\"contentReviews\");\n expect(screen.queryByTestId(\"overlay\")).toBeNull();\n\n fireEvent.click(screen.getByRole(\"button\", { name: \"Content Reviews\" }));\n\n expect(screen.getByTestId(\"overlay\")).toBeTruthy();\n expect(screen.getByTestId(\"overlay-bar\").textContent).toBe(\"Content Reviews - Pages\");\n expect(router.goToRoute).not.toHaveBeenCalled();\n expect(router.setRouteParams).not.toHaveBeenCalled();\n expect(router.replaceRouteParams).not.toHaveBeenCalled();\n });\n\n it(\"lists the page reviews, All with every state, without a content model or the URL\", () => {\n render(<WbContentReviewsSidebarItem />);\n fireEvent.click(screen.getByRole(\"button\", { name: \"Content Reviews\" }));\n\n expect(viewProps.current).toMatchObject({\n app: \"wb\",\n rowProvider,\n namespaces: [\"wb.page\"],\n fixedContentTypeId: null,\n showContentType: false,\n contentTypeFilter: null,\n initialScope: \"all\",\n initialState: \"all\",\n title: null\n });\n expect(viewProps.current?.onRouteChange).toBeUndefined();\n });\n\n it(\"closes the overlay back to the pages list\", () => {\n render(<WbContentReviewsSidebarItem />);\n fireEvent.click(screen.getByRole(\"button\", { name: \"Content Reviews\" }));\n\n fireEvent.click(screen.getByRole(\"button\", { name: \"Close overlay\" }));\n\n expect(screen.queryByTestId(\"overlay\")).toBeNull();\n expect(screen.getByRole(\"button\", { name: \"Content Reviews\" })).toBeTruthy();\n expect(router.goToRoute).not.toHaveBeenCalled();\n });\n\n it(\"closes when Open content goes to the page editor\", async () => {\n const rendered = render(<WbContentReviewsSidebarItem />);\n fireEvent.click(screen.getByRole(\"button\", { name: \"Content Reviews\" }));\n\n router.route = {\n name: \"WebsiteBuilder/Pages/Editor\",\n pathname: \"/website-builder/pages/editor/page-1%230001\",\n params: { id: \"page-1#0001\" }\n };\n rendered.rerender(<WbContentReviewsSidebarItem />);\n\n await waitFor(() => expect(screen.queryByTestId(\"overlay\")).toBeNull());\n });\n});\n"],"names":["router","vi","rowProvider","viewProps","importOriginal","actual","React","OverlayLayout","props","Footer","Item","ItemIcon","ItemBadge","Object","describe","beforeEach","afterEach","cleanup","it","render","WbContentReviewsSidebarItem","expect","screen","fireEvent","rendered","waitFor"],"mappings":";;;;AAyCA,MAAMA,SAASC,GAAG,OAAO,CAAC,IACf;QACH,OAAO;YACH,MAAM;YACN,UAAU;YACV,QAAQ,CAAC;QACb;QACA,WAAWA,GAAG,EAAE;QAChB,gBAAgBA,GAAG,EAAE;QACrB,oBAAoBA,GAAG,EAAE;IAC7B;AAGJ,MAAMC,cAAcD,GAAG,OAAO,CAAC,IACpB;QAAE,YAAY,IAAM;IAAK;AAIpC,MAAME,YAAYF,GAAG,OAAO,CAAC,IAClB;QAAE,SAAS;IAAK;AAG3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oBAACC,6BAA2BA;QACnCG,UAAU,KAAK,CAACD,OAAO,SAAS,CAAC,UAAU;YAAE,MAAM;QAAkB;QAErED,OAAOlB,UAAU,OAAO,EAAE,aAAa,CAAC;YACpC,KAAK;YACLD;YACA,YAAY;gBAAC;aAAU;YACvB,oBAAoB;YACpB,iBAAiB;YACjB,mBAAmB;YACnB,cAAc;YACd,cAAc;YACd,OAAO;QACX;QACAmB,OAAOlB,UAAU,OAAO,EAAE,eAAe,aAAa;IAC1D;IAEAe,GAAG,6CAA6C;QAC5CC,OAAO,WAADA,GAAC,oBAACC,6BAA2BA;QACnCG,UAAU,KAAK,CAACD,OAAO,SAAS,CAAC,UAAU;YAAE,MAAM;QAAkB;QAErEC,UAAU,KAAK,CAACD,OAAO,SAAS,CAAC,UAAU;YAAE,MAAM;QAAgB;QAEnED,OAAOC,OAAO,aAAa,CAAC,YAAY,QAAQ;QAChDD,OAAOC,OAAO,SAAS,CAAC,UAAU;YAAE,MAAM;QAAkB,IAAI,UAAU;QAC1ED,OAAOrB,OAAO,SAAS,EAAE,GAAG,CAAC,gBAAgB;IACjD;IAEAkB,GAAG,oDAAoD;QACnD,MAAMM,WAAWL,OAAO,WAADA,GAAC,oBAACC,6BAA2BA;QACpDG,UAAU,KAAK,CAACD,OAAO,SAAS,CAAC,UAAU;YAAE,MAAM;QAAkB;QAErEtB,OAAO,KAAK,GAAG;YACX,MAAM;YACN,UAAU;YACV,QAAQ;gBAAE,IAAI;YAAc;QAChC;QACAwB,SAAS,QAAQ,CAAC,WAAD,GAAC,oBAACJ,6BAA2BA;QAE9C,MAAMK,QAAQ,IAAMJ,OAAOC,OAAO,aAAa,CAAC,YAAY,QAAQ;IACxE;AACJ"}
|
|
@@ -3,7 +3,7 @@ import { useFeature } from "@webiny/app";
|
|
|
3
3
|
import { createReactiveComponent } from "@webiny/app-admin";
|
|
4
4
|
import { PageEditorConfig } from "@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js";
|
|
5
5
|
import { WbPageReviewFeature } from "../../features/editorReview/feature.js";
|
|
6
|
-
const { Ui
|
|
6
|
+
const { Ui } = PageEditorConfig;
|
|
7
7
|
const BasePublishGate = createReactiveComponent((props)=>{
|
|
8
8
|
const { session } = useFeature(WbPageReviewFeature);
|
|
9
9
|
if ("noWorkflow" === session.presenter.vm.status) return props.element ?? null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageBasePublishDecorator.js","sources":["../../../src/Components/PageEditor/PageBasePublishDecorator.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReviewFeature } from \"~/features/editorReview/feature.js\";\n\nconst { Ui } = PageEditorConfig;\n\ninterface BasePublishGateProps {\n element?: React.ReactElement | null;\n}\n\nconst BasePublishGate = createReactiveComponent((props: BasePublishGateProps) => {\n const { session } = useFeature(WbPageReviewFeature);\n\n if (session.presenter.vm.status === \"noWorkflow\") {\n return props.element ?? null;\n }\n\n return null;\n});\n\n/*\n * Hides the base Publish for every page of a namespace that has a workflow; the workflows Publish\n * (`buttonWorkflowPublish`) takes over there. The one decoration of `buttonPublish` (A78).\n */\nexport const PageBasePublishDecorator = Ui.TopBar.Action.createDecorator(Original => {\n return function PageBasePublishDecoratorAction(props) {\n if (props.name === \"buttonPublish\") {\n return <Original {...props} element={<BasePublishGate element={props.element} />} />;\n }\n return <Original {...props} />;\n };\n});\n"],"names":["Ui","PageEditorConfig","BasePublishGate","createReactiveComponent","props","session","useFeature","WbPageReviewFeature","PageBasePublishDecorator","Original"],"mappings":";;;;;AAMA,MAAM,EAAEA,
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageBasePublishDecorator.js","sources":["../../../src/Components/PageEditor/PageBasePublishDecorator.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReviewFeature } from \"~/features/editorReview/feature.js\";\n\nconst { Ui } = PageEditorConfig;\n\ninterface BasePublishGateProps {\n element?: React.ReactElement | null;\n}\n\nconst BasePublishGate = createReactiveComponent((props: BasePublishGateProps) => {\n const { session } = useFeature(WbPageReviewFeature);\n\n if (session.presenter.vm.status === \"noWorkflow\") {\n return props.element ?? null;\n }\n\n return null;\n});\n\n/*\n * Hides the base Publish for every page of a namespace that has a workflow; the workflows Publish\n * (`buttonWorkflowPublish`) takes over there. The one decoration of `buttonPublish` (A78).\n */\nexport const PageBasePublishDecorator = Ui.TopBar.Action.createDecorator(Original => {\n return function PageBasePublishDecoratorAction(props) {\n if (props.name === \"buttonPublish\") {\n return <Original {...props} element={<BasePublishGate element={props.element} />} />;\n }\n return <Original {...props} />;\n };\n});\n"],"names":["Ui","PageEditorConfig","BasePublishGate","createReactiveComponent","props","session","useFeature","WbPageReviewFeature","PageBasePublishDecorator","Original"],"mappings":";;;;;AAMA,MAAM,EAAEA,EAAE,EAAE,GAAGC;AAMf,MAAMC,kBAAkBC,wBAAwB,CAACC;IAC7C,MAAM,EAAEC,OAAO,EAAE,GAAGC,WAAWC;IAE/B,IAAIF,AAAgC,iBAAhCA,QAAQ,SAAS,CAAC,EAAE,CAAC,MAAM,EAC3B,OAAOD,MAAM,OAAO,IAAI;IAG5B,OAAO;AACX;AAMO,MAAMI,2BAA2BR,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAACS,CAAAA,WAC9D,SAAwCL,KAAK;QAChD,IAAIA,AAAe,oBAAfA,MAAM,IAAI,EACV,OAAO,WAAP,GAAO,oBAACK,UAAAA;YAAU,GAAGL,KAAK;YAAE,uBAAS,oBAACF,iBAAAA;gBAAgB,SAASE,MAAM,OAAO;;;QAEhF,OAAO,WAAP,GAAO,oBAACK,UAAaL;IACzB"}
|
|
@@ -3,7 +3,7 @@ import { useFeature } from "@webiny/app";
|
|
|
3
3
|
import { createReactiveComponent } from "@webiny/app-admin";
|
|
4
4
|
import { PageEditorConfig } from "@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js";
|
|
5
5
|
import { WbPageReviewFeature } from "../../features/editorReview/feature.js";
|
|
6
|
-
const { Ui
|
|
6
|
+
const { Ui } = PageEditorConfig;
|
|
7
7
|
const AutoSaveGate = createReactiveComponent((props)=>{
|
|
8
8
|
const { session } = useFeature(WbPageReviewFeature);
|
|
9
9
|
if (session.presenter.vm.allowsEditing) return props.element ?? null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageEditorAutoSave.js","sources":["../../../src/Components/PageEditor/PageEditorAutoSave.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReviewFeature } from \"~/features/editorReview/feature.js\";\n\nconst { Ui } = PageEditorConfig;\n\ninterface AutoSaveGateProps {\n element?: React.ReactElement | null;\n}\n\nconst AutoSaveGate = createReactiveComponent((props: AutoSaveGateProps) => {\n const { session } = useFeature(WbPageReviewFeature);\n\n /*\n * Autosave runs only while editing is allowed: never while a review exists and never while the\n * review status is loading or failed.\n */\n if (session.presenter.vm.allowsEditing) {\n return props.element ?? null;\n }\n\n return null;\n});\n\nexport const PageEditorAutoSave = Ui.TopBar.Element.createDecorator(Original => {\n return function PageEditorAutoSaveDecorated(props) {\n if (props.name === \"autoSave\") {\n return <Original {...props} element={<AutoSaveGate element={props.element} />} />;\n }\n return <Original {...props} />;\n };\n});\n"],"names":["Ui","PageEditorConfig","AutoSaveGate","createReactiveComponent","props","session","useFeature","WbPageReviewFeature","PageEditorAutoSave","Original"],"mappings":";;;;;AAMA,MAAM,EAAEA,
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageEditorAutoSave.js","sources":["../../../src/Components/PageEditor/PageEditorAutoSave.tsx"],"sourcesContent":["import React from \"react\";\nimport { useFeature } from \"@webiny/app\";\nimport { createReactiveComponent } from \"@webiny/app-admin\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReviewFeature } from \"~/features/editorReview/feature.js\";\n\nconst { Ui } = PageEditorConfig;\n\ninterface AutoSaveGateProps {\n element?: React.ReactElement | null;\n}\n\nconst AutoSaveGate = createReactiveComponent((props: AutoSaveGateProps) => {\n const { session } = useFeature(WbPageReviewFeature);\n\n /*\n * Autosave runs only while editing is allowed: never while a review exists and never while the\n * review status is loading or failed.\n */\n if (session.presenter.vm.allowsEditing) {\n return props.element ?? null;\n }\n\n return null;\n});\n\nexport const PageEditorAutoSave = Ui.TopBar.Element.createDecorator(Original => {\n return function PageEditorAutoSaveDecorated(props) {\n if (props.name === \"autoSave\") {\n return <Original {...props} element={<AutoSaveGate element={props.element} />} />;\n }\n return <Original {...props} />;\n };\n});\n"],"names":["Ui","PageEditorConfig","AutoSaveGate","createReactiveComponent","props","session","useFeature","WbPageReviewFeature","PageEditorAutoSave","Original"],"mappings":";;;;;AAMA,MAAM,EAAEA,EAAE,EAAE,GAAGC;AAMf,MAAMC,eAAeC,wBAAwB,CAACC;IAC1C,MAAM,EAAEC,OAAO,EAAE,GAAGC,WAAWC;IAM/B,IAAIF,QAAQ,SAAS,CAAC,EAAE,CAAC,aAAa,EAClC,OAAOD,MAAM,OAAO,IAAI;IAG5B,OAAO;AACX;AAEO,MAAMI,qBAAqBR,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAACS,CAAAA,WACzD,SAAqCL,KAAK;QAC7C,IAAIA,AAAe,eAAfA,MAAM,IAAI,EACV,OAAO,WAAP,GAAO,oBAACK,UAAAA;YAAU,GAAGL,KAAK;YAAE,uBAAS,oBAACF,cAAAA;gBAAa,SAASE,MAAM,OAAO;;;QAE7E,OAAO,WAAP,GAAO,oBAACK,UAAaL;IACzB"}
|
|
@@ -8,7 +8,7 @@ import { WbEditorHarness } from "../../testing/WbEditorHarness.js";
|
|
|
8
8
|
import { createFakeSession } from "../../testing/createFakeSession.js";
|
|
9
9
|
import { createPageEditor } from "../../testing/createPageEditor.js";
|
|
10
10
|
import { PageEditorAutoSave } from "./PageEditorAutoSave.js";
|
|
11
|
-
const { Ui
|
|
11
|
+
const { Ui } = PageEditorConfig;
|
|
12
12
|
const mountAutoSave = (kind)=>{
|
|
13
13
|
const handle = createFakeSession(kind);
|
|
14
14
|
const container = new Container();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageEditorAutoSave.test.js","sources":["../../../src/Components/PageEditor/PageEditorAutoSave.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { waitFor } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { InternalPageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageEditorAutoSave } from \"./PageEditorAutoSave.js\";\n\nconst { Ui } = PageEditorConfig;\n\nconst mountAutoSave = (kind: FakeReviewKind) => {\n const handle = createFakeSession(kind);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n const editor = createPageEditor(\"draft\");\n\n render(\n <WbEditorHarness container={container} editor={editor} groups={[\"left\"]}>\n <PageEditorAutoSave />\n <InternalPageEditorConfig>\n <Ui.TopBar.Element\n group={\"left\"}\n name={\"sentinel\"}\n element={<span data-testid={\"sentinel\"} />}\n />\n <Ui.TopBar.Element\n group={\"left\"}\n name={\"title\"}\n element={<span data-testid={\"title\"} />}\n />\n <Ui.TopBar.Element\n group={\"left\"}\n name={\"autoSave\"}\n element={<span data-testid={\"autosave\"} />}\n />\n </InternalPageEditorConfig>\n </WbEditorHarness>\n );\n\n return handle;\n};\n\ninterface AutoSaveCase {\n kind: FakeReviewKind;\n on: boolean;\n}\n\nconst CASES: AutoSaveCase[] = [\n { kind: \"loading\", on: false },\n { kind: \"failed\", on: false },\n { kind: \"noWorkflow\", on: true },\n { kind: \"none\", on: true },\n { kind: \"inProgress\", on: false },\n { kind: \"approved\", on: false },\n { kind: \"rejected\", on: false }\n];\n\ndescribe(\"PageEditorAutoSave\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it.each(CASES)(\"$kind review: autosave on is $on\", async ({ kind, on }) => {\n mountAutoSave(kind);\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"autosave\")).toHaveLength(on ? 1 : 0);\n });\n });\n\n it(\"leaves every other top bar element alone\", async () => {\n mountAutoSave(\"loading\");\n await screen.findByTestId(\"sentinel\");\n\n expect(screen.queryAllByTestId(\"title\")).toHaveLength(1);\n });\n\n it(\"turns autosave off when a review starts and on again when it ends\", async () => {\n const { setKind } = mountAutoSave(\"none\");\n await screen.findByTestId(\"sentinel\");\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"autosave\")).toHaveLength(1);\n });\n\n act(() => {\n setKind(\"inProgress\");\n });\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"autosave\")).toHaveLength(0);\n });\n\n act(() => {\n setKind(\"none\");\n });\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"autosave\")).toHaveLength(1);\n });\n });\n});\n"],"names":["Ui","PageEditorConfig","mountAutoSave","kind","handle","createFakeSession","container","Container","WbPageReview","editor","createPageEditor","render","WbEditorHarness","PageEditorAutoSave","InternalPageEditorConfig","CASES","describe","afterEach","cleanup","it","on","screen","waitFor","expect","setKind","act"],"mappings":";;;;;;;;;;AAoBA,MAAM,EAAEA,
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageEditorAutoSave.test.js","sources":["../../../src/Components/PageEditor/PageEditorAutoSave.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { waitFor } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { InternalPageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageEditorAutoSave } from \"./PageEditorAutoSave.js\";\n\nconst { Ui } = PageEditorConfig;\n\nconst mountAutoSave = (kind: FakeReviewKind) => {\n const handle = createFakeSession(kind);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n const editor = createPageEditor(\"draft\");\n\n render(\n <WbEditorHarness container={container} editor={editor} groups={[\"left\"]}>\n <PageEditorAutoSave />\n <InternalPageEditorConfig>\n <Ui.TopBar.Element\n group={\"left\"}\n name={\"sentinel\"}\n element={<span data-testid={\"sentinel\"} />}\n />\n <Ui.TopBar.Element\n group={\"left\"}\n name={\"title\"}\n element={<span data-testid={\"title\"} />}\n />\n <Ui.TopBar.Element\n group={\"left\"}\n name={\"autoSave\"}\n element={<span data-testid={\"autosave\"} />}\n />\n </InternalPageEditorConfig>\n </WbEditorHarness>\n );\n\n return handle;\n};\n\ninterface AutoSaveCase {\n kind: FakeReviewKind;\n on: boolean;\n}\n\nconst CASES: AutoSaveCase[] = [\n { kind: \"loading\", on: false },\n { kind: \"failed\", on: false },\n { kind: \"noWorkflow\", on: true },\n { kind: \"none\", on: true },\n { kind: \"inProgress\", on: false },\n { kind: \"approved\", on: false },\n { kind: \"rejected\", on: false }\n];\n\ndescribe(\"PageEditorAutoSave\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it.each(CASES)(\"$kind review: autosave on is $on\", async ({ kind, on }) => {\n mountAutoSave(kind);\n await screen.findByTestId(\"sentinel\");\n\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"autosave\")).toHaveLength(on ? 1 : 0);\n });\n });\n\n it(\"leaves every other top bar element alone\", async () => {\n mountAutoSave(\"loading\");\n await screen.findByTestId(\"sentinel\");\n\n expect(screen.queryAllByTestId(\"title\")).toHaveLength(1);\n });\n\n it(\"turns autosave off when a review starts and on again when it ends\", async () => {\n const { setKind } = mountAutoSave(\"none\");\n await screen.findByTestId(\"sentinel\");\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"autosave\")).toHaveLength(1);\n });\n\n act(() => {\n setKind(\"inProgress\");\n });\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"autosave\")).toHaveLength(0);\n });\n\n act(() => {\n setKind(\"none\");\n });\n await waitFor(() => {\n expect(screen.queryAllByTestId(\"autosave\")).toHaveLength(1);\n });\n });\n});\n"],"names":["Ui","PageEditorConfig","mountAutoSave","kind","handle","createFakeSession","container","Container","WbPageReview","editor","createPageEditor","render","WbEditorHarness","PageEditorAutoSave","InternalPageEditorConfig","CASES","describe","afterEach","cleanup","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Aa,YAAY,CAACD,KAAK,IAAI;QACtE;IACJ;IAEAD,GAAG,4CAA4C;QAC3CjB,cAAc;QACd,MAAMmB,OAAO,YAAY,CAAC;QAE1BE,OAAOF,OAAO,gBAAgB,CAAC,UAAU,YAAY,CAAC;IAC1D;IAEAF,GAAG,qEAAqE;QACpE,MAAM,EAAEK,OAAO,EAAE,GAAGtB,cAAc;QAClC,MAAMmB,OAAO,YAAY,CAAC;QAC1B,MAAMC,QAAQ;YACVC,OAAOF,OAAO,gBAAgB,CAAC,aAAa,YAAY,CAAC;QAC7D;QAEAI,IAAI;YACAD,QAAQ;QACZ;QACA,MAAMF,QAAQ;YACVC,OAAOF,OAAO,gBAAgB,CAAC,aAAa,YAAY,CAAC;QAC7D;QAEAI,IAAI;YACAD,QAAQ;QACZ;QACA,MAAMF,QAAQ;YACVC,OAAOF,OAAO,gBAAgB,CAAC,aAAa,YAAY,CAAC;QAC7D;IACJ;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { PageEditorConfig } from "@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js";
|
|
3
3
|
import { PageReadOnlySync } from "./PageReadOnlySync.js";
|
|
4
|
-
const { Ui
|
|
4
|
+
const { Ui } = PageEditorConfig;
|
|
5
5
|
const PageEditorLayout = Ui.Layout.createDecorator((Original)=>function() {
|
|
6
6
|
return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Original, null), /*#__PURE__*/ react.createElement(PageReadOnlySync, null));
|
|
7
7
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageEditorLayout.js","sources":["../../../src/Components/PageEditor/PageEditorLayout.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageReadOnlySync } from \"./PageReadOnlySync.js\";\n\nconst { Ui } = PageEditorConfig;\n\nexport const PageEditorLayout = Ui.Layout.createDecorator(Original => {\n return function PageEditorLayoutReview() {\n return (\n <>\n <Original />\n <PageReadOnlySync />\n </>\n );\n };\n});\n"],"names":["Ui","PageEditorConfig","PageEditorLayout","Original","PageReadOnlySync"],"mappings":";;;AAIA,MAAM,EAAEA,
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageEditorLayout.js","sources":["../../../src/Components/PageEditor/PageEditorLayout.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageReadOnlySync } from \"./PageReadOnlySync.js\";\n\nconst { Ui } = PageEditorConfig;\n\nexport const PageEditorLayout = Ui.Layout.createDecorator(Original => {\n return function PageEditorLayoutReview() {\n return (\n <>\n <Original />\n <PageReadOnlySync />\n </>\n );\n };\n});\n"],"names":["Ui","PageEditorConfig","PageEditorLayout","Original","PageReadOnlySync"],"mappings":";;;AAIA,MAAM,EAAEA,EAAE,EAAE,GAAGC;AAER,MAAMC,mBAAmBF,GAAG,MAAM,CAAC,eAAe,CAACG,CAAAA,WAC/C;QACH,OAAO,WAAP,GACI,wDACI,oBAACA,UAAAA,OAAAA,WAAAA,GACD,oBAACC,kBAAgBA;IAG7B"}
|
|
@@ -18,7 +18,7 @@ vi.mock("@webiny/app-website-builder/BaseEditor/config/Layout.js", async ()=>{
|
|
|
18
18
|
Layout
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
|
-
const { Ui
|
|
21
|
+
const { Ui } = PageEditorConfig;
|
|
22
22
|
const mountLayout = (pageStatus, kind)=>{
|
|
23
23
|
const handle = createFakeSession(kind);
|
|
24
24
|
const container = new Container();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageEditorLayout.test.js","sources":["../../../src/Components/PageEditor/PageEditorLayout.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageEditorLayout } from \"./PageEditorLayout.js\";\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"EditorLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-layout\" });\n });\n return { Layout };\n});\n\nconst { Ui } = PageEditorConfig;\n\nconst mountLayout = (pageStatus: WbStatus, kind: FakeReviewKind) => {\n const handle = createFakeSession(kind);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n const editor = createPageEditor(pageStatus);\n\n render(\n <WbEditorHarness container={container} editor={editor}>\n <PageEditorLayout />\n <Ui.Layout />\n </WbEditorHarness>\n );\n\n return { ...handle, editor };\n};\n\ninterface ReadOnlyCase {\n kind: FakeReviewKind;\n page: WbStatus;\n readOnly: boolean;\n}\n\nconst CASES: ReadOnlyCase[] = [\n { kind: \"loading\", page: \"draft\", readOnly: true },\n { kind: \"failed\", page: \"draft\", readOnly: true },\n { kind: \"noWorkflow\", page: \"draft\", readOnly: false },\n { kind: \"none\", page: \"draft\", readOnly: false },\n { kind: \"inProgress\", page: \"draft\", readOnly: true },\n { kind: \"approved\", page: \"draft\", readOnly: true },\n { kind: \"rejected\", page: \"draft\", readOnly: true },\n { kind: \"noWorkflow\", page: \"published\", readOnly: true },\n { kind: \"none\", page: \"published\", readOnly: true },\n { kind: \"none\", page: \"unpublished\", readOnly: true }\n];\n\ndescribe(\"PageEditorLayout\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it(\"renders the original layout\", () => {\n mountLayout(\"draft\", \"none\");\n\n expect(screen.getAllByTestId(\"base-layout\")).toHaveLength(1);\n });\n\n it.each(CASES)(\n \"$kind review on a $page page: canvas read-only is $readOnly\",\n ({ kind, page, readOnly }) => {\n const { editor } = mountLayout(page, kind);\n\n expect(editor.getEditorState().read().isReadOnly).toBe(readOnly);\n }\n );\n\n it(\"follows the review state while the editor is open (the one source of the flag)\", () => {\n const { editor, setKind } = mountLayout(\"draft\", \"none\");\n expect(editor.getEditorState().read().isReadOnly).toBe(false);\n\n act(() => {\n setKind(\"inProgress\");\n });\n expect(editor.getEditorState().read().isReadOnly).toBe(true);\n\n act(() => {\n setKind(\"none\");\n });\n expect(editor.getEditorState().read().isReadOnly).toBe(false);\n });\n\n it(\"never opens a canvas the editor was created read-only\", () => {\n const { editor, setKind } = mountLayout(\"published\", \"none\");\n\n act(() => {\n setKind(\"noWorkflow\");\n });\n\n expect(editor.getEditorState().read().isReadOnly).toBe(true);\n });\n});\n"],"names":["vi","React","makeDecoratable","Layout","Ui","PageEditorConfig","mountLayout","pageStatus","kind","handle","createFakeSession","container","Container","WbPageReview","editor","createPageEditor","render","WbEditorHarness","PageEditorLayout","CASES","describe","afterEach","cleanup","it","expect","screen","page","readOnly","setKind","act"],"mappings":";;;;;;;;;;AAoBAA,GAAG,IAAI,CAAC,2DAA2D;IAC/D,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;IACzC,MAAMC,SAASD,gBAAgB,gBAAgB,IACpCD,MAAM,aAAa,CAAC,OAAO;YAAE,eAAe;QAAc;IAErE,OAAO;QAAEE;IAAO;AACpB;AAEA,MAAM,EAAEC,
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageEditorLayout.test.js","sources":["../../../src/Components/PageEditor/PageEditorLayout.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageEditorLayout } from \"./PageEditorLayout.js\";\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"EditorLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-layout\" });\n });\n return { Layout };\n});\n\nconst { Ui } = PageEditorConfig;\n\nconst mountLayout = (pageStatus: WbStatus, kind: FakeReviewKind) => {\n const handle = createFakeSession(kind);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n const editor = createPageEditor(pageStatus);\n\n render(\n <WbEditorHarness container={container} editor={editor}>\n <PageEditorLayout />\n <Ui.Layout />\n </WbEditorHarness>\n );\n\n return { ...handle, editor };\n};\n\ninterface ReadOnlyCase {\n kind: FakeReviewKind;\n page: WbStatus;\n readOnly: boolean;\n}\n\nconst CASES: ReadOnlyCase[] = [\n { kind: \"loading\", page: \"draft\", readOnly: true },\n { kind: \"failed\", page: \"draft\", readOnly: true },\n { kind: \"noWorkflow\", page: \"draft\", readOnly: false },\n { kind: \"none\", page: \"draft\", readOnly: false },\n { kind: \"inProgress\", page: \"draft\", readOnly: true },\n { kind: \"approved\", page: \"draft\", readOnly: true },\n { kind: \"rejected\", page: \"draft\", readOnly: true },\n { kind: \"noWorkflow\", page: \"published\", readOnly: true },\n { kind: \"none\", page: \"published\", readOnly: true },\n { kind: \"none\", page: \"unpublished\", readOnly: true }\n];\n\ndescribe(\"PageEditorLayout\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it(\"renders the original layout\", () => {\n mountLayout(\"draft\", \"none\");\n\n expect(screen.getAllByTestId(\"base-layout\")).toHaveLength(1);\n });\n\n it.each(CASES)(\n \"$kind review on a $page page: canvas read-only is $readOnly\",\n ({ kind, page, readOnly }) => {\n const { editor } = mountLayout(page, kind);\n\n expect(editor.getEditorState().read().isReadOnly).toBe(readOnly);\n }\n );\n\n it(\"follows the review state while the editor is open (the one source of the flag)\", () => {\n const { editor, setKind } = mountLayout(\"draft\", \"none\");\n expect(editor.getEditorState().read().isReadOnly).toBe(false);\n\n act(() => {\n setKind(\"inProgress\");\n });\n expect(editor.getEditorState().read().isReadOnly).toBe(true);\n\n act(() => {\n setKind(\"none\");\n });\n expect(editor.getEditorState().read().isReadOnly).toBe(false);\n });\n\n it(\"never opens a canvas the editor was created read-only\", () => {\n const { editor, setKind } = mountLayout(\"published\", \"none\");\n\n act(() => {\n setKind(\"noWorkflow\");\n });\n\n expect(editor.getEditorState().read().isReadOnly).toBe(true);\n });\n});\n"],"names":["vi","React","makeDecoratable","Layout","Ui","PageEditorConfig","mountLayout","pageStatus","kind","handle","createFakeSession","container","Container","WbPageReview","editor","createPageEditor","render","WbEditorHarness","PageEditorLayout","CASES","describe","afterEach","cleanup","it","expect","screen","page","readOnly","setKind","act"],"mappings":";;;;;;;;;;AAoBAA,G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QAErBkB,OAAOC,OAAO,cAAc,CAAC,gBAAgB,YAAY,CAAC;IAC9D;IAEAF,GAAG,IAAI,CAACJ,OACJ,+DACA,CAAC,EAAEX,IAAI,EAAEkB,IAAI,EAAEC,QAAQ,EAAE;QACrB,MAAM,EAAEb,MAAM,EAAE,GAAGR,YAAYoB,MAAMlB;QAErCgB,OAAOV,OAAO,cAAc,GAAG,IAAI,GAAG,UAAU,EAAE,IAAI,CAACa;IAC3D;IAGJJ,GAAG,kFAAkF;QACjF,MAAM,EAAET,MAAM,EAAEc,OAAO,EAAE,GAAGtB,YAAY,SAAS;QACjDkB,OAAOV,OAAO,cAAc,GAAG,IAAI,GAAG,UAAU,EAAE,IAAI,CAAC;QAEvDe,IAAI;YACAD,QAAQ;QACZ;QACAJ,OAAOV,OAAO,cAAc,GAAG,IAAI,GAAG,UAAU,EAAE,IAAI,CAAC;QAEvDe,IAAI;YACAD,QAAQ;QACZ;QACAJ,OAAOV,OAAO,cAAc,GAAG,IAAI,GAAG,UAAU,EAAE,IAAI,CAAC;IAC3D;IAEAS,GAAG,yDAAyD;QACxD,MAAM,EAAET,MAAM,EAAEc,OAAO,EAAE,GAAGtB,YAAY,aAAa;QAErDuB,IAAI;YACAD,QAAQ;QACZ;QAEAJ,OAAOV,OAAO,cAAc,GAAG,IAAI,GAAG,UAAU,EAAE,IAAI,CAAC;IAC3D;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { PageEditorConfig } from "@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js";
|
|
3
3
|
import { PageReviewBar } from "./PageReviewBar.js";
|
|
4
|
-
const { Ui
|
|
4
|
+
const { Ui } = PageEditorConfig;
|
|
5
5
|
const PageEditorTopBar = Ui.TopBar.Layout.createDecorator((Original)=>function() {
|
|
6
6
|
return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(Original, null), /*#__PURE__*/ react.createElement(PageReviewBar, null));
|
|
7
7
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageEditorTopBar.js","sources":["../../../src/Components/PageEditor/PageEditorTopBar.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageReviewBar } from \"./PageReviewBar.js\";\n\nconst { Ui } = PageEditorConfig;\n\nexport const PageEditorTopBar = Ui.TopBar.Layout.createDecorator(Original => {\n return function PageEditorTopBarReview() {\n return (\n <>\n <Original />\n <PageReviewBar />\n </>\n );\n };\n});\n"],"names":["Ui","PageEditorConfig","PageEditorTopBar","Original","PageReviewBar"],"mappings":";;;AAIA,MAAM,EAAEA,
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageEditorTopBar.js","sources":["../../../src/Components/PageEditor/PageEditorTopBar.tsx"],"sourcesContent":["import React from \"react\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { PageReviewBar } from \"./PageReviewBar.js\";\n\nconst { Ui } = PageEditorConfig;\n\nexport const PageEditorTopBar = Ui.TopBar.Layout.createDecorator(Original => {\n return function PageEditorTopBarReview() {\n return (\n <>\n <Original />\n <PageReviewBar />\n </>\n );\n };\n});\n"],"names":["Ui","PageEditorConfig","PageEditorTopBar","Original","PageReviewBar"],"mappings":";;;AAIA,MAAM,EAAEA,EAAE,EAAE,GAAGC;AAER,MAAMC,mBAAmBF,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAACG,CAAAA,WACtD;QACH,OAAO,WAAP,GACI,wDACI,oBAACA,UAAAA,OAAAA,WAAAA,GACD,oBAACC,eAAaA;IAG1B"}
|
|
@@ -36,7 +36,7 @@ vi.mock("@webiny/app-workflows/review/editor/components/EditorReviewBar.js", asy
|
|
|
36
36
|
EditorReviewBar
|
|
37
37
|
};
|
|
38
38
|
});
|
|
39
|
-
const { Ui
|
|
39
|
+
const { Ui } = PageEditorConfig;
|
|
40
40
|
const mountTopBar = (pageStatus, kind)=>{
|
|
41
41
|
const handle = createFakeSession(kind);
|
|
42
42
|
const container = new Container();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Components/PageEditor/PageEditorTopBar.test.js","sources":["../../../src/Components/PageEditor/PageEditorTopBar.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { waitFor } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport type { Route } from \"@webiny/app-admin\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageStatus } from \"@webiny/app-website-builder/constants.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbPageUnsavedChanges } from \"~/features/editorReview/WbPageUnsavedChanges.js\";\nimport { WbPageContentReloader } from \"~/features/editorReview/WbPageContentReloader.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport { registerPageContent } from \"~/testing/registerPageContent.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageEditorTopBar } from \"./PageEditorTopBar.js\";\n\nvi.mock(\"@webiny/icons/info.svg\", () => {\n return { ReactComponent: () => null };\n});\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/TopBar/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"TopBarLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-top-bar\" });\n });\n return { Layout, TopBarOptionsMenu: () => null };\n});\n\nvi.mock(\"@webiny/app-workflows/review/editor/components/EditorReviewBar.js\", async () => {\n const React = await import(\"react\");\n interface StubProps {\n reviewsRoute: Route<any>;\n }\n const EditorReviewBar = (props: StubProps) => {\n return React.createElement(\"div\", {\n \"data-testid\": \"review-bar\",\n \"data-route\": props.reviewsRoute.name\n });\n };\n return { EditorReviewBar };\n});\n\nconst { Ui } = PageEditorConfig;\n\nconst mountTopBar = (pageStatus: WbStatus, kind: FakeReviewKind) => {\n const handle = createFakeSession(kind);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n registerPageContent(container);\n const editor = createPageEditor(pageStatus);\n\n const view = render(\n <WbEditorHarness container={container} editor={editor}>\n <PageEditorTopBar />\n <Ui.TopBar.Layout />\n </WbEditorHarness>\n );\n\n return { ...handle, editor, view };\n};\n\ndescribe(\"PageEditorTopBar\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it(\"renders the original top bar and exactly one review bar in a strip that reserves its height\", () => {\n mountTopBar(\"draft\", \"none\");\n\n expect(screen.getAllByTestId(\"base-top-bar\")).toHaveLength(1);\n const bars = screen.getAllByTestId(\"review-bar\");\n expect(bars).toHaveLength(1);\n expect(bars[0].getAttribute(\"data-route\")).toBe(\"WebsiteBuilder/Pages/WorkflowStateList\");\n const strip = bars[0].parentElement;\n expect(strip?.getAttribute(\"data-affects-preview\")).toBe(\"height\");\n });\n\n it.each([\"draft\", \"published\", \"unpublished\"] as const)(\n \"shows the bar on a %s page\",\n pageStatus => {\n mountTopBar(pageStatus, \"none\");\n\n expect(screen.getAllByTestId(\"review-bar\")).toHaveLength(1);\n }\n );\n\n it(\"renders nothing, not even the strip, when the namespace has no workflow\", () => {\n mountTopBar(\"draft\", \"noWorkflow\");\n\n expect(screen.queryByTestId(\"review-bar\")).toBeNull();\n expect(document.querySelector(\"[data-affects-preview]\")).toBeNull();\n expect(screen.getAllByTestId(\"base-top-bar\")).toHaveLength(1);\n });\n\n it(\"initialises the session for the draft revision with the editor's own read-only state\", () => {\n const { presenter } = mountTopBar(\"draft\", \"none\");\n\n expect(presenter.init).toHaveBeenCalledTimes(1);\n expect(presenter.init).toHaveBeenCalledWith({\n target: { namespace: \"wb.page\", targetRevisionId: \"page-1#0001\" },\n contentReloader: expect.any(WbPageContentReloader),\n unsavedChanges: expect.any(WbPageUnsavedChanges),\n targetTitle: \"Home\",\n canRequest: true,\n isPublished: false,\n isUnpublished: false\n });\n });\n\n it(\"cannot request a review on a published page and marks it published\", () => {\n const { presenter } = mountTopBar(\"published\", \"none\");\n\n expect(presenter.init).toHaveBeenCalledWith({\n target: { namespace: \"wb.page\", targetRevisionId: \"page-1#0001\" },\n contentReloader: expect.any(WbPageContentReloader),\n unsavedChanges: expect.any(WbPageUnsavedChanges),\n targetTitle: \"Home\",\n canRequest: false,\n isPublished: true,\n isUnpublished: false\n });\n });\n\n it(\"cannot request a review on an unpublished page, which was published before (Q19)\", () => {\n const { presenter } = mountTopBar(\"unpublished\", \"none\");\n\n const params = presenter.init.mock.calls[0][0];\n expect(params.canRequest).toBe(false);\n expect(params.isPublished).toBe(false);\n expect(params.isUnpublished).toBe(true);\n });\n\n it(\"updates the context without a reload when the page is published\", async () => {\n const { presenter, editor } = mountTopBar(\"draft\", \"none\");\n\n act(() => {\n editor.updateDocument(state => {\n state.status = WbPageStatus.Published;\n });\n });\n\n await waitFor(() => {\n expect(presenter.setContext).toHaveBeenLastCalledWith({\n targetTitle: \"Home\",\n canRequest: true,\n isPublished: true,\n isUnpublished: false\n });\n });\n expect(presenter.init).toHaveBeenCalledTimes(1);\n expect(presenter.dispose).not.toHaveBeenCalled();\n });\n\n it(\"updates the context with the new title when the page is renamed\", async () => {\n const { presenter, editor } = mountTopBar(\"draft\", \"none\");\n\n act(() => {\n editor.updateDocument(state => {\n state.properties.title = \"Renamed home\";\n });\n });\n\n await waitFor(() => {\n expect(presenter.setContext).toHaveBeenLastCalledWith({\n targetTitle: \"Renamed home\",\n canRequest: true,\n isPublished: false,\n isUnpublished: false\n });\n });\n expect(presenter.init).toHaveBeenCalledTimes(1);\n });\n\n it(\"updates the context without a reload when the page is unpublished (Q19)\", async () => {\n const { presenter, editor } = mountTopBar(\"published\", \"approved\");\n\n act(() => {\n editor.updateDocument(state => {\n state.status = WbPageStatus.Unpublished;\n });\n });\n\n await waitFor(() => {\n expect(presenter.setContext).toHaveBeenLastCalledWith({\n targetTitle: \"Home\",\n canRequest: false,\n isPublished: false,\n isUnpublished: true\n });\n });\n expect(presenter.init).toHaveBeenCalledTimes(1);\n });\n});\n"],"names":["vi","React","makeDecoratable","Layout","EditorReviewBar","props","Ui","PageEditorConfig","mountTopBar","pageStatus","kind","handle","createFakeSession","container","Container","WbPageReview","registerPageContent","editor","createPageEditor","view","render","WbEditorHarness","PageEditorTopBar","describe","afterEach","cleanup","it","expect","screen","bars","strip","document","presenter","WbPageContentReloader","WbPageUnsavedChanges","params","act","state","WbPageStatus","waitFor"],"mappings":";;;;;;;;;;;;;;AA0BAA,GAAG,IAAI,CAAC,0BAA0B,IACvB;QAAE,gBAAgB,IAAM;IAAK;AAGxCA,GAAG,IAAI,CAAC,kEAAkE;IACtE,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;IACzC,MAAMC,SAASD,gBAAgB,gBAAgB,IACpCD,MAAM,aAAa,CAAC,OAAO;YAAE,eAAe;QAAe;IAEtE,OAAO;QAAEE;QAAQ,mBAAmB,IAAM;IAAK;AACnD;AAEAH,GAAG,IAAI,CAAC,qEAAqE;IACzE,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAI3B,MAAMG,kBAAkB,CAACC,QACdJ,MAAM,aAAa,CAAC,OAAO;YAC9B,eAAe;YACf,cAAcI,MAAM,YAAY,CAAC,IAAI;QACzC;IAEJ,OAAO;QAAED;IAAgB;AAC7B;AAEA,MA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,EAAE,qBAAqB,CAAC;QAC7CL,OAAOK,UAAU,OAAO,EAAE,GAAG,CAAC,gBAAgB;IAClD;IAEAN,GAAG,mEAAmE;QAClE,MAAM,EAAEM,SAAS,EAAEf,MAAM,EAAE,GAAGT,YAAY,SAAS;QAEnD4B,IAAI;YACAnB,OAAO,cAAc,CAACoB,CAAAA;gBAClBA,MAAM,UAAU,CAAC,KAAK,GAAG;YAC7B;QACJ;QAEA,MAAME,QAAQ;YACVZ,OAAOK,UAAU,UAAU,EAAE,wBAAwB,CAAC;gBAClD,aAAa;gBACb,YAAY;gBACZ,aAAa;gBACb,eAAe;YACnB;QACJ;QACAL,OAAOK,UAAU,IAAI,EAAE,qBAAqB,CAAC;IACjD;IAEAN,GAAG,2EAA2E;QAC1E,MAAM,EAAEM,SAAS,EAAEf,MAAM,EAAE,GAAGT,YAAY,aAAa;QAEvD4B,IAAI;YACAnB,OAAO,cAAc,CAACoB,CAAAA;gBAClBA,MAAM,MAAM,GAAGC,aAAa,WAAW;YAC3C;QACJ;QAEA,MAAMC,QAAQ;YACVZ,OAAOK,UAAU,UAAU,EAAE,wBAAwB,CAAC;gBAClD,aAAa;gBACb,YAAY;gBACZ,aAAa;gBACb,eAAe;YACnB;QACJ;QACAL,OAAOK,UAAU,IAAI,EAAE,qBAAqB,CAAC;IACjD;AACJ"}
|
|
1
|
+
{"version":3,"file":"Components/PageEditor/PageEditorTopBar.test.js","sources":["../../../src/Components/PageEditor/PageEditorTopBar.test.tsx"],"sourcesContent":["import React from \"react\";\nimport { act } from \"@testing-library/react\";\nimport { cleanup } from \"@testing-library/react\";\nimport { render } from \"@testing-library/react\";\nimport { screen } from \"@testing-library/react\";\nimport { waitFor } from \"@testing-library/react\";\nimport { afterEach } from \"vitest\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport { Container } from \"@webiny/di\";\nimport type { Route } from \"@webiny/app-admin\";\nimport { PageEditorConfig } from \"@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js\";\nimport { WbPageStatus } from \"@webiny/app-website-builder/constants.js\";\nimport type { WbStatus } from \"@webiny/app-website-builder/constants.js\";\nimport { WbPageReview } from \"~/features/editorReview/abstractions.js\";\nimport { WbPageUnsavedChanges } from \"~/features/editorReview/WbPageUnsavedChanges.js\";\nimport { WbPageContentReloader } from \"~/features/editorReview/WbPageContentReloader.js\";\nimport { WbEditorHarness } from \"~/testing/WbEditorHarness.js\";\nimport { createFakeSession } from \"~/testing/createFakeSession.js\";\nimport { createPageEditor } from \"~/testing/createPageEditor.js\";\nimport { registerPageContent } from \"~/testing/registerPageContent.js\";\nimport type { FakeReviewKind } from \"~/testing/createFakeVm.js\";\nimport { PageEditorTopBar } from \"./PageEditorTopBar.js\";\n\nvi.mock(\"@webiny/icons/info.svg\", () => {\n return { ReactComponent: () => null };\n});\n\nvi.mock(\"@webiny/app-website-builder/BaseEditor/config/TopBar/Layout.js\", async () => {\n const React = await import(\"react\");\n const { makeDecoratable } = await import(\"@webiny/react-composition\");\n const Layout = makeDecoratable(\"TopBarLayout\", () => {\n return React.createElement(\"div\", { \"data-testid\": \"base-top-bar\" });\n });\n return { Layout, TopBarOptionsMenu: () => null };\n});\n\nvi.mock(\"@webiny/app-workflows/review/editor/components/EditorReviewBar.js\", async () => {\n const React = await import(\"react\");\n interface StubProps {\n reviewsRoute: Route<any>;\n }\n const EditorReviewBar = (props: StubProps) => {\n return React.createElement(\"div\", {\n \"data-testid\": \"review-bar\",\n \"data-route\": props.reviewsRoute.name\n });\n };\n return { EditorReviewBar };\n});\n\nconst { Ui } = PageEditorConfig;\n\nconst mountTopBar = (pageStatus: WbStatus, kind: FakeReviewKind) => {\n const handle = createFakeSession(kind);\n const container = new Container();\n container.registerInstance(WbPageReview, handle.session);\n registerPageContent(container);\n const editor = createPageEditor(pageStatus);\n\n const view = render(\n <WbEditorHarness container={container} editor={editor}>\n <PageEditorTopBar />\n <Ui.TopBar.Layout />\n </WbEditorHarness>\n );\n\n return { ...handle, editor, view };\n};\n\ndescribe(\"PageEditorTopBar\", () => {\n afterEach(() => {\n cleanup();\n });\n\n it(\"renders the original top bar and exactly one review bar in a strip that reserves its height\", () => {\n mountTopBar(\"draft\", \"none\");\n\n expect(screen.getAllByTestId(\"base-top-bar\")).toHaveLength(1);\n const bars = screen.getAllByTestId(\"review-bar\");\n expect(bars).toHaveLength(1);\n expect(bars[0].getAttribute(\"data-route\")).toBe(\"WebsiteBuilder/Pages/WorkflowStateList\");\n const strip = bars[0].parentElement;\n expect(strip?.getAttribute(\"data-affects-preview\")).toBe(\"height\");\n });\n\n it.each([\"draft\", \"published\", \"unpublished\"] as const)(\n \"shows the bar on a %s page\",\n pageStatus => {\n mountTopBar(pageStatus, \"none\");\n\n expect(screen.getAllByTestId(\"review-bar\")).toHaveLength(1);\n }\n );\n\n it(\"renders nothing, not even the strip, when the namespace has no workflow\", () => {\n mountTopBar(\"draft\", \"noWorkflow\");\n\n expect(screen.queryByTestId(\"review-bar\")).toBeNull();\n expect(document.querySelector(\"[data-affects-preview]\")).toBeNull();\n expect(screen.getAllByTestId(\"base-top-bar\")).toHaveLength(1);\n });\n\n it(\"initialises the session for the draft revision with the editor's own read-only state\", () => {\n const { presenter } = mountTopBar(\"draft\", \"none\");\n\n expect(presenter.init).toHaveBeenCalledTimes(1);\n expect(presenter.init).toHaveBeenCalledWith({\n target: { namespace: \"wb.page\", targetRevisionId: \"page-1#0001\" },\n contentReloader: expect.any(WbPageContentReloader),\n unsavedChanges: expect.any(WbPageUnsavedChanges),\n targetTitle: \"Home\",\n canRequest: true,\n isPublished: false,\n isUnpublished: false\n });\n });\n\n it(\"cannot request a review on a published page and marks it published\", () => {\n const { presenter } = mountTopBar(\"published\", \"none\");\n\n expect(presenter.init).toHaveBeenCalledWith({\n target: { namespace: \"wb.page\", targetRevisionId: \"page-1#0001\" },\n contentReloader: expect.any(WbPageContentReloader),\n unsavedChanges: expect.any(WbPageUnsavedChanges),\n targetTitle: \"Home\",\n canRequest: false,\n isPublished: true,\n isUnpublished: false\n });\n });\n\n it(\"cannot request a review on an unpublished page, which was published before (Q19)\", () => {\n const { presenter } = mountTopBar(\"unpublished\", \"none\");\n\n const params = presenter.init.mock.calls[0][0];\n expect(params.canRequest).toBe(false);\n expect(params.isPublished).toBe(false);\n expect(params.isUnpublished).toBe(true);\n });\n\n it(\"updates the context without a reload when the page is published\", async () => {\n const { presenter, editor } = mountTopBar(\"draft\", \"none\");\n\n act(() => {\n editor.updateDocument(state => {\n state.status = WbPageStatus.Published;\n });\n });\n\n await waitFor(() => {\n expect(presenter.setContext).toHaveBeenLastCalledWith({\n targetTitle: \"Home\",\n canRequest: true,\n isPublished: true,\n isUnpublished: false\n });\n });\n expect(presenter.init).toHaveBeenCalledTimes(1);\n expect(presenter.dispose).not.toHaveBeenCalled();\n });\n\n it(\"updates the context with the new title when the page is renamed\", async () => {\n const { presenter, editor } = mountTopBar(\"draft\", \"none\");\n\n act(() => {\n editor.updateDocument(state => {\n state.properties.title = \"Renamed home\";\n });\n });\n\n await waitFor(() => {\n expect(presenter.setContext).toHaveBeenLastCalledWith({\n targetTitle: \"Renamed home\",\n canRequest: true,\n isPublished: false,\n isUnpublished: false\n });\n });\n expect(presenter.init).toHaveBeenCalledTimes(1);\n });\n\n it(\"updates the context without a reload when the page is unpublished (Q19)\", async () => {\n const { presenter, editor } = mountTopBar(\"published\", \"approved\");\n\n act(() => {\n editor.updateDocument(state => {\n state.status = WbPageStatus.Unpublished;\n });\n });\n\n await waitFor(() => {\n expect(presenter.setContext).toHaveBeenLastCalledWith({\n targetTitle: \"Home\",\n canRequest: false,\n isPublished: false,\n isUnpublished: true\n });\n });\n expect(presenter.init).toHaveBeenCalledTimes(1);\n });\n});\n"],"names":["vi","React","makeDecoratable","Layout","EditorReviewBar","props","Ui","PageEditorConfig","mountTopBar","pageStatus","kind","handle","createFakeSession","container","Container","WbPageReview","registerPageContent","editor","createPageEditor","view","render","WbEditorHarness","PageEditorTopBar","describe","afterEach","cleanup","it","expect","screen","bars","strip","document","presenter","WbPageContentReloader","WbPageUnsavedChanges","params","act","state","WbPageStatus","waitFor"],"mappings":";;;;;;;;;;;;;;AA0BAA,GAAG,IAAI,CAAC,0BAA0B,IACvB;QAAE,gBAAgB,IAAM;IAAK;AAGxCA,GAAG,IAAI,CAAC,kEAAkE;IACtE,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAC3B,MAAM,EAAEC,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC;IACzC,MAAMC,SAASD,gBAAgB,gBAAgB,IACpCD,MAAM,aAAa,CAAC,OAAO;YAAE,eAAe;QAAe;IAEtE,OAAO;QAAEE;QAAQ,mBAAmB,IAAM;IAAK;AACnD;AAEAH,GAAG,IAAI,CAAC,qEAAqE;IACzE,MAAMC,QAAQ,MAAM,MAAM,CAAC;IAI3B,MAAMG,kBAAkB,CAACC,QACdJ,MAAM,aAAa,CAAC,OAAO;YAC9B,eAAe;YACf,cAAcI,MAAM,YAAY,CAAC,IAAI;QACzC;IAEJ,OAAO;QAAED;IAAgB;AAC7B;AAEA,MAAM,EAAEE,EAAE,EAAE,GAAGC;AAEf,MAAMC,cAAc,CAACC,YAAsBC;IACvC,MAAMC,SAASC,kBAAkBF;IACjC,MAAMG,YAAY,IAAIC;IACtBD,UAAU,gBAAgB,CAACE,cAAcJ,OAAO,OAAO;IACvDK,oBAAoBH;IACpB,MAAMI,SAASC,iBAAiBT;IAEhC,MAAMU,OAAOC,OAAO,WAADA,GACf,oBAACC,iBAAeA;QAAC,WAAWR;QAAW,QAAQI;qBAC3C,oBAACK,kBAAgBA,OAAAA,WAAAA,GACjB,oBAAChB,GAAG,MAAM,CAAC,MAAM;IAIzB,OAAO;QAAE,GAAGK,MAAM;QAAEM;QAAQE;IAAK;AACrC;AAEAI,SAAS,oBAAoB;IACzBC,UAAU;QACNC;IACJ;IAEAC,GAAG,+FAA+F;QAC9FlB,YAAY,SAAS;QAErBmB,OAAOC,O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IAAI;YACAnB,OAAO,cAAc,CAACoB,CAAAA;gBAClBA,MAAM,MAAM,GAAGC,aAAa,WAAW;YAC3C;QACJ;QAEA,MAAMC,QAAQ;YACVZ,OAAOK,UAAU,UAAU,EAAE,wBAAwB,CAAC;gBAClD,aAAa;gBACb,YAAY;gBACZ,aAAa;gBACb,eAAe;YACnB;QACJ;QACAL,OAAOK,UAAU,IAAI,EAAE,qBAAqB,CAAC;IACjD;AACJ"}
|
|
@@ -3,7 +3,7 @@ import { useFeature } from "@webiny/app";
|
|
|
3
3
|
import { createReactiveComponent } from "@webiny/app-admin";
|
|
4
4
|
import { PageEditorConfig } from "@webiny/app-website-builder/presentation/pages/PageEditor/PageEditorConfig.js";
|
|
5
5
|
import { WbPageReviewFeature } from "../../features/editorReview/feature.js";
|
|
6
|
-
const { Ui
|
|
6
|
+
const { Ui } = PageEditorConfig;
|
|
7
7
|
const NewRevisionGate = createReactiveComponent((props)=>{
|
|
8
8
|
const { session } = useFeature(WbPageReviewFeature);
|
|
9
9
|
const { vm } = session.presenter;
|