slice-machine-ui 1.23.2-beta.10 → 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/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 +3 -0
- package/components/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +4 -0
- package/components/Forms/CreateSliceModal/CreateSliceModal.tsx +3 -1
- package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +6 -1
- package/components/Forms/RenameSliceModal/RenameSliceModal.tsx +3 -0
- package/components/LoginModal/index.tsx +40 -2
- 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 +3 -8
- package/lib/builders/SliceBuilder/index.tsx +3 -3
- package/lib/models/common/ModelStatus/index.ts +25 -0
- package/out/404.html +1 -1
- package/out/_next/static/chunks/25-3aa4d4b24167d340.js +1 -0
- package/out/_next/static/chunks/{318-99b5914b60bf1d17.js → 318-19dbcae10cdb6408.js} +1 -1
- package/out/_next/static/chunks/727-de03055e40815a3a.js +1 -0
- package/out/_next/static/chunks/{799-b616401fe0dafdeb.js → 799-0af1215eb2b3c17e.js} +1 -1
- package/out/_next/static/chunks/904-40686b0426716111.js +1 -0
- package/out/_next/static/chunks/pages/{_app-5ec41fc53c1f6405.js → _app-bca191df4ac7078e.js} +24 -24
- package/out/_next/static/chunks/pages/{changelog-02cd80dad6f40878.js → changelog-cb1df3a70b20f1b8.js} +1 -1
- package/out/_next/static/chunks/pages/changes-ccfd715c2bdc4f83.js +1 -0
- package/out/_next/static/chunks/pages/{labs-39b50541a4c370bf.js → labs-2adfb5127f9c4081.js} +1 -1
- package/out/_next/static/chunks/pages/{settings-879686e3a8759dc3.js → settings-94bcd7422e8b237d.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/{simulator-c498e9c80cae8cce.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/{3c26dbbbd8f4be12.css → 39e089aad1742a3a.css} +1 -1
- package/out/_next/static/{Dz7wwTNVdXvoAjySXz7mE → dS_xZnzzna6Y6uwcTgf90}/_buildManifest.js +1 -1
- 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 -1
- 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 +3 -3
- package/pages/_app.tsx +34 -32
- package/pages/changes.tsx +27 -41
- 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/features/autoSave/AutoSaveStatusIndicator.tsx +4 -4
- package/src/features/customTypes/customTypesBuilder/CustomTypeProvider.tsx +11 -10
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +2 -2
- package/src/features/environments/actions/setEnvironment.ts +3 -3
- 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/icons/SyncFailed.tsx +30 -0
- package/src/icons/Synced.tsx +19 -0
- package/src/icons/Syncing.tsx +23 -0
- package/test/__testutils__/index.tsx +8 -5
- package/components/Navigation/ChangesListItem.tsx +0 -74
- package/components/Navigation/ChangesRightElement.tsx +0 -33
- package/out/_next/static/chunks/25-01f422cea8066349.js +0 -1
- package/out/_next/static/chunks/727-f8fefdd3e50cab2a.js +0 -1
- package/out/_next/static/chunks/904-4653b7a849f4db94.js +0 -1
- package/out/_next/static/chunks/pages/changes-8e9da8fbb809aad3.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-9b893c62b2f2fe4a.js +0 -1
- package/out/_next/static/chunks/pages/slices-4522d604117d8c66.js +0 -1
- package/src/features/autoSave/useAutoSave.tsx +0 -177
- 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/LoginModal.test.tsx +0 -67
- package/test/src/hooks/useModelStatus.test.ts +0 -115
- /package/out/_next/static/{Dz7wwTNVdXvoAjySXz7mE → 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,78 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computeModelStatus,
|
|
3
|
-
ModelStatus,
|
|
4
|
-
} from "@lib/models/common/ModelStatus";
|
|
5
|
-
import { getAuthStatus } from "@src/modules/environment";
|
|
6
|
-
import { AuthStatus } from "@src/modules/userContext/types";
|
|
7
|
-
import { SliceMachineStoreType } from "@src/redux/type";
|
|
8
|
-
import { useSelector } from "react-redux";
|
|
9
|
-
import { useNetwork } from "./useNetwork";
|
|
10
|
-
import {
|
|
11
|
-
hasLocal,
|
|
12
|
-
LocalOrRemoteCustomType,
|
|
13
|
-
LocalOrRemoteModel,
|
|
14
|
-
LocalOrRemoteSlice,
|
|
15
|
-
} from "@lib/models/common/ModelData";
|
|
16
|
-
|
|
17
|
-
// Slices and Custom Types needs to be separated as Ids are not unique amongst each others.
|
|
18
|
-
export interface ModelStatusInformation {
|
|
19
|
-
modelsStatuses: {
|
|
20
|
-
slices: { [sliceId: string]: ModelStatus };
|
|
21
|
-
customTypes: { [ctId: string]: ModelStatus };
|
|
22
|
-
};
|
|
23
|
-
authStatus: AuthStatus;
|
|
24
|
-
isOnline: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function computeStatuses(
|
|
28
|
-
models: LocalOrRemoteCustomType[],
|
|
29
|
-
userHasAccessToModels: boolean,
|
|
30
|
-
): { [sliceId: string]: ModelStatus };
|
|
31
|
-
function computeStatuses(
|
|
32
|
-
models: LocalOrRemoteSlice[],
|
|
33
|
-
userHasAccessToModels: boolean,
|
|
34
|
-
): { [sliceId: string]: ModelStatus };
|
|
35
|
-
function computeStatuses(
|
|
36
|
-
models: LocalOrRemoteModel[],
|
|
37
|
-
userHasAccessToModels: boolean,
|
|
38
|
-
) {
|
|
39
|
-
return models.reduce<{ [id: string]: ModelStatus }>(
|
|
40
|
-
(acc, model) => {
|
|
41
|
-
const { status } = computeModelStatus(model, userHasAccessToModels);
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
...acc,
|
|
45
|
-
[hasLocal(model) ? model.local.id : model.remote.id]: status,
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
{} as { [sliceId: string]: ModelStatus },
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const useModelStatus = ({
|
|
53
|
-
slices = [],
|
|
54
|
-
customTypes = [],
|
|
55
|
-
}: {
|
|
56
|
-
slices?: LocalOrRemoteSlice[];
|
|
57
|
-
customTypes?: LocalOrRemoteCustomType[];
|
|
58
|
-
}): ModelStatusInformation => {
|
|
59
|
-
const isOnline = useNetwork();
|
|
60
|
-
const { authStatus } = useSelector((store: SliceMachineStoreType) => ({
|
|
61
|
-
authStatus: getAuthStatus(store),
|
|
62
|
-
}));
|
|
63
|
-
const userHasAccessToModels =
|
|
64
|
-
isOnline &&
|
|
65
|
-
authStatus != AuthStatus.FORBIDDEN &&
|
|
66
|
-
authStatus != AuthStatus.UNAUTHORIZED;
|
|
67
|
-
|
|
68
|
-
const modelsStatuses = {
|
|
69
|
-
slices: computeStatuses(slices, userHasAccessToModels),
|
|
70
|
-
customTypes: computeStatuses(customTypes, userHasAccessToModels),
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
modelsStatuses,
|
|
75
|
-
authStatus,
|
|
76
|
-
isOnline,
|
|
77
|
-
};
|
|
78
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
2
|
-
import { ModelStatus } from "@lib/models/common/ModelStatus";
|
|
3
|
-
import { selectAllCustomTypes } from "@src/modules/availableCustomTypes";
|
|
4
|
-
import { getFrontendSlices, getLibraries } from "@src/modules/slices";
|
|
5
|
-
import { SliceMachineStoreType } from "@src/redux/type";
|
|
6
|
-
import { useSelector } from "react-redux";
|
|
7
|
-
import { ModelStatusInformation, useModelStatus } from "./useModelStatus";
|
|
8
|
-
import {
|
|
9
|
-
LocalOrRemoteCustomType,
|
|
10
|
-
RemoteOnlySlice,
|
|
11
|
-
getModelId,
|
|
12
|
-
isRemoteOnly,
|
|
13
|
-
} from "@lib/models/common/ModelData";
|
|
14
|
-
|
|
15
|
-
export const unSyncStatuses = [
|
|
16
|
-
ModelStatus.New,
|
|
17
|
-
ModelStatus.Modified,
|
|
18
|
-
ModelStatus.Deleted,
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
export interface UnSyncChanges extends ModelStatusInformation {
|
|
22
|
-
unSyncedSlices: ComponentUI[];
|
|
23
|
-
unSyncedCustomTypes: LocalOrRemoteCustomType[];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// ComponentUI are manipulated on all the relevant pages
|
|
27
|
-
// But the data is not available for remote only slices
|
|
28
|
-
// which have been deleted locally
|
|
29
|
-
// Should revisit this with the sync improvements
|
|
30
|
-
const wrapDeletedSlice = (s: RemoteOnlySlice): ComponentUI => ({
|
|
31
|
-
model: s.remote,
|
|
32
|
-
screenshots: {},
|
|
33
|
-
from: "",
|
|
34
|
-
href: "",
|
|
35
|
-
pathToSlice: "",
|
|
36
|
-
fileName: "",
|
|
37
|
-
extension: "",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const useUnSyncChanges = (): UnSyncChanges => {
|
|
41
|
-
const { customTypes, slices, libraries } = useSelector(
|
|
42
|
-
(store: SliceMachineStoreType) => ({
|
|
43
|
-
customTypes: selectAllCustomTypes(store),
|
|
44
|
-
slices: getFrontendSlices(store),
|
|
45
|
-
libraries: getLibraries(store),
|
|
46
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const { modelsStatuses, authStatus, isOnline } = useModelStatus({
|
|
50
|
-
slices,
|
|
51
|
-
customTypes,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const localComponents: ComponentUI[] = libraries.flatMap(
|
|
55
|
-
(lib) => lib.components,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
const deletedComponents: ComponentUI[] = slices
|
|
59
|
-
.filter(isRemoteOnly)
|
|
60
|
-
.map(wrapDeletedSlice);
|
|
61
|
-
|
|
62
|
-
const components: ComponentUI[] = localComponents
|
|
63
|
-
.concat(deletedComponents)
|
|
64
|
-
.sort((s1, s2) => (s1.model.name > s2.model.name ? 1 : -1));
|
|
65
|
-
|
|
66
|
-
const unSyncedSlices = components.filter(
|
|
67
|
-
(component) =>
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
69
|
-
modelsStatuses.slices[component.model.id] &&
|
|
70
|
-
unSyncStatuses.includes(modelsStatuses.slices[component.model.id]),
|
|
71
|
-
);
|
|
72
|
-
const unSyncedCustomTypes = customTypes.filter(
|
|
73
|
-
(customType) =>
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
75
|
-
modelsStatuses.customTypes[getModelId(customType)] &&
|
|
76
|
-
unSyncStatuses.includes(
|
|
77
|
-
modelsStatuses.customTypes[getModelId(customType)],
|
|
78
|
-
),
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
unSyncedSlices,
|
|
83
|
-
unSyncedCustomTypes,
|
|
84
|
-
modelsStatuses,
|
|
85
|
-
authStatus,
|
|
86
|
-
isOnline,
|
|
87
|
-
};
|
|
88
|
-
};
|
|
@@ -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
|