@griddo/ax 12.17.1 → 12.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/__tests__/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/TemplateManagerWhiteList.test.tsx +89 -0
- package/src/__tests__/components/Login/LoginCollapsible.test.tsx +5 -5
- package/src/__tests__/components/Login/LoginDropdownCard.test.tsx +1 -1
- package/src/__tests__/components/Login/LoginGriddoId.test.tsx +13 -13
- package/src/__tests__/components/Login/LoginPending.test.tsx +273 -0
- package/src/__tests__/components/SideModal/SideModal.test.tsx +84 -1
- package/src/__tests__/containers/App/loginSSO.test.ts +57 -0
- package/src/__tests__/containers/PageEditor/pasteModule.test.ts +116 -0
- package/src/__tests__/hooks/pendingNavigation.test.tsx +214 -0
- package/src/__tests__/locales/loginLocale.test.ts +13 -2
- package/src/__tests__/modules/Login/Login.test.tsx +4 -4
- package/src/__tests__/modules/Login/signInOut.test.tsx +19 -1
- package/src/components/Button/index.tsx +8 -0
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/index.tsx +2 -1
- package/src/components/Login/LoginGriddoId/index.tsx +14 -27
- package/src/components/Login/LoginGriddoId/style.tsx +7 -2
- package/src/components/Login/LoginSSO/index.tsx +33 -10
- package/src/components/Login/LoginSSO/style.tsx +18 -0
- package/src/components/Login/index.tsx +1 -1
- package/src/components/SideModal/index.tsx +3 -1
- package/src/containers/App/actions.tsx +11 -3
- package/src/containers/PageEditor/actions.tsx +12 -7
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/pendingNavigation.ts +63 -0
- package/src/locales/en-US.ts +2 -1
- package/src/locales/es-ES.ts +2 -1
- package/src/modules/Login/index.tsx +6 -4
- package/src/schemas/pages/GlobalPage.ts +3 -5
- package/src/schemas/pages/Page.ts +3 -5
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { global } from "@ax/api";
|
|
2
|
+
import { appActions } from "@ax/containers/App";
|
|
3
|
+
|
|
4
|
+
// AC6 · `loginSSO` repone `isLogging` cuando no obtiene URL; con URL la página se descarga y se mantiene.
|
|
5
|
+
|
|
6
|
+
const setIsLogging = (value: boolean) => appActions.setIsLogging(value);
|
|
7
|
+
|
|
8
|
+
const run = async () => {
|
|
9
|
+
const dispatch = vi.fn();
|
|
10
|
+
const result = await appActions.loginSSO()(dispatch);
|
|
11
|
+
|
|
12
|
+
return { dispatch, result };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("loginSSO · isLogging", () => {
|
|
16
|
+
it("con URL devuelve la URL y deja isLogging en true", async () => {
|
|
17
|
+
vi.spyOn(global, "login").mockResolvedValue({ status: 200, data: "https://sso/start" } as never);
|
|
18
|
+
|
|
19
|
+
const { dispatch, result } = await run();
|
|
20
|
+
|
|
21
|
+
expect(result).toBe("https://sso/start");
|
|
22
|
+
expect(dispatch).toHaveBeenCalledExactlyOnceWith(setIsLogging(true));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("con estado HTTP no OK devuelve null y repone isLogging a false", async () => {
|
|
26
|
+
vi.spyOn(global, "login").mockResolvedValue({ status: 500, data: null } as never);
|
|
27
|
+
|
|
28
|
+
const { dispatch, result } = await run();
|
|
29
|
+
|
|
30
|
+
expect(result).toBeNull();
|
|
31
|
+
expect(dispatch).toHaveBeenNthCalledWith(1, setIsLogging(true));
|
|
32
|
+
expect(dispatch).toHaveBeenLastCalledWith(setIsLogging(false));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("con un error de red devuelve null y repone isLogging a false", async () => {
|
|
36
|
+
vi.spyOn(global, "login").mockRejectedValue(new Error("net"));
|
|
37
|
+
|
|
38
|
+
const { dispatch, result } = await run();
|
|
39
|
+
|
|
40
|
+
expect(result).toBeNull();
|
|
41
|
+
expect(dispatch).toHaveBeenLastCalledWith(setIsLogging(false));
|
|
42
|
+
expect(dispatch).toHaveBeenCalledTimes(2);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it.each([
|
|
46
|
+
["cadena vacía", ""],
|
|
47
|
+
["null", null],
|
|
48
|
+
["undefined", undefined],
|
|
49
|
+
])("con estado OK pero data %s devuelve null y repone isLogging a false", async (_n, data) => {
|
|
50
|
+
vi.spyOn(global, "login").mockResolvedValue({ status: 200, data } as never);
|
|
51
|
+
|
|
52
|
+
const { dispatch, result } = await run();
|
|
53
|
+
|
|
54
|
+
expect(result).toBeNull();
|
|
55
|
+
expect(dispatch).toHaveBeenLastCalledWith(setIsLogging(false));
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { structuredData } from "@ax/api";
|
|
2
|
+
import { pageEditorActions } from "@ax/containers/PageEditor";
|
|
3
|
+
|
|
4
|
+
// Pasting a distributor module in manual mode re-validates data.fixed with the same request the manual
|
|
5
|
+
// distributor list uses (getDistributorContent), so what the module shows is what survives the paste.
|
|
6
|
+
// data.site is only the selector's value when the editor pressed Add: it must never drop data.
|
|
7
|
+
vi.mock("@ax/containers/PageEditor/utils", async (importOriginal) => {
|
|
8
|
+
const original: any = await importOriginal();
|
|
9
|
+
return { ...original, checkMaxModules: () => ({ isMaxModules: false }) };
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const WARNING_TEXT = "Some distributor data were not copied because they no longer exist";
|
|
13
|
+
|
|
14
|
+
const makeState = (pasted: any[], currentSiteInfo: any = { id: 7 }) =>
|
|
15
|
+
({
|
|
16
|
+
pageEditor: {
|
|
17
|
+
selectedEditorID: 0,
|
|
18
|
+
isNewTranslation: false,
|
|
19
|
+
selectedContent: null,
|
|
20
|
+
template: "BasicTemplate",
|
|
21
|
+
errors: [],
|
|
22
|
+
editorContent: {
|
|
23
|
+
id: 100,
|
|
24
|
+
header: null,
|
|
25
|
+
footer: null,
|
|
26
|
+
template: { component: "BasicTemplate", editorID: 0, content: pasted },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
sites: { currentSiteInfo },
|
|
30
|
+
navigation: { currentDefaultsContent: [] },
|
|
31
|
+
dataPacks: { configFormData: {} },
|
|
32
|
+
app: { lang: 1 },
|
|
33
|
+
}) as any;
|
|
34
|
+
|
|
35
|
+
const distributor = (data: Record<string, unknown>) => ({
|
|
36
|
+
component: "Distributor",
|
|
37
|
+
editorID: 5,
|
|
38
|
+
hasDistributorData: true,
|
|
39
|
+
data: { mode: "manual", fixed: [1, 2, 3], fullRelations: true, ...data },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const distributorContent = (ids: number[], status = 200) =>
|
|
43
|
+
vi.spyOn(structuredData, "getDistributorContent").mockResolvedValue({
|
|
44
|
+
status,
|
|
45
|
+
data: ids.map((id) => ({ id, relatedSite: null })),
|
|
46
|
+
} as any);
|
|
47
|
+
|
|
48
|
+
const paste = async (module: any, currentSiteInfo: any = { id: 7 }) => {
|
|
49
|
+
const items: any[] = [];
|
|
50
|
+
const state = makeState(items, currentSiteInfo);
|
|
51
|
+
const result: any = await pageEditorActions.pasteModule(0, "content", [module])(vi.fn(), () => state);
|
|
52
|
+
return { items, result };
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
describe("[UC-AX-compose-page-modules] pasteModule · distributor data", () => {
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
vi.restoreAllMocks();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("AC7 · global data without data.site is kept, no warning", async () => {
|
|
61
|
+
const spy = distributorContent([1, 2, 3]);
|
|
62
|
+
const { items, result } = await paste(distributor({}));
|
|
63
|
+
|
|
64
|
+
expect(spy).toHaveBeenCalledWith(7, { mode: "manual", fixed: [1, 2, 3], fullRelations: true, site: undefined });
|
|
65
|
+
expect(items[0].data.fixed).toEqual([1, 2, 3]);
|
|
66
|
+
expect(result.error).toBeUndefined();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("AC7 · selector changed after marking (data.site differs from the data's site): data are kept", async () => {
|
|
70
|
+
const spy = distributorContent([320]);
|
|
71
|
+
const { items, result } = await paste(distributor({ fixed: [320], site: 630 }));
|
|
72
|
+
|
|
73
|
+
expect(spy).toHaveBeenCalledWith(7, { mode: "manual", fixed: [320], fullRelations: true, site: 630 });
|
|
74
|
+
expect(items[0].data.fixed).toEqual([320]);
|
|
75
|
+
expect(result.error).toBeUndefined();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("AC7 · some ids no longer exist: keeps the returned ones and warns", async () => {
|
|
79
|
+
distributorContent([1, 3]);
|
|
80
|
+
const { items, result } = await paste(distributor({}));
|
|
81
|
+
|
|
82
|
+
expect(items[0].data.fixed).toEqual([1, 3]);
|
|
83
|
+
expect(result.error).toEqual({ type: "warning", text: WARNING_TEXT });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("AC7 · no id exists: fixed is empty and warns", async () => {
|
|
87
|
+
distributorContent([]);
|
|
88
|
+
const { items, result } = await paste(distributor({}));
|
|
89
|
+
|
|
90
|
+
expect(items[0].data.fixed).toEqual([]);
|
|
91
|
+
expect(result.error).toEqual({ type: "warning", text: WARNING_TEXT });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("AC7 · auto mode or no hasDistributorData: the request is not made", async () => {
|
|
95
|
+
const spy = distributorContent([1]);
|
|
96
|
+
await paste(distributor({ mode: "auto" }));
|
|
97
|
+
await paste({ ...distributor({}), hasDistributorData: false });
|
|
98
|
+
|
|
99
|
+
expect(spy).not.toHaveBeenCalled();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("AC7 · no current site (global context): asks as global", async () => {
|
|
103
|
+
const spy = distributorContent([1, 2, 3]);
|
|
104
|
+
await paste(distributor({}), null);
|
|
105
|
+
|
|
106
|
+
expect(spy).toHaveBeenCalledWith("global", expect.objectContaining({ fixed: [1, 2, 3] }));
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("AC7 · a failed request leaves the module's data untouched", async () => {
|
|
110
|
+
distributorContent([], 500);
|
|
111
|
+
const { items, result } = await paste(distributor({}));
|
|
112
|
+
|
|
113
|
+
expect(items[0].data.fixed).toEqual([1, 2, 3]);
|
|
114
|
+
expect(result.error).toBeUndefined();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
2
|
+
|
|
3
|
+
import { usePendingNavigation } from "@ax/hooks";
|
|
4
|
+
|
|
5
|
+
import { act, renderHook } from "@testing-library/react";
|
|
6
|
+
|
|
7
|
+
type Deferred<T> = { promise: Promise<T>; resolve: (v: T) => void; reject: (e: unknown) => void };
|
|
8
|
+
|
|
9
|
+
const deferred = <T,>(): Deferred<T> => {
|
|
10
|
+
let resolve!: (v: T) => void;
|
|
11
|
+
let reject!: (e: unknown) => void;
|
|
12
|
+
const promise = new Promise<T>((res, rej) => {
|
|
13
|
+
resolve = res;
|
|
14
|
+
reject = rej;
|
|
15
|
+
});
|
|
16
|
+
return { promise, resolve, reject };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const firePageShow = (persisted: boolean) => {
|
|
20
|
+
const event = new Event("pageshow") as PageTransitionEvent;
|
|
21
|
+
Object.defineProperty(event, "persisted", { value: persisted });
|
|
22
|
+
window.dispatchEvent(event);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe("usePendingNavigation", () => {
|
|
26
|
+
it("AC6 · pending pasa a true antes de que la acción termine", async () => {
|
|
27
|
+
const d = deferred<string | null>();
|
|
28
|
+
const { result } = renderHook(() => usePendingNavigation(() => d.promise));
|
|
29
|
+
|
|
30
|
+
expect(result.current.pending).toBe(false);
|
|
31
|
+
|
|
32
|
+
let run!: Promise<void>;
|
|
33
|
+
act(() => {
|
|
34
|
+
run = result.current.run();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
expect(result.current.pending).toBe(true);
|
|
38
|
+
await act(async () => {
|
|
39
|
+
d.resolve("https://sso");
|
|
40
|
+
await run;
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("AC6 · con un valor truthy pending se mantiene (la página se descarga)", async () => {
|
|
45
|
+
const { result } = renderHook(() => usePendingNavigation(async () => "https://sso"));
|
|
46
|
+
|
|
47
|
+
await act(async () => {
|
|
48
|
+
await result.current.run();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(result.current.pending).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("AC12 · con undefined (navegación síncrona) pending se mantiene", async () => {
|
|
55
|
+
const { result } = renderHook(() => usePendingNavigation(() => undefined));
|
|
56
|
+
|
|
57
|
+
await act(async () => {
|
|
58
|
+
await result.current.run();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(result.current.pending).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it.each([
|
|
65
|
+
["null", null],
|
|
66
|
+
["cadena vacía", ""],
|
|
67
|
+
])("AC6 · un retorno %s libera el botón", async (_n, value) => {
|
|
68
|
+
const { result } = renderHook(() => usePendingNavigation(async () => value));
|
|
69
|
+
|
|
70
|
+
await act(async () => {
|
|
71
|
+
await result.current.run();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
expect(result.current.pending).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("AC6 · un rechazo libera el botón y no queda sin capturar", async () => {
|
|
78
|
+
const { result } = renderHook(() =>
|
|
79
|
+
usePendingNavigation(async () => {
|
|
80
|
+
throw new Error("boom");
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
await act(async () => {
|
|
85
|
+
await expect(result.current.run()).resolves.toBeUndefined();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(result.current.pending).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("AC6 · un rechazo se registra en consola para poder diagnosticarlo", async () => {
|
|
92
|
+
const error = new Error("boom");
|
|
93
|
+
const log = vi.spyOn(console, "error").mockImplementation(() => undefined);
|
|
94
|
+
const { result } = renderHook(() =>
|
|
95
|
+
usePendingNavigation(async () => {
|
|
96
|
+
throw error;
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
await act(async () => {
|
|
101
|
+
await result.current.run();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
expect(log).toHaveBeenCalledExactlyOnceWith(error);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("AC6 · una acción síncrona que lanza también libera el botón", async () => {
|
|
108
|
+
const { result } = renderHook(() =>
|
|
109
|
+
usePendingNavigation(() => {
|
|
110
|
+
throw new Error("sync");
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
await act(async () => {
|
|
115
|
+
await result.current.run();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(result.current.pending).toBe(false);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("AC6 · dos run() en el mismo instante lanzan una sola acción", async () => {
|
|
122
|
+
const action = vi.fn(async () => "url");
|
|
123
|
+
const { result } = renderHook(() => usePendingNavigation(action));
|
|
124
|
+
|
|
125
|
+
await act(async () => {
|
|
126
|
+
const first = result.current.run();
|
|
127
|
+
const second = result.current.run();
|
|
128
|
+
await Promise.all([first, second]);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
expect(action).toHaveBeenCalledTimes(1);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("AC6 · tras volver null se puede reintentar, incluso sin re-render intermedio", async () => {
|
|
135
|
+
const action = vi.fn(async () => null);
|
|
136
|
+
const { result } = renderHook(() => usePendingNavigation(action));
|
|
137
|
+
|
|
138
|
+
await act(async () => {
|
|
139
|
+
await result.current.run();
|
|
140
|
+
await result.current.run();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
expect(action).toHaveBeenCalledTimes(2);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("AC12 · pageshow persisted reactiva el botón y permite volver a ejecutar", async () => {
|
|
147
|
+
const action = vi.fn(() => undefined);
|
|
148
|
+
const { result } = renderHook(() => usePendingNavigation(action));
|
|
149
|
+
|
|
150
|
+
await act(async () => {
|
|
151
|
+
await result.current.run();
|
|
152
|
+
});
|
|
153
|
+
expect(result.current.pending).toBe(true);
|
|
154
|
+
|
|
155
|
+
act(() => firePageShow(true));
|
|
156
|
+
expect(result.current.pending).toBe(false);
|
|
157
|
+
|
|
158
|
+
await act(async () => {
|
|
159
|
+
await result.current.run();
|
|
160
|
+
});
|
|
161
|
+
expect(action).toHaveBeenCalledTimes(2);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("AC6 · pageshow no persistido no reactiva el botón", async () => {
|
|
165
|
+
const { result } = renderHook(() => usePendingNavigation(() => undefined));
|
|
166
|
+
|
|
167
|
+
await act(async () => {
|
|
168
|
+
await result.current.run();
|
|
169
|
+
});
|
|
170
|
+
act(() => firePageShow(false));
|
|
171
|
+
|
|
172
|
+
expect(result.current.pending).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("AC6 · al desmontar retira el listener y no actualiza estado si la acción termina después", async () => {
|
|
176
|
+
const add = vi.spyOn(window, "addEventListener");
|
|
177
|
+
const remove = vi.spyOn(window, "removeEventListener");
|
|
178
|
+
const errors = vi.spyOn(console, "error").mockImplementation(() => undefined);
|
|
179
|
+
const d = deferred<string | null>();
|
|
180
|
+
const { result, unmount } = renderHook(() => usePendingNavigation(() => d.promise));
|
|
181
|
+
|
|
182
|
+
let run!: Promise<void>;
|
|
183
|
+
act(() => {
|
|
184
|
+
run = result.current.run();
|
|
185
|
+
});
|
|
186
|
+
unmount();
|
|
187
|
+
|
|
188
|
+
const handler = add.mock.calls.find(([type]) => type === "pageshow")?.[1];
|
|
189
|
+
expect(handler).toBeDefined();
|
|
190
|
+
expect(remove).toHaveBeenCalledWith("pageshow", handler);
|
|
191
|
+
|
|
192
|
+
await act(async () => {
|
|
193
|
+
d.resolve(null);
|
|
194
|
+
await run;
|
|
195
|
+
});
|
|
196
|
+
expect(errors).not.toHaveBeenCalled();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("AC6 · usa la última acción recibida", async () => {
|
|
200
|
+
const first = vi.fn(async () => "a");
|
|
201
|
+
const second = vi.fn(async () => "b");
|
|
202
|
+
const { result, rerender } = renderHook(({ action }) => usePendingNavigation(action), {
|
|
203
|
+
initialProps: { action: first },
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
rerender({ action: second });
|
|
207
|
+
await act(async () => {
|
|
208
|
+
await result.current.run();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
expect(first).not.toHaveBeenCalled();
|
|
212
|
+
expect(second).toHaveBeenCalledTimes(1);
|
|
213
|
+
});
|
|
214
|
+
});
|
|
@@ -3,13 +3,13 @@ import { getLoginLocale, LOCALE } from "@ax/locales";
|
|
|
3
3
|
describe("getLoginLocale", () => {
|
|
4
4
|
it("devuelve el login del idioma fijo de AX (inglés), igual que LOCALE", () => {
|
|
5
5
|
expect(getLoginLocale()).toBe(LOCALE.login);
|
|
6
|
-
expect(getLoginLocale().griddoIdButton).toBe("Sign in with Griddo");
|
|
6
|
+
expect(getLoginLocale().griddoIdButton).toBe("Sign in with Griddo ID");
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
it.each(["es-ES", "es", "fr-FR", "en-GB", ""])("no depende del idioma del navegador (%j)", (language) => {
|
|
10
10
|
vi.spyOn(window.navigator, "language", "get").mockReturnValue(language);
|
|
11
11
|
|
|
12
|
-
expect(getLoginLocale().griddoIdButton).toBe("Sign in with Griddo");
|
|
12
|
+
expect(getLoginLocale().griddoIdButton).toBe("Sign in with Griddo ID");
|
|
13
13
|
expect(getLoginLocale().emailPasswordToggle).toBe("Login with email and password");
|
|
14
14
|
expect(getLoginLocale().submit).toBe("Login");
|
|
15
15
|
});
|
|
@@ -35,3 +35,14 @@ describe("getLoginLocale", () => {
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
+
|
|
39
|
+
describe("getLoginLocale · connecting", () => {
|
|
40
|
+
it("AC6 · texto «Connecting…» en en-US y es-ES (misma clave)", async () => {
|
|
41
|
+
const { enUS } = await import("../../locales/en-US");
|
|
42
|
+
const { esES } = await import("../../locales/es-ES");
|
|
43
|
+
|
|
44
|
+
expect(enUS.login.connecting).toBe("Connecting…");
|
|
45
|
+
expect(esES.login.connecting).toBe("Conectando…");
|
|
46
|
+
expect(getLoginLocale().connecting).toBe("Connecting…");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -58,7 +58,7 @@ describe("módulo Login con auth.griddo.io", () => {
|
|
|
58
58
|
vi.stubGlobal("location", { ...window.location, assign });
|
|
59
59
|
renderModule({ GriddoIdEnabled: true });
|
|
60
60
|
|
|
61
|
-
const button = screen.getByRole("button", { name: "Sign in with Griddo" });
|
|
61
|
+
const button = screen.getByRole("button", { name: "Sign in with Griddo ID" });
|
|
62
62
|
|
|
63
63
|
fireEvent.click(button);
|
|
64
64
|
fireEvent.click(button);
|
|
@@ -80,7 +80,7 @@ describe("módulo Login con auth.griddo.io", () => {
|
|
|
80
80
|
vi.stubGlobal("location", { ...window.location, assign });
|
|
81
81
|
renderModule({ GriddoIdEnabled: true });
|
|
82
82
|
|
|
83
|
-
return { assign, button: screen.getByRole("button", { name: "Sign in with Griddo" }) };
|
|
83
|
+
return { assign, button: screen.getByRole("button", { name: "Sign in with Griddo ID" }) };
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
it("envía el email escrito como login_hint, recortado y codificado", () => {
|
|
@@ -145,7 +145,7 @@ describe("módulo Login con auth.griddo.io", () => {
|
|
|
145
145
|
expect(screen.getByPlaceholderText("Type your email")).not.toBeVisible();
|
|
146
146
|
openForm();
|
|
147
147
|
expect(screen.getByPlaceholderText("Type your email")).toBeVisible();
|
|
148
|
-
expect(screen.getByRole("button", { name: "Sign in with Griddo" })).toBeInTheDocument();
|
|
148
|
+
expect(screen.getByRole("button", { name: "Sign in with Griddo ID" })).toBeInTheDocument();
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
it("con el flag activo muestra el logo «griddo dxp» arriba a la izquierda", () => {
|
|
@@ -163,7 +163,7 @@ describe("módulo Login con auth.griddo.io", () => {
|
|
|
163
163
|
it("con el flag apagado (o sin settings) muestra el formulario de siempre", () => {
|
|
164
164
|
renderModule({ GriddoIdEnabled: false });
|
|
165
165
|
|
|
166
|
-
expect(screen.queryByText("Sign in with Griddo")).toBeNull();
|
|
166
|
+
expect(screen.queryByText("Sign in with Griddo ID")).toBeNull();
|
|
167
167
|
expect(screen.getByPlaceholderText("Type your email")).toBeInTheDocument();
|
|
168
168
|
});
|
|
169
169
|
});
|
|
@@ -18,6 +18,7 @@ const actions = vi.hoisted(() => ({
|
|
|
18
18
|
login: vi.fn(),
|
|
19
19
|
loginSSO: vi.fn(),
|
|
20
20
|
setHistoryPush: vi.fn(),
|
|
21
|
+
ssoResult: { value: "https://sso.uni.es/start" as string | null },
|
|
21
22
|
}));
|
|
22
23
|
|
|
23
24
|
vi.mock("@ax/containers/App", async (importOriginal) => {
|
|
@@ -35,7 +36,7 @@ vi.mock("@ax/containers/App", async (importOriginal) => {
|
|
|
35
36
|
loginSSO: () => {
|
|
36
37
|
actions.loginSSO();
|
|
37
38
|
|
|
38
|
-
return async () =>
|
|
39
|
+
return async () => actions.ssoResult.value;
|
|
39
40
|
},
|
|
40
41
|
setHistoryPush: (path: string) => {
|
|
41
42
|
actions.setHistoryPush(path);
|
|
@@ -50,6 +51,7 @@ vi.mock("@ax/containers/App", async (importOriginal) => {
|
|
|
50
51
|
|
|
51
52
|
afterEach(() => {
|
|
52
53
|
cleanup();
|
|
54
|
+
actions.ssoResult.value = SSO_URL;
|
|
53
55
|
vi.clearAllMocks();
|
|
54
56
|
vi.unstubAllGlobals();
|
|
55
57
|
});
|
|
@@ -99,6 +101,22 @@ describe("[UC-AX-sign-in-out] módulo Login", () => {
|
|
|
99
101
|
expect(actions.loginSSO).toHaveBeenCalledTimes(1);
|
|
100
102
|
});
|
|
101
103
|
|
|
104
|
+
it("AC6 · sin URL no se navega y el botón SSO vuelve a estar habilitado", async () => {
|
|
105
|
+
const open = vi.fn();
|
|
106
|
+
|
|
107
|
+
actions.ssoResult.value = null;
|
|
108
|
+
vi.stubGlobal("open", open);
|
|
109
|
+
renderAt("/login", { SSOActivated: true });
|
|
110
|
+
|
|
111
|
+
fireEvent.click(screen.getAllByRole("button")[0]);
|
|
112
|
+
|
|
113
|
+
await waitFor(() => expect(actions.loginSSO).toHaveBeenCalledTimes(1));
|
|
114
|
+
await waitFor(() => expect(screen.getAllByRole("button")[0]).toBeEnabled());
|
|
115
|
+
expect(open).not.toHaveBeenCalled();
|
|
116
|
+
fireEvent.click(screen.getAllByRole("button")[0]);
|
|
117
|
+
await waitFor(() => expect(actions.loginSSO).toHaveBeenCalledTimes(2));
|
|
118
|
+
});
|
|
119
|
+
|
|
102
120
|
it.each([
|
|
103
121
|
["noemail", "No email found in token"],
|
|
104
122
|
["noregistered+ana@uni.es", "The email ana@uni.es isn't registered in Griddo."],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
+
|
|
2
3
|
import Icon from "../Icon";
|
|
3
4
|
import Loader from "../Loader";
|
|
4
5
|
|
|
@@ -14,6 +15,7 @@ enum buttonStyles {
|
|
|
14
15
|
|
|
15
16
|
const Button = (props: IButtonProps): JSX.Element => {
|
|
16
17
|
const { children, type, disabled, icon, buttonStyle, onClick, className, loader, backIcon, iconFill = true } = props;
|
|
18
|
+
const ariaBusy = props["aria-busy"];
|
|
17
19
|
|
|
18
20
|
const handleOnClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
19
21
|
if (onClick !== undefined) {
|
|
@@ -45,6 +47,7 @@ const Button = (props: IButtonProps): JSX.Element => {
|
|
|
45
47
|
className={className}
|
|
46
48
|
type={type}
|
|
47
49
|
disabled={disabled}
|
|
50
|
+
aria-busy={ariaBusy}
|
|
48
51
|
onClick={handleOnClick}
|
|
49
52
|
>
|
|
50
53
|
{buttonContent}
|
|
@@ -58,6 +61,7 @@ const Button = (props: IButtonProps): JSX.Element => {
|
|
|
58
61
|
className={className}
|
|
59
62
|
type={type}
|
|
60
63
|
disabled={disabled}
|
|
64
|
+
aria-busy={ariaBusy}
|
|
61
65
|
onClick={handleOnClick}
|
|
62
66
|
isInverse={isInverse}
|
|
63
67
|
>
|
|
@@ -71,6 +75,7 @@ const Button = (props: IButtonProps): JSX.Element => {
|
|
|
71
75
|
className={className}
|
|
72
76
|
type={type}
|
|
73
77
|
disabled={disabled}
|
|
78
|
+
aria-busy={ariaBusy}
|
|
74
79
|
onClick={handleOnClick}
|
|
75
80
|
>
|
|
76
81
|
{buttonContent}
|
|
@@ -83,6 +88,7 @@ const Button = (props: IButtonProps): JSX.Element => {
|
|
|
83
88
|
className={className}
|
|
84
89
|
type={type}
|
|
85
90
|
disabled={disabled}
|
|
91
|
+
aria-busy={ariaBusy}
|
|
86
92
|
onClick={handleOnClick}
|
|
87
93
|
iconFill={iconFill}
|
|
88
94
|
>
|
|
@@ -103,6 +109,8 @@ export interface IButtonProps {
|
|
|
103
109
|
className?: string;
|
|
104
110
|
backIcon?: string;
|
|
105
111
|
iconFill?: boolean;
|
|
112
|
+
/** Marca el botón como ocupado (p. ej. mientras conecta) para tecnologías de apoyo. */
|
|
113
|
+
"aria-busy"?: boolean;
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
export default Button;
|
package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/index.tsx
CHANGED
|
@@ -58,7 +58,8 @@ export const TemplateManager = (props: IProps) => {
|
|
|
58
58
|
return acc;
|
|
59
59
|
}, []);
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// A module may be both whitelisted by the schema and injected by a data pack: offer it once (sc-125145).
|
|
62
|
+
const mappedWhiteList: string[] = [...new Set([...(whiteList ?? []), ...addedModules])].sort();
|
|
62
63
|
const filteredWhiteList = filterThemeModules(themeElements, mappedWhiteList);
|
|
63
64
|
const categories = getModuleCategories(filteredWhiteList);
|
|
64
65
|
|
|
@@ -1,46 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Loader } from "@ax/components";
|
|
2
|
+
import { usePendingNavigation } from "@ax/hooks";
|
|
3
3
|
import { getLoginLocale } from "@ax/locales";
|
|
4
4
|
|
|
5
5
|
import * as S from "./style";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* «Entrar con Griddo» (`auth.griddo.io`), sobre el formulario de usuario y contraseña. Solo existe junto al login
|
|
9
|
-
* normal: con el SSO de Comillas activo no se muestra.
|
|
9
|
+
* normal: con el SSO de Comillas activo no se muestra. Mientras navega queda deshabilitado con loader y ignora
|
|
10
|
+
* clics repetidos; con «Atrás» (bfcache) vuelve a funcionar.
|
|
10
11
|
*/
|
|
11
12
|
const LoginGriddoId = (props: ILoginGriddoIdProps): JSX.Element => {
|
|
12
13
|
const { handleGriddoId, errorSSO } = props;
|
|
13
14
|
|
|
14
15
|
const text = getLoginLocale();
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
// Con «Atrás» el navegador puede restaurar esta página de su caché (bfcache) con el estado de antes de navegar:
|
|
18
|
-
// el botón debe volver a funcionar.
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const handlePageShow = (e: PageTransitionEvent) => {
|
|
21
|
-
if (e.persisted) hasNavigated.current = false;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
window.addEventListener("pageshow", handlePageShow);
|
|
25
|
-
|
|
26
|
-
return () => window.removeEventListener("pageshow", handlePageShow);
|
|
27
|
-
}, []);
|
|
28
|
-
|
|
29
|
-
// Un doble clic no debe iniciar dos flujos: la segunda pulsación se ignora.
|
|
30
|
-
const handleClick = () => {
|
|
31
|
-
if (hasNavigated.current) return;
|
|
32
|
-
|
|
33
|
-
hasNavigated.current = true;
|
|
34
|
-
handleGriddoId();
|
|
35
|
-
};
|
|
16
|
+
const { pending, run: handleClick } = usePendingNavigation(handleGriddoId);
|
|
36
17
|
|
|
37
18
|
return (
|
|
38
19
|
<S.Alternatives>
|
|
39
20
|
{errorSSO && <S.StyledNotification text={errorSSO} type="error" closeButton={false} />}
|
|
40
|
-
<S.FullWidthButton type="button" onClick={handleClick}>
|
|
21
|
+
<S.FullWidthButton type="button" onClick={handleClick} disabled={pending} aria-busy={pending}>
|
|
41
22
|
<S.ContentButton>
|
|
42
|
-
|
|
43
|
-
|
|
23
|
+
{pending ? (
|
|
24
|
+
<S.LoaderIcon>
|
|
25
|
+
<Loader name="circle" size="16" />
|
|
26
|
+
</S.LoaderIcon>
|
|
27
|
+
) : (
|
|
28
|
+
<S.Mark src="/img/logos/logoGriddoG.svg" alt="" />
|
|
29
|
+
)}
|
|
30
|
+
<S.TextButton>{pending ? text.connecting : text.griddoIdButton}</S.TextButton>
|
|
44
31
|
</S.ContentButton>
|
|
45
32
|
</S.FullWidthButton>
|
|
46
33
|
</S.Alternatives>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
|
|
3
|
-
import { StyledButton } from "../LoginSSO/style";
|
|
3
|
+
import { LoaderIcon as BaseLoaderIcon, StyledButton } from "../LoginSSO/style";
|
|
4
4
|
|
|
5
5
|
export { ContentButton, IconButton, StyledNotification, TextButton } from "../LoginSSO/style";
|
|
6
6
|
|
|
@@ -32,4 +32,9 @@ const Mark = styled.img`
|
|
|
32
32
|
margin-right: 12px;
|
|
33
33
|
`;
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
// Mismo hueco que `Mark` (16px + 12px de margen) para que el texto no se desplace al conectar.
|
|
36
|
+
const LoaderIcon = styled(BaseLoaderIcon)`
|
|
37
|
+
margin-right: 12px;
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export { Alternatives, FullWidthButton, LoaderIcon, Mark };
|