slice-machine-ui 1.23.2-beta.1 → 1.23.2-beta.11
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/.depcheckrc +3 -0
- package/components/ChangesEmptyState/OfflinePage.tsx +1 -1
- package/components/ChangesItems/ChangesItems.tsx +6 -2
- package/components/CustomTypeTable/changesPage.tsx +12 -7
- package/components/DeleteSliceModal/index.tsx +37 -24
- package/components/DeleteVariationModal/index.tsx +1 -0
- package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +65 -38
- package/components/Forms/CreateSliceModal/CreateSliceModal.tsx +3 -1
- package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +7 -2
- package/components/Forms/RenameSliceModal/RenameSliceModal.tsx +36 -21
- package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +0 -1
- package/components/LoginModal/index.tsx +40 -2
- package/components/ModalFormCard/index.tsx +0 -1
- package/components/Navigation/ChangesItem.tsx +117 -0
- package/components/Navigation/Environment.tsx +51 -4
- package/components/Navigation/index.css.ts +1 -2
- package/components/Navigation/index.test.tsx +5 -85
- package/components/Navigation/index.tsx +32 -20
- package/components/ReviewModal/ReviewForm.tsx +0 -1
- package/lib/builders/SliceBuilder/index.tsx +3 -3
- package/lib/builders/common/EditModal/Form.jsx +0 -1
- package/lib/builders/common/Zone/Card/components/NewField.tsx +0 -1
- package/lib/models/common/ModelStatus/index.ts +25 -0
- package/lib/models/common/widgets/StructuredText/index.ts +1 -1
- package/out/404.html +1 -1
- package/out/_next/static/chunks/18539003-5f78714a35fde4a1.js +97 -0
- package/out/_next/static/chunks/25-3aa4d4b24167d340.js +1 -0
- package/out/_next/static/chunks/318-19dbcae10cdb6408.js +1 -0
- package/out/_next/static/chunks/727-de03055e40815a3a.js +1 -0
- package/out/_next/static/chunks/777-8c5507e3b119b5dc.js +8 -0
- package/out/_next/static/chunks/799-0af1215eb2b3c17e.js +1 -0
- package/out/_next/static/chunks/904-40686b0426716111.js +1 -0
- package/out/_next/static/chunks/pages/_app-bca191df4ac7078e.js +434 -0
- package/out/_next/static/chunks/pages/{changelog-afd18276fe018b24.js → changelog-cb1df3a70b20f1b8.js} +1 -1
- package/out/_next/static/chunks/pages/changes-ccfd715c2bdc4f83.js +1 -0
- package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-3f862ad6111a1fc0.js → [customTypeId]-97ab3b90b85d645d.js} +1 -1
- package/out/_next/static/chunks/pages/{custom-types-94b8f8dbf7727412.js → custom-types-3c8e721ec6802127.js} +1 -1
- package/out/_next/static/chunks/pages/index-cf93d16e9c63b6db.js +1 -0
- package/out/_next/static/chunks/pages/{labs-ee206005948f8e87.js → labs-2adfb5127f9c4081.js} +1 -1
- package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-d1ffca11c42f2603.js → [pageTypeId]-84a22c5e480d3fa9.js} +1 -1
- package/out/_next/static/chunks/pages/settings-94bcd7422e8b237d.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-897ca93c114a1435.js → simulator-aaf65fbec8f5839c.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-90bb2ea76d2abf42.js +1 -0
- package/out/_next/static/chunks/pages/slices-e0ce615c38e8338d.js +1 -0
- package/out/_next/static/css/39e089aad1742a3a.css +1 -0
- package/out/_next/static/css/{37153180c3b0dd66.css → 838fd8bb5a7c32b0.css} +1 -1
- package/out/_next/static/css/ca32882a5d2d8d88.css +1 -0
- package/out/_next/static/dS_xZnzzna6Y6uwcTgf90/_buildManifest.js +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/settings.html +1 -0
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +9 -6
- package/pages/_app.tsx +34 -32
- package/pages/changes.tsx +27 -41
- package/pages/settings.tsx +1 -0
- package/pages/slices.tsx +20 -8
- package/postcss.config.js +10 -0
- package/src/apiClient.ts +1 -22
- package/src/components/FieldSet/FieldSet.stories.tsx +20 -11
- package/src/components/RelativeTime/RelativeTime.stories.tsx +25 -0
- package/src/components/RelativeTime/RelativeTime.tsx +40 -0
- package/src/components/RelativeTime/index.ts +1 -0
- package/src/components/SideNav/SideNav.css.ts +1 -1
- package/src/components/SideNav/SideNav.tsx +9 -5
- package/src/components/SideNav/SideNavEnvironmentSelector.tsx +31 -11
- package/src/domain/__tests__/customType.test.ts +205 -19
- package/src/domain/customType.ts +132 -7
- package/src/domain/slice.ts +38 -0
- package/src/features/autoSave/AutoSaveStatusIndicator.tsx +4 -4
- package/src/features/customTypes/PageTypeOnboarding.tsx +21 -26
- package/src/features/customTypes/actions/convertCustomToPageType.ts +14 -10
- package/src/features/customTypes/actions/createCustomType.ts +69 -0
- package/src/features/customTypes/actions/deleteCustomType.ts +13 -3
- package/src/features/customTypes/actions/renameCustomType.ts +10 -4
- package/src/features/customTypes/customTypesBuilder/CustomTypeProvider.tsx +11 -10
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +5 -3
- package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +8 -8
- package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +18 -17
- package/src/features/environments/actions/setEnvironment.ts +4 -4
- package/src/features/settings/SettingsPage.tsx +47 -0
- package/src/features/settings/git/ConnectGitRepository.tsx +126 -0
- package/src/features/settings/git/ConnectGitRepositoryBlankSlate.tsx +33 -0
- package/src/features/settings/git/GitOwnerSelect.tsx +71 -0
- package/src/features/settings/git/GitProvider.ts +40 -0
- package/src/features/settings/git/GitProviderConnectButtons.tsx +63 -0
- package/src/features/settings/git/GitRepositoriesList.tsx +76 -0
- package/src/features/settings/git/GitRepositoriesSearch.tsx +69 -0
- package/src/features/settings/git/GitRepositoryConnectDialog.tsx +85 -0
- package/src/features/settings/git/GitRepositoryDisconnectDialog.tsx +60 -0
- package/src/features/settings/git/useGitIntegrationExperiment.ts +8 -0
- package/src/features/settings/git/useGitOwners.ts +12 -0
- package/src/features/settings/git/useGitRepos.ts +24 -0
- package/src/features/settings/git/useLinkedGitRepos.ts +41 -0
- package/src/features/settings/git/useWriteAPIToken.ts +23 -0
- package/src/features/slices/actions/createSlice.ts +5 -29
- package/src/features/slices/actions/deleteSlice.ts +33 -0
- package/src/features/slices/actions/renameSlice.ts +37 -0
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +0 -1
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +0 -1
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceMergeWithIdenticalDialog.tsx +0 -1
- package/src/features/slices/sliceBuilder/SliceBuilderProvider.tsx +12 -10
- package/src/features/sync/AutoSyncProvider.tsx +252 -0
- package/src/features/sync/components/AutoSyncStatusIndicator.module.css +17 -0
- package/src/features/sync/components/AutoSyncStatusIndicator.module.css.d.ts +5 -0
- package/src/features/sync/components/AutoSyncStatusIndicator.tsx +58 -0
- package/src/features/sync/fetchUnSyncChanges.ts +40 -0
- package/src/features/sync/getUnSyncChanges.ts +144 -0
- package/src/features/sync/useUnSyncChanges.ts +32 -0
- package/src/hooks/useActionQueue.tsx +177 -0
- package/src/hooks/useAuthStatus.ts +12 -0
- package/src/hooks/useUser.ts +14 -0
- package/src/icons/SettingsIcon.tsx +19 -0
- package/src/icons/SyncFailed.tsx +30 -0
- package/src/icons/Synced.tsx +19 -0
- package/src/icons/Syncing.tsx +23 -0
- package/src/modules/availableCustomTypes/index.ts +29 -135
- package/src/modules/loading/types.ts +0 -5
- package/src/modules/modal/types.ts +0 -3
- package/src/modules/slices/index.ts +27 -193
- package/src/modules/slices/selector.ts +0 -14
- package/src/modules/useSliceMachineActions.ts +70 -89
- package/src/modules/userContext/index.ts +3 -3
- package/src/redux/saga.ts +0 -4
- package/test/__testutils__/index.tsx +8 -5
- package/test/src/modules/__fixtures__/serverState.ts +1 -2
- package/test/src/modules/availableCustomTypes/index.test.ts +2 -243
- package/test/src/modules/slices.test.ts +1 -267
- package/components/Navigation/ChangesListItem.tsx +0 -92
- package/components/Navigation/ChangesRightElement.tsx +0 -33
- package/out/_next/static/chunks/18539003-5cc559566b738915.js +0 -97
- package/out/_next/static/chunks/25-37d6fa7f064be04b.js +0 -1
- package/out/_next/static/chunks/318-ce7e74f18f2d5b22.js +0 -1
- package/out/_next/static/chunks/376-7e784d6069e01654.js +0 -8
- package/out/_next/static/chunks/727-3a3bc32518778317.js +0 -1
- package/out/_next/static/chunks/731-501990ebe6a71b32.js +0 -1
- package/out/_next/static/chunks/904-9a4c1264727ae89a.js +0 -1
- package/out/_next/static/chunks/pages/_app-cd9d4c76a4abc11a.js +0 -432
- package/out/_next/static/chunks/pages/changes-2a976f9efeb719aa.js +0 -1
- package/out/_next/static/chunks/pages/index-64cfb8b0948ba8ef.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-b2a9d773ce5d7739.js +0 -1
- package/out/_next/static/chunks/pages/slices-e9c70c082ca3e3f9.js +0 -1
- package/out/_next/static/css/200244e3e0463c39.css +0 -1
- package/out/_next/static/m6psnC5u1xT7Y6osWHKjp/_buildManifest.js +0 -1
- package/src/features/autoSave/useAutoSave.tsx +0 -177
- package/src/features/customTypes/__tests__/createCustomType.test.ts +0 -159
- package/src/features/customTypes/customTypesTable/createCustomType.ts +0 -107
- package/src/features/legacyState/actions/getLegacySliceMachineState.ts +0 -53
- package/src/features/legacyState/useLegacySliceMachineState.ts +0 -7
- package/src/hooks/useModelStatus.ts +0 -78
- package/src/hooks/useUnSyncChanges.ts +0 -88
- package/test/components/CreateCustomTypeModal.test.tsx +0 -73
- package/test/components/LoginModal.test.tsx +0 -67
- package/test/src/hooks/useModelStatus.test.ts +0 -115
- /package/out/_next/static/{m6psnC5u1xT7Y6osWHKjp → dS_xZnzzna6Y6uwcTgf90}/_ssgManifest.js +0 -0
- /package/src/features/{changes → sync}/actions/pushChanges.ts +0 -0
- /package/src/features/{changes → sync}/actions/trackPushChangesSuccess.ts +0 -0
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
|
|
3
|
-
import { describe, test, afterEach, expect, vi } from "vitest";
|
|
4
|
-
import { Analytics } from "@segment/analytics-node";
|
|
5
|
-
|
|
6
|
-
import { render, fireEvent, act } from "../__testutils__";
|
|
7
|
-
import { CreateCustomTypeModal } from "../../components/Forms/CreateCustomTypeModal";
|
|
8
|
-
import { ModalKeysEnum } from "../../src/modules/modal/types";
|
|
9
|
-
|
|
10
|
-
vi.mock("next/router", () => require("next-router-mock"));
|
|
11
|
-
global.console = { ...global.console, error: vi.fn() };
|
|
12
|
-
|
|
13
|
-
describe("CreateCustomTypeModal", () => {
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
vi.clearAllMocks();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("when a slice is created the tracker should be called", async () => {
|
|
19
|
-
const fakeId = "testing_id";
|
|
20
|
-
const fakeName = "testing-name";
|
|
21
|
-
const fakeRepo = "foo";
|
|
22
|
-
|
|
23
|
-
render(<CreateCustomTypeModal format="custom" />, {
|
|
24
|
-
preloadedState: {
|
|
25
|
-
// @ts-expect-error TS(2739) FIXME: Type '{ repo: string; }' is missing the following ... Remove this comment to see the full error message
|
|
26
|
-
environment: {
|
|
27
|
-
repo: fakeRepo,
|
|
28
|
-
},
|
|
29
|
-
availableCustomTypes: {},
|
|
30
|
-
// @ts-expect-error TS(2740) FIXME: Type '{ CREATE_CUSTOM_TYPE: true; }' is missing th... Remove this comment to see the full error message
|
|
31
|
-
modal: { [ModalKeysEnum.CREATE_CUSTOM_TYPE]: true },
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const idInput = document.querySelector('[name="id"]');
|
|
36
|
-
const labelInput = document.querySelector('[name="label"]');
|
|
37
|
-
const submitButton = document.querySelector('[type="submit"]');
|
|
38
|
-
|
|
39
|
-
await act(async () => {
|
|
40
|
-
if (labelInput) {
|
|
41
|
-
fireEvent.change(labelInput, { target: { value: fakeName } });
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
await act(async () => {
|
|
46
|
-
if (idInput) {
|
|
47
|
-
fireEvent.change(idInput, { target: { value: fakeId } });
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await act(async () => {
|
|
52
|
-
if (submitButton) {
|
|
53
|
-
fireEvent.click(submitButton);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
expect(Analytics.prototype.track).toHaveBeenCalledOnce();
|
|
58
|
-
expect(Analytics.prototype.track).toHaveBeenCalledWith(
|
|
59
|
-
expect.objectContaining({
|
|
60
|
-
event: "SliceMachine Custom Type Created",
|
|
61
|
-
properties: {
|
|
62
|
-
id: fakeId,
|
|
63
|
-
name: fakeName,
|
|
64
|
-
format: "custom",
|
|
65
|
-
type: "repeatable",
|
|
66
|
-
nodeVersion: process.versions.node,
|
|
67
|
-
origin: "table",
|
|
68
|
-
},
|
|
69
|
-
}),
|
|
70
|
-
expect.any(Function),
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
|
|
3
|
-
import { describe, test, expect, vi } from "vitest";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { render } from "@testing-library/react";
|
|
6
|
-
import LoginModal from "@components/LoginModal";
|
|
7
|
-
import { FrontEndEnvironment } from "@lib/models/common/Environment";
|
|
8
|
-
import { useSelector } from "react-redux";
|
|
9
|
-
|
|
10
|
-
const mockDispatch = vi.fn();
|
|
11
|
-
vi.mock("react-beautiful-dnd", () => {
|
|
12
|
-
return {};
|
|
13
|
-
});
|
|
14
|
-
vi.mock("react-redux", () => ({
|
|
15
|
-
useSelector: vi.fn(),
|
|
16
|
-
useDispatch: () => mockDispatch,
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
const useSelectorMock = vi.mocked(useSelector);
|
|
20
|
-
|
|
21
|
-
const App = () => <LoginModal />;
|
|
22
|
-
|
|
23
|
-
describe("LoginModal", () => {
|
|
24
|
-
window.open = vi.fn();
|
|
25
|
-
|
|
26
|
-
const div = document.createElement("div");
|
|
27
|
-
div.id = "__next";
|
|
28
|
-
document.body.appendChild(div);
|
|
29
|
-
|
|
30
|
-
test("when given a prismic url in env it should open to prismic.io/dashboard", () => {
|
|
31
|
-
useSelectorMock.mockImplementation(() => ({
|
|
32
|
-
env: {
|
|
33
|
-
manifest: {
|
|
34
|
-
apiEndpoint: "https://foo.prismic.io/api/v2",
|
|
35
|
-
},
|
|
36
|
-
} as FrontEndEnvironment,
|
|
37
|
-
isOpen: true,
|
|
38
|
-
isLoginLoading: true,
|
|
39
|
-
}));
|
|
40
|
-
const result = render(<App />);
|
|
41
|
-
|
|
42
|
-
expect(result.getByText("Click here").closest("a")).toHaveAttribute(
|
|
43
|
-
"href",
|
|
44
|
-
// Since we're not using the `start-slicemachine` server proxy, port defaults to Next/React Testing Library's default port
|
|
45
|
-
"https://prismic.io/dashboard/cli/login?source=slice-machine&port=3000&path=/api/auth",
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("when given wroom.io url it should open to wroom.io/dashboard", () => {
|
|
50
|
-
useSelectorMock.mockImplementation(() => ({
|
|
51
|
-
env: {
|
|
52
|
-
manifest: {
|
|
53
|
-
apiEndpoint: "https://foo.wroom.io/api/v2",
|
|
54
|
-
},
|
|
55
|
-
} as FrontEndEnvironment,
|
|
56
|
-
isOpen: true,
|
|
57
|
-
isLoginLoading: true,
|
|
58
|
-
}));
|
|
59
|
-
const result = render(<App />);
|
|
60
|
-
|
|
61
|
-
expect(result.getByText("Click here").closest("a")).toHaveAttribute(
|
|
62
|
-
"href",
|
|
63
|
-
// Since we're not using the `start-slicemachine` server proxy, port defaults to Next/React Testing Library's default port
|
|
64
|
-
"https://wroom.io/dashboard/cli/login?source=slice-machine&port=3000&path=/api/auth",
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { describe, test, beforeEach, expect, vi } from "vitest";
|
|
2
|
-
import { useModelStatus } from "../../../src/hooks/useModelStatus";
|
|
3
|
-
import * as networkHook from "../../../src/hooks/useNetwork";
|
|
4
|
-
import { AuthStatus } from "@src/modules/userContext/types";
|
|
5
|
-
|
|
6
|
-
import { Slices } from "@lib/models/common/Slice";
|
|
7
|
-
import SliceMock from "../../__fixtures__/sliceModel";
|
|
8
|
-
|
|
9
|
-
import { CustomTypes } from "@lib/models/common/CustomType";
|
|
10
|
-
import { customTypeMock } from "../../__fixtures__/customType";
|
|
11
|
-
import { ModelStatus } from "@lib/models/common/ModelStatus";
|
|
12
|
-
|
|
13
|
-
const mockSelector = vi.fn();
|
|
14
|
-
vi.mock("react-redux", async () => {
|
|
15
|
-
const actual: typeof import("react-redux") =
|
|
16
|
-
await vi.importActual("react-redux");
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
...actual,
|
|
20
|
-
useSelector: () => mockSelector(),
|
|
21
|
-
};
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const BaseSliceMock = {
|
|
25
|
-
...SliceMock,
|
|
26
|
-
variations: SliceMock.variations.map((variation) => {
|
|
27
|
-
// @ts-expect-error we know imageUrl is optional
|
|
28
|
-
delete variation["imageUrl"];
|
|
29
|
-
return variation;
|
|
30
|
-
}),
|
|
31
|
-
};
|
|
32
|
-
const sliceModel = Slices.toSM(BaseSliceMock);
|
|
33
|
-
const customTypeModel = CustomTypes.toSM(customTypeMock);
|
|
34
|
-
|
|
35
|
-
describe("[useModelStatus hook]", () => {
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
vi.clearAllMocks();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test("it should return the model status correctly", () => {
|
|
41
|
-
vi.spyOn(networkHook, "useNetwork").mockImplementation(() => true); // isOnline
|
|
42
|
-
mockSelector.mockReturnValue({ authStatus: AuthStatus.AUTHORIZED });
|
|
43
|
-
|
|
44
|
-
const result = useModelStatus({
|
|
45
|
-
slices: [{ local: sliceModel, remote: sliceModel, localScreenshots: {} }],
|
|
46
|
-
customTypes: [{ local: customTypeModel }],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
expect(result).toEqual({
|
|
50
|
-
modelsStatuses: {
|
|
51
|
-
slices: { [sliceModel.id]: ModelStatus.Synced },
|
|
52
|
-
customTypes: { [customTypeModel.id]: ModelStatus.New },
|
|
53
|
-
},
|
|
54
|
-
authStatus: AuthStatus.AUTHORIZED,
|
|
55
|
-
isOnline: true,
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test("it should return Unknown status is the user doesn't have internet", () => {
|
|
60
|
-
vi.spyOn(networkHook, "useNetwork").mockImplementation(() => false); // isOnline
|
|
61
|
-
mockSelector.mockReturnValue({ authStatus: AuthStatus.AUTHORIZED });
|
|
62
|
-
|
|
63
|
-
const result = useModelStatus({
|
|
64
|
-
slices: [{ local: sliceModel, remote: sliceModel, localScreenshots: {} }],
|
|
65
|
-
customTypes: [{ local: customTypeModel }],
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
expect(result).toEqual({
|
|
69
|
-
modelsStatuses: {
|
|
70
|
-
slices: { [sliceModel.id]: ModelStatus.Unknown },
|
|
71
|
-
customTypes: { [customTypeModel.id]: ModelStatus.Unknown },
|
|
72
|
-
},
|
|
73
|
-
authStatus: AuthStatus.AUTHORIZED,
|
|
74
|
-
isOnline: false,
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test("it should return Unknown status is the user is not connected to Prismic", () => {
|
|
79
|
-
vi.spyOn(networkHook, "useNetwork").mockImplementation(() => true); // isOnline
|
|
80
|
-
mockSelector.mockReturnValue({ authStatus: AuthStatus.UNAUTHORIZED });
|
|
81
|
-
|
|
82
|
-
const result = useModelStatus({
|
|
83
|
-
slices: [{ local: sliceModel, remote: sliceModel, localScreenshots: {} }],
|
|
84
|
-
customTypes: [{ local: customTypeModel }],
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
expect(result).toEqual({
|
|
88
|
-
modelsStatuses: {
|
|
89
|
-
slices: { [sliceModel.id]: ModelStatus.Unknown },
|
|
90
|
-
customTypes: { [customTypeModel.id]: ModelStatus.Unknown },
|
|
91
|
-
},
|
|
92
|
-
authStatus: AuthStatus.UNAUTHORIZED,
|
|
93
|
-
isOnline: true,
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test("it should return Unknown status is the user doesn't have access to the repository", () => {
|
|
98
|
-
vi.spyOn(networkHook, "useNetwork").mockImplementation(() => true); // isOnline
|
|
99
|
-
mockSelector.mockReturnValue({ authStatus: AuthStatus.FORBIDDEN });
|
|
100
|
-
|
|
101
|
-
const result = useModelStatus({
|
|
102
|
-
slices: [{ local: sliceModel, remote: sliceModel, localScreenshots: {} }],
|
|
103
|
-
customTypes: [{ local: customTypeModel }],
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
expect(result).toEqual({
|
|
107
|
-
modelsStatuses: {
|
|
108
|
-
slices: { [sliceModel.id]: ModelStatus.Unknown },
|
|
109
|
-
customTypes: { [customTypeModel.id]: ModelStatus.Unknown },
|
|
110
|
-
},
|
|
111
|
-
authStatus: AuthStatus.FORBIDDEN,
|
|
112
|
-
isOnline: true,
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|