@griddo/ax 12.16.0 → 12.17.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/README.md +1 -0
- package/config/griddo-config/index.js +3 -2
- package/package.json +7 -4
- package/public/img/logos/logoGriddoDxp.svg +22 -0
- package/public/img/logos/logoGriddoG.svg +10 -0
- package/src/GlobalStore.tsx +32 -25
- package/src/__tests__/GlobalStore.session.test.tsx +98 -0
- package/src/__tests__/api/global.test.ts +64 -0
- package/src/__tests__/api/session.test.ts +311 -0
- package/src/__tests__/api/sessionRenewal.test.ts +705 -0
- package/src/__tests__/api/utils.test.ts +373 -0
- package/src/__tests__/components/Fields/FileField/FileField.test.tsx +33 -6
- package/src/__tests__/components/FieldsBehavior/FieldsBehavior.test.tsx +5 -3
- package/src/__tests__/components/Login/BrandPalette.test.tsx +145 -0
- package/src/__tests__/components/Login/Login.test.tsx +2 -33
- package/src/__tests__/components/Login/LoginCollapsible.test.tsx +271 -0
- package/src/__tests__/components/Login/LoginDropdownCard.test.tsx +311 -0
- package/src/__tests__/components/Login/LoginFooter.test.tsx +128 -0
- package/src/__tests__/components/Login/LoginGriddoId.test.tsx +213 -0
- package/src/__tests__/components/Login/LoginInlineError.test.tsx +116 -0
- package/src/__tests__/components/Login/RecoveryModal/RecoveryModal.test.tsx +3 -4
- package/src/__tests__/components/SsoDenied/SsoDenied.test.tsx +86 -0
- package/src/__tests__/config/webpackAliases.test.ts +18 -0
- package/src/__tests__/containers/App/reducer.griddoId.test.ts +18 -0
- package/src/__tests__/containers/App/session.test.ts +397 -0
- package/src/__tests__/containers/App/signInOut.test.ts +159 -0
- package/src/__tests__/helpers/griddoId.test.ts +56 -0
- package/src/__tests__/hooks/useShouldBeSaved.test.tsx +78 -0
- package/src/__tests__/locales/loginLocale.test.ts +37 -0
- package/src/__tests__/modules/App/Routing/NavMenu.test.tsx +54 -0
- package/src/__tests__/modules/App/Routing/PrivateRoute.test.tsx +64 -0
- package/src/__tests__/modules/App/Routing/Routing.startup.test.tsx +79 -0
- package/src/__tests__/modules/Login/Login.test.tsx +169 -0
- package/src/__tests__/modules/Login/loginError.uc.test.tsx +294 -0
- package/src/__tests__/modules/Login/signInOut.test.tsx +125 -0
- package/src/__tests__/modules/Redirects/RedirectPanel/RedirectPanel.test.tsx +9 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.create.test.tsx +19 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.edit.test.tsx +19 -0
- package/src/__tests__/modules/Redirects/Redirects/Redirects.filter.test.tsx +19 -0
- package/src/__tests__/modules/SsoDenied/SsoDenied.test.tsx +30 -0
- package/src/__tests__/routes/publicRoutes.test.ts +36 -0
- package/src/api/global.tsx +24 -1
- package/src/api/session.tsx +197 -0
- package/src/api/sessionRenewal.tsx +114 -0
- package/src/api/utils.tsx +22 -12
- package/src/{helpers/categoryColumns.tsx → components/CategoryCell/buildCategoryColumns.tsx} +3 -2
- package/src/components/Circle/index.tsx +1 -1
- package/src/components/Circle/style.tsx +4 -2
- package/src/components/ErrorPage/index.tsx +1 -1
- package/src/components/ErrorPage/style.tsx +11 -9
- package/src/components/ErrorToast/index.tsx +2 -0
- package/src/{helpers/fields.tsx → components/FieldsBehavior/getFieldByPath.tsx} +1 -1
- package/src/components/FieldsBehavior/index.tsx +3 -1
- package/src/components/Login/LoginFooter/index.tsx +16 -0
- package/src/components/Login/LoginFooter/style.tsx +17 -0
- package/src/components/Login/LoginForm/index.tsx +147 -79
- package/src/components/Login/LoginForm/style.tsx +147 -24
- package/src/components/Login/LoginGriddoId/index.tsx +56 -0
- package/src/components/Login/LoginGriddoId/style.tsx +35 -0
- package/src/components/Login/LoginSSO/index.tsx +4 -7
- package/src/components/Login/LoginSSO/style.tsx +10 -26
- package/src/components/Login/LoginSlider/style.tsx +5 -5
- package/src/components/Login/index.tsx +35 -6
- package/src/components/Login/style.tsx +40 -24
- package/src/components/Notification/index.tsx +3 -1
- package/src/components/SsoDenied/index.tsx +46 -0
- package/src/components/SsoDenied/style.tsx +37 -0
- package/src/components/index.tsx +11 -7
- package/src/containers/App/actions.tsx +114 -6
- package/src/containers/App/interfaces.tsx +2 -2
- package/src/containers/App/reducer.tsx +9 -0
- package/src/containers/Users/actions.tsx +28 -24
- package/src/helpers/griddoId.ts +28 -0
- package/src/helpers/index.tsx +4 -5
- package/src/hooks/forms.tsx +8 -5
- package/src/locales/en-US.ts +13 -0
- package/src/locales/es-ES.ts +13 -0
- package/src/locales/index.ts +9 -1
- package/src/modules/App/Routing/NavMenu/index.tsx +4 -4
- package/src/modules/Content/PageItem/index.tsx +6 -8
- package/src/modules/Login/index.tsx +33 -14
- package/src/modules/SsoDenied/index.tsx +9 -0
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +6 -8
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +9 -11
- package/src/modules/Users/UserEdit/index.tsx +9 -2
- package/src/routes/publicRoutes.tsx +3 -0
- package/src/themes/brandPalette.ts +16 -0
- package/public/img/logos/logoSQY.svg +0 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getLoginLocale, LOCALE } from "@ax/locales";
|
|
2
|
+
|
|
3
|
+
describe("getLoginLocale", () => {
|
|
4
|
+
it("devuelve el login del idioma fijo de AX (inglés), igual que LOCALE", () => {
|
|
5
|
+
expect(getLoginLocale()).toBe(LOCALE.login);
|
|
6
|
+
expect(getLoginLocale().griddoIdButton).toBe("Sign in with Griddo");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it.each(["es-ES", "es", "fr-FR", "en-GB", ""])("no depende del idioma del navegador (%j)", (language) => {
|
|
10
|
+
vi.spyOn(window.navigator, "language", "get").mockReturnValue(language);
|
|
11
|
+
|
|
12
|
+
expect(getLoginLocale().griddoIdButton).toBe("Sign in with Griddo");
|
|
13
|
+
expect(getLoginLocale().emailPasswordToggle).toBe("Login with email and password");
|
|
14
|
+
expect(getLoginLocale().submit).toBe("Login");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("sin idioma del navegador sigue en inglés", () => {
|
|
18
|
+
vi.spyOn(window.navigator, "language", "get").mockReturnValue(undefined as unknown as string);
|
|
19
|
+
|
|
20
|
+
expect(getLoginLocale().welcome).toBe("Welcome");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("textos fijos de acceso denegado", () => {
|
|
24
|
+
expect(getLoginLocale().deniedTitle).toBe("You don't have access to this instance");
|
|
25
|
+
expect(getLoginLocale().switchAccount).toBe("Sign in with another account");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("textos del botón de envío", () => {
|
|
29
|
+
expect(getLoginLocale()).toMatchObject({ submit: "Login", submitting: "Sending" });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("ya no hay separador «o» ni texto de «Acceso de administración»", () => {
|
|
33
|
+
for (const key of ["or", "emailPasswordHint", "adminAccess"]) {
|
|
34
|
+
expect(getLoginLocale()).not.toHaveProperty(key);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Provider } from "react-redux";
|
|
2
|
+
import { Router } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
5
|
+
import configureStore from "redux-mock-store";
|
|
6
|
+
import { ThemeProvider } from "styled-components";
|
|
7
|
+
import "@testing-library/jest-dom";
|
|
8
|
+
|
|
9
|
+
import { appInitialState } from "@ax/containers/App/reducer";
|
|
10
|
+
import { parseTheme } from "@ax/helpers";
|
|
11
|
+
import NavMenu from "@ax/modules/App/Routing/NavMenu";
|
|
12
|
+
import history from "@ax/routes/history";
|
|
13
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
14
|
+
|
|
15
|
+
vi.mock("@ax/containers/App", async (importOriginal) => {
|
|
16
|
+
const original = await importOriginal<typeof import("@ax/containers/App")>();
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
...original,
|
|
20
|
+
appActions: {
|
|
21
|
+
...original.appActions,
|
|
22
|
+
logoutAndEndCentralSession: () => ({ type: "test/logoutAndEndCentralSession" }),
|
|
23
|
+
logoutAndNavigate: () => ({ type: "test/logoutAndNavigate" }),
|
|
24
|
+
setHistoryPush: () => ({ type: "test/setHistoryPush" }),
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(cleanup);
|
|
30
|
+
|
|
31
|
+
describe("NavMenu: botón «Logout»", () => {
|
|
32
|
+
it("usa el cierre completo (con la sesión central de auth.griddo.io), no el solo local", () => {
|
|
33
|
+
const store = configureStore([])({
|
|
34
|
+
app: { ...appInitialState, lang: { locale: "es-ES", id: 1 }, globalSettings: appInitialState.globalSettings },
|
|
35
|
+
structuredData: { categories: { global: [], site: [] }, structuredData: { global: [], site: [] } },
|
|
36
|
+
sites: { currentSiteInfo: null, currentSiteLanguages: [] },
|
|
37
|
+
users: { currentUser: null },
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
render(
|
|
41
|
+
<Provider store={store}>
|
|
42
|
+
<Router history={history}>
|
|
43
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
44
|
+
<NavMenu />
|
|
45
|
+
</ThemeProvider>
|
|
46
|
+
</Router>
|
|
47
|
+
</Provider>,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
fireEvent.click(screen.getAllByText("Logout")[0]);
|
|
51
|
+
|
|
52
|
+
expect(store.getActions()).toEqual([{ type: "test/logoutAndEndCentralSession" }]);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { MemoryRouter, Route } from "react-router-dom";
|
|
2
|
+
|
|
3
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
4
|
+
import { ThemeProvider } from "styled-components";
|
|
5
|
+
import "@testing-library/jest-dom";
|
|
6
|
+
|
|
7
|
+
import { parseTheme } from "@ax/helpers";
|
|
8
|
+
import PrivateRoute from "@ax/modules/App/Routing/PrivateRoute";
|
|
9
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
10
|
+
import type { IUser } from "@ax/types";
|
|
11
|
+
|
|
12
|
+
const usePermission = vi.hoisted(() => vi.fn());
|
|
13
|
+
|
|
14
|
+
vi.mock("@ax/hooks", async (importOriginal) => ({
|
|
15
|
+
...(await importOriginal<typeof import("@ax/hooks")>()),
|
|
16
|
+
usePermission,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
afterEach(cleanup);
|
|
20
|
+
|
|
21
|
+
const Private = () => <p>área privada</p>;
|
|
22
|
+
const currentUser = { id: 1 } as IUser;
|
|
23
|
+
|
|
24
|
+
const renderAt = (token: string, allowed: boolean) => {
|
|
25
|
+
usePermission.mockReturnValue(allowed);
|
|
26
|
+
|
|
27
|
+
render(
|
|
28
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
29
|
+
<MemoryRouter initialEntries={["/sites"]}>
|
|
30
|
+
<PrivateRoute
|
|
31
|
+
path="/sites"
|
|
32
|
+
component={Private}
|
|
33
|
+
token={token}
|
|
34
|
+
currentUser={currentUser}
|
|
35
|
+
permission="sites.view"
|
|
36
|
+
exact
|
|
37
|
+
/>
|
|
38
|
+
<Route path="/login" render={() => <p>pantalla de login</p>} />
|
|
39
|
+
</MemoryRouter>
|
|
40
|
+
</ThemeProvider>,
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
describe("[UC-AX-sign-in-out] PrivateRoute", () => {
|
|
45
|
+
it("AC4 · ruta privada sin token → redirige a /login", () => {
|
|
46
|
+
renderAt("", true);
|
|
47
|
+
|
|
48
|
+
expect(screen.getByText("pantalla de login")).toBeInTheDocument();
|
|
49
|
+
expect(screen.queryByText("área privada")).toBeNull();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("AC4 · token pero sin permiso → ErrorPage forbidden", () => {
|
|
53
|
+
renderAt("jwt", false);
|
|
54
|
+
|
|
55
|
+
expect(screen.getByText("Access Denied")).toBeInTheDocument();
|
|
56
|
+
expect(screen.queryByText("área privada")).toBeNull();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("AC4 (borde) · token y permiso → renderiza la ruta", () => {
|
|
60
|
+
renderAt("jwt", true);
|
|
61
|
+
|
|
62
|
+
expect(screen.getByText("área privada")).toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Provider } from "react-redux";
|
|
2
|
+
import { MemoryRouter } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
import { appInitialState } from "@ax/containers/App/reducer";
|
|
5
|
+
import { parseTheme } from "@ax/helpers";
|
|
6
|
+
import Routing from "@ax/modules/App/Routing";
|
|
7
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
8
|
+
|
|
9
|
+
import { cleanup, render } from "@testing-library/react";
|
|
10
|
+
import configureStore from "redux-mock-store";
|
|
11
|
+
import { ThemeProvider } from "styled-components";
|
|
12
|
+
|
|
13
|
+
const actions = vi.hoisted(() => ({ setHistoryPush: vi.fn(), logout: vi.fn() }));
|
|
14
|
+
|
|
15
|
+
vi.mock("@ax/routes", () => ({ publicRoutes: [], privateRoutes: [], routes: [] }));
|
|
16
|
+
vi.mock("@ax/modules/App/Routing/NavMenu", () => ({ default: () => null }));
|
|
17
|
+
vi.mock("@ax/guards", () => ({ ErrorGuard: () => null }));
|
|
18
|
+
vi.mock("@ax/containers/App", async (importOriginal) => {
|
|
19
|
+
const original = await importOriginal<typeof import("@ax/containers/App")>();
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
...original,
|
|
23
|
+
appActions: {
|
|
24
|
+
...original.appActions,
|
|
25
|
+
setHistoryPush: (...args: unknown[]) => {
|
|
26
|
+
actions.setHistoryPush(...args);
|
|
27
|
+
|
|
28
|
+
return { type: "test/setHistoryPush" };
|
|
29
|
+
},
|
|
30
|
+
logout: () => {
|
|
31
|
+
actions.logout();
|
|
32
|
+
|
|
33
|
+
return { type: "test/logout" };
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
beforeEach(() => localStorage.clear());
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
cleanup();
|
|
42
|
+
vi.clearAllMocks();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const renderAt = (path: string) => {
|
|
46
|
+
const store = configureStore([])({
|
|
47
|
+
router: { location: { pathname: path } },
|
|
48
|
+
app: { ...appInitialState, token: "" },
|
|
49
|
+
users: { currentUser: null },
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
render(
|
|
53
|
+
<Provider store={store}>
|
|
54
|
+
<MemoryRouter initialEntries={[path]}>
|
|
55
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
56
|
+
<Routing />
|
|
57
|
+
</ThemeProvider>
|
|
58
|
+
</MemoryRouter>
|
|
59
|
+
</Provider>,
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
describe("[UC-AX-sign-in-out] arranque", () => {
|
|
64
|
+
it("AC3 · con localStorage.user guardado, arrancar en /login redirige a /sites", () => {
|
|
65
|
+
localStorage.setItem("user", JSON.stringify({ token: "jwt" }));
|
|
66
|
+
|
|
67
|
+
renderAt("/login");
|
|
68
|
+
|
|
69
|
+
expect(actions.setHistoryPush).toHaveBeenCalledExactlyOnceWith("/sites", false);
|
|
70
|
+
expect(actions.logout).not.toHaveBeenCalled();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("AC3 (borde) · sin localStorage.user, /login limpia la sesión y no redirige", () => {
|
|
74
|
+
renderAt("/login");
|
|
75
|
+
|
|
76
|
+
expect(actions.logout).toHaveBeenCalledTimes(1);
|
|
77
|
+
expect(actions.setHistoryPush).not.toHaveBeenCalled();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Provider } from "react-redux";
|
|
2
|
+
import { Router } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
5
|
+
import configureStore from "redux-mock-store";
|
|
6
|
+
import { ThemeProvider } from "styled-components";
|
|
7
|
+
import "@testing-library/jest-dom";
|
|
8
|
+
|
|
9
|
+
import { appInitialState } from "@ax/containers/App/reducer";
|
|
10
|
+
import { parseTheme } from "@ax/helpers";
|
|
11
|
+
import LoginModule from "@ax/modules/Login";
|
|
12
|
+
import history from "@ax/routes/history";
|
|
13
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
14
|
+
|
|
15
|
+
vi.mock("@ax/containers/App", async (importOriginal) => ({
|
|
16
|
+
...(await importOriginal<typeof import("@ax/containers/App")>()),
|
|
17
|
+
appActions: {
|
|
18
|
+
...(await importOriginal<typeof import("@ax/containers/App")>()).appActions,
|
|
19
|
+
login: () => ({ type: "test/login" }),
|
|
20
|
+
loginSSO: () => ({ type: "test/loginSSO" }),
|
|
21
|
+
resetError: () => ({ type: "test/resetError" }),
|
|
22
|
+
getGlobalSettings: () => ({ type: "test/getGlobalSettings" }),
|
|
23
|
+
setHistoryPush: () => ({ type: "test/setHistoryPush" }),
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
cleanup();
|
|
29
|
+
vi.unstubAllGlobals();
|
|
30
|
+
vi.unstubAllEnvs();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const renderModule = (globalSettings: Partial<typeof appInitialState.globalSettings>) => {
|
|
34
|
+
const store = configureStore([])({
|
|
35
|
+
app: { isLoggingIn: false, globalSettings: { ...appInitialState.globalSettings, ...globalSettings } },
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
render(
|
|
39
|
+
<Provider store={store}>
|
|
40
|
+
<Router history={history}>
|
|
41
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
42
|
+
<LoginModule />
|
|
43
|
+
</ThemeProvider>
|
|
44
|
+
</Router>
|
|
45
|
+
</Provider>,
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
describe("módulo Login con auth.griddo.io", () => {
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
vi.stubEnv("GRIDDO_API_URL", "https://api.uni.es");
|
|
52
|
+
vi.spyOn(window.navigator, "language", "get").mockReturnValue("en-US");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("«Entrar con Griddo» navega a /sso/start de la API configurada, una sola vez con doble clic", () => {
|
|
56
|
+
const assign = vi.fn();
|
|
57
|
+
|
|
58
|
+
vi.stubGlobal("location", { ...window.location, assign });
|
|
59
|
+
renderModule({ GriddoIdEnabled: true });
|
|
60
|
+
|
|
61
|
+
const button = screen.getByRole("button", { name: "Sign in with Griddo" });
|
|
62
|
+
|
|
63
|
+
fireEvent.click(button);
|
|
64
|
+
fireEvent.click(button);
|
|
65
|
+
|
|
66
|
+
expect(assign).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(assign).toHaveBeenCalledWith("https://api.uni.es/sso/start");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const openForm = () => fireEvent.click(screen.getByRole("button", { name: "Login with email and password" }));
|
|
71
|
+
|
|
72
|
+
const typeEmail = (value: string) => {
|
|
73
|
+
openForm();
|
|
74
|
+
fireEvent.change(screen.getByPlaceholderText("Type your email"), { target: { value } });
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const clickGriddoId = () => {
|
|
78
|
+
const assign = vi.fn();
|
|
79
|
+
|
|
80
|
+
vi.stubGlobal("location", { ...window.location, assign });
|
|
81
|
+
renderModule({ GriddoIdEnabled: true });
|
|
82
|
+
|
|
83
|
+
return { assign, button: screen.getByRole("button", { name: "Sign in with Griddo" }) };
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
it("envía el email escrito como login_hint, recortado y codificado", () => {
|
|
87
|
+
const { assign, button } = clickGriddoId();
|
|
88
|
+
|
|
89
|
+
typeEmail(" ana+x@uni.es ");
|
|
90
|
+
fireEvent.click(button);
|
|
91
|
+
|
|
92
|
+
expect(assign).toHaveBeenCalledWith("https://api.uni.es/sso/start?login_hint=ana%2Bx%40uni.es");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("con el campo vacío o sin arroba navega sin query", () => {
|
|
96
|
+
for (const typed of ["", "ana"]) {
|
|
97
|
+
const { assign, button } = clickGriddoId();
|
|
98
|
+
|
|
99
|
+
typeEmail(typed);
|
|
100
|
+
fireEvent.click(button);
|
|
101
|
+
|
|
102
|
+
expect(assign).toHaveBeenCalledWith("https://api.uni.es/sso/start");
|
|
103
|
+
cleanup();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("la contraseña no viaja en la URL", () => {
|
|
108
|
+
const { assign, button } = clickGriddoId();
|
|
109
|
+
const password = document.querySelector<HTMLInputElement>('input[name="password"]') as HTMLInputElement;
|
|
110
|
+
|
|
111
|
+
typeEmail("ana@uni.es");
|
|
112
|
+
fireEvent.change(password, { target: { value: "s3cr3t-pass" } });
|
|
113
|
+
fireEvent.click(button);
|
|
114
|
+
|
|
115
|
+
const url = assign.mock.calls[0][0] as string;
|
|
116
|
+
|
|
117
|
+
expect(url).toBe("https://api.uni.es/sso/start?login_hint=ana%40uni.es");
|
|
118
|
+
expect(url).not.toContain("s3cr3t");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("con email escrito, un doble clic navega una sola vez", () => {
|
|
122
|
+
const { assign, button } = clickGriddoId();
|
|
123
|
+
|
|
124
|
+
typeEmail("ana@uni.es");
|
|
125
|
+
fireEvent.click(button);
|
|
126
|
+
fireEvent.click(button);
|
|
127
|
+
|
|
128
|
+
expect(assign).toHaveBeenCalledTimes(1);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("sin GRIDDO_API_URL el destino cuelga de REACT_APP_API_ENDPOINT", () => {
|
|
132
|
+
vi.stubEnv("GRIDDO_API_URL", "");
|
|
133
|
+
vi.stubEnv("REACT_APP_API_ENDPOINT", "https://fallback.uni.es");
|
|
134
|
+
const { assign, button } = clickGriddoId();
|
|
135
|
+
|
|
136
|
+
typeEmail("ana@uni.es");
|
|
137
|
+
fireEvent.click(button);
|
|
138
|
+
|
|
139
|
+
expect(assign).toHaveBeenCalledWith("https://fallback.uni.es/sso/start?login_hint=ana%40uni.es");
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("con el flag activo el formulario está plegado bajo el botón hasta pulsar el desplegable", () => {
|
|
143
|
+
renderModule({ GriddoIdEnabled: true });
|
|
144
|
+
|
|
145
|
+
expect(screen.getByPlaceholderText("Type your email")).not.toBeVisible();
|
|
146
|
+
openForm();
|
|
147
|
+
expect(screen.getByPlaceholderText("Type your email")).toBeVisible();
|
|
148
|
+
expect(screen.getByRole("button", { name: "Sign in with Griddo" })).toBeInTheDocument();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("con el flag activo muestra el logo «griddo dxp» arriba a la izquierda", () => {
|
|
152
|
+
renderModule({ GriddoIdEnabled: true });
|
|
153
|
+
|
|
154
|
+
expect(screen.getByAltText("Griddo DXP")).toHaveAttribute("src", "/img/logos/logoGriddoDxp.svg");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("con el flag apagado no muestra el logo «griddo dxp»: ese login ya lleva su «Welcome to»", () => {
|
|
158
|
+
renderModule({ GriddoIdEnabled: false });
|
|
159
|
+
|
|
160
|
+
expect(screen.queryByAltText("Griddo DXP")).toBeNull();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("con el flag apagado (o sin settings) muestra el formulario de siempre", () => {
|
|
164
|
+
renderModule({ GriddoIdEnabled: false });
|
|
165
|
+
|
|
166
|
+
expect(screen.queryByText("Sign in with Griddo")).toBeNull();
|
|
167
|
+
expect(screen.getByPlaceholderText("Type your email")).toBeInTheDocument();
|
|
168
|
+
});
|
|
169
|
+
});
|