@griddo/ax 12.15.1-astro-rc.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/__tests__/getCSSModuleLocalIdent.test.js +30 -0
- package/config/griddo-config/index.js +3 -2
- package/config/webpack/getCSSModuleLocalIdent.js +10 -0
- package/config/webpack.config.js +1 -1
- package/package.json +8 -6
- 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/Fields/TranslateButton/TranslateButton.test.tsx +121 -4
- 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/components/Fields/TranslateButton/index.tsx +4 -9
- 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,145 @@
|
|
|
1
|
+
import { MemoryRouter } from "react-router-dom";
|
|
2
|
+
|
|
3
|
+
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
+
import { ThemeProvider } from "styled-components";
|
|
5
|
+
import "@testing-library/jest-dom";
|
|
6
|
+
|
|
7
|
+
import ErrorPage from "@ax/components/ErrorPage";
|
|
8
|
+
import Login, { type ILoginProps } from "@ax/components/Login";
|
|
9
|
+
import SsoDenied from "@ax/components/SsoDenied";
|
|
10
|
+
import { parseTheme } from "@ax/helpers";
|
|
11
|
+
import { BRAND_PALETTE } from "@ax/themes/brandPalette";
|
|
12
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
13
|
+
|
|
14
|
+
afterEach(cleanup);
|
|
15
|
+
|
|
16
|
+
const settings = {
|
|
17
|
+
cloudinaryName: "cloudinary",
|
|
18
|
+
globalLogoBig: "https://images.dev.griddo.io/big",
|
|
19
|
+
globalLogoMini: "https://images.dev.griddo.io/mini",
|
|
20
|
+
siteLogoBig: "https://images.dev.griddo.io/sbig",
|
|
21
|
+
siteLogoMini: "https://images.dev.griddo.io/smini",
|
|
22
|
+
welcomeText1: "Welcome back to",
|
|
23
|
+
welcomeText2: "Griddo",
|
|
24
|
+
autoSummary: false,
|
|
25
|
+
autoTranslation: false,
|
|
26
|
+
SSOActivated: false,
|
|
27
|
+
GriddoIdEnabled: false,
|
|
28
|
+
SSOWelcomeText: "",
|
|
29
|
+
useForms: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const loginProps = (overrides: Partial<ILoginProps["settings"]> = {}): ILoginProps => ({
|
|
33
|
+
handleSubmit: vi.fn((e) => e.preventDefault()),
|
|
34
|
+
email: "",
|
|
35
|
+
handleEmail: vi.fn(),
|
|
36
|
+
password: "",
|
|
37
|
+
handlePassword: vi.fn(),
|
|
38
|
+
isLoggingIn: false,
|
|
39
|
+
settings: { ...settings, ...overrides },
|
|
40
|
+
rememberMe: false,
|
|
41
|
+
handleRememberMe: vi.fn(),
|
|
42
|
+
handleGriddoId: vi.fn(),
|
|
43
|
+
isLoginSuccess: false,
|
|
44
|
+
handleLoginSuccess: vi.fn(),
|
|
45
|
+
handleSSO: vi.fn(),
|
|
46
|
+
errorSSO: "",
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const theme = parseTheme(globalTheme);
|
|
50
|
+
|
|
51
|
+
const renderLogin = (overrides: Partial<ILoginProps["settings"]> = {}) =>
|
|
52
|
+
render(
|
|
53
|
+
<ThemeProvider theme={theme}>
|
|
54
|
+
<Login {...loginProps(overrides)} />
|
|
55
|
+
</ThemeProvider>,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const circles = () => screen.getAllByTestId("circle");
|
|
59
|
+
|
|
60
|
+
describe("[UC-AX-sign-in-out] paleta de marca: constantes", () => {
|
|
61
|
+
it("AC13 · expone los tonos de marca", () => {
|
|
62
|
+
expect(BRAND_PALETTE.navy).toBe("#001B3C");
|
|
63
|
+
expect(BRAND_PALETTE.navyControl).toBe("#022958");
|
|
64
|
+
expect(BRAND_PALETTE.cyan).toBe("#3CC3DD");
|
|
65
|
+
expect(BRAND_PALETTE.purple).toBe("#A950CF");
|
|
66
|
+
expect(BRAND_PALETTE.turquoise).toBe("#40E0D0");
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe("[UC-AX-sign-in-out] Login: paleta de marca", () => {
|
|
71
|
+
it("AC13 · columna izquierda con el azul de marca", () => {
|
|
72
|
+
renderLogin();
|
|
73
|
+
expect(screen.getByTestId("login-left")).toHaveStyle({ background: "#001B3C" });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("AC13 · blur cyan en lugar del amarillo, con blur 50px (el 100 de Figma) y opacidad .5", () => {
|
|
77
|
+
const { container } = renderLogin();
|
|
78
|
+
const backgrounds = circles().map((c) => getComputedStyle(c).backgroundColor);
|
|
79
|
+
expect(backgrounds).toContain("rgb(60, 195, 221)");
|
|
80
|
+
expect(container.innerHTML).not.toMatch(/FBE15C/i);
|
|
81
|
+
for (const c of circles()) {
|
|
82
|
+
expect(c).toHaveStyle({ filter: "blur(50px)", opacity: "0.5" });
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("AC13 · el halo de marca es turquesa, queda por debajo del contenido y no captura clics", () => {
|
|
87
|
+
renderLogin({ GriddoIdEnabled: true });
|
|
88
|
+
const halo = screen.getByTestId("login-halo");
|
|
89
|
+
expect(halo).toHaveStyle({ pointerEvents: "none", zIndex: "0", backgroundColor: "#40E0D0" });
|
|
90
|
+
expect(halo.parentElement).toBe(screen.getByTestId("login-left"));
|
|
91
|
+
expect(screen.getByTestId("login-left")).toHaveStyle({ overflow: "hidden" });
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("AC13 · el clic llega al botón SSO pese al halo", () => {
|
|
95
|
+
const props = loginProps({ GriddoIdEnabled: true });
|
|
96
|
+
render(
|
|
97
|
+
<ThemeProvider theme={theme}>
|
|
98
|
+
<Login {...props} />
|
|
99
|
+
</ThemeProvider>,
|
|
100
|
+
);
|
|
101
|
+
fireEvent.click(screen.getByRole("button", { name: /sign in with griddo/i }));
|
|
102
|
+
expect(props.handleGriddoId).toHaveBeenCalledTimes(1);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it.each([
|
|
106
|
+
["Griddo ID", { GriddoIdEnabled: true }],
|
|
107
|
+
["normal", {}],
|
|
108
|
+
["Comillas", { SSOActivated: true }],
|
|
109
|
+
])("AC13 · variante %s usa la paleta", (_n, overrides) => {
|
|
110
|
+
renderLogin(overrides);
|
|
111
|
+
expect(screen.getByTestId("login-left")).toHaveStyle({ background: "#001B3C" });
|
|
112
|
+
expect(circles().map((c) => getComputedStyle(c).backgroundColor)).toContain("rgb(60, 195, 221)");
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("AC13 · el halo y el logo no quedan huérfanos en la animación de éxito: viven dentro de la columna que se expande", () => {
|
|
116
|
+
renderLogin({ GriddoIdEnabled: true });
|
|
117
|
+
const left = screen.getByTestId("login-left");
|
|
118
|
+
expect(left).toContainElement(screen.getByTestId("login-halo"));
|
|
119
|
+
expect(left).toContainElement(screen.getByAltText("Griddo DXP"));
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe("[UC-AX-sign-in-out] pantallas que comparten estilos", () => {
|
|
124
|
+
it("AC13 · SsoDenied usa el fondo y el círculo de marca", () => {
|
|
125
|
+
render(
|
|
126
|
+
<ThemeProvider theme={theme}>
|
|
127
|
+
<SsoDenied switchAccountUrl="https://api/sso/switch-account" />
|
|
128
|
+
</ThemeProvider>,
|
|
129
|
+
);
|
|
130
|
+
expect(screen.getByTestId("sso-denied-wrapper").firstElementChild).toHaveStyle({ background: "#001B3C" });
|
|
131
|
+
expect(circles().map((c) => getComputedStyle(c).backgroundColor)).toContain("rgb(60, 195, 221)");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("AC13 · ErrorPage saca su fondo de la constante compartida y usa el círculo de marca", () => {
|
|
135
|
+
render(
|
|
136
|
+
<ThemeProvider theme={theme}>
|
|
137
|
+
<MemoryRouter>
|
|
138
|
+
<ErrorPage type="404" />
|
|
139
|
+
</MemoryRouter>
|
|
140
|
+
</ThemeProvider>,
|
|
141
|
+
);
|
|
142
|
+
expect(screen.getByTestId("error-page-wrapper")).toHaveStyle({ backgroundColor: BRAND_PALETTE.navy });
|
|
143
|
+
expect(circles().map((c) => getComputedStyle(c).backgroundColor)).toContain("rgb(60, 195, 221)");
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
2
2
|
import { ThemeProvider } from "styled-components";
|
|
3
|
-
import { render, cleanup, screen, fireEvent } from "@testing-library/react";
|
|
4
3
|
import "@testing-library/jest-dom";
|
|
5
4
|
|
|
6
|
-
import { parseTheme } from "@ax/helpers";
|
|
7
5
|
import Login, { type ILoginProps } from "@ax/components/Login";
|
|
6
|
+
import { parseTheme } from "@ax/helpers";
|
|
8
7
|
import globalTheme from "@ax/themes/theme.json";
|
|
9
8
|
|
|
10
9
|
afterEach(cleanup);
|
|
@@ -180,36 +179,6 @@ describe("Login component events", () => {
|
|
|
180
179
|
fireEvent.click(input);
|
|
181
180
|
expect(handleRememberMeMock).toBeCalledTimes(1);
|
|
182
181
|
});
|
|
183
|
-
|
|
184
|
-
it("should change input type on button click", () => {
|
|
185
|
-
const defaultProps: ILoginProps = {
|
|
186
|
-
handleSubmit: vi.fn((e) => e.preventDefault()),
|
|
187
|
-
email: "hola@secuoyas.com",
|
|
188
|
-
handleEmail: vi.fn(),
|
|
189
|
-
password: "",
|
|
190
|
-
handlePassword: vi.fn(),
|
|
191
|
-
isLoggingIn: false,
|
|
192
|
-
settings,
|
|
193
|
-
rememberMe: false,
|
|
194
|
-
handleRememberMe: vi.fn(),
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
render(
|
|
198
|
-
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
199
|
-
<Login {...defaultProps} />
|
|
200
|
-
</ThemeProvider>,
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
const input = screen.getByLabelText("password");
|
|
204
|
-
expect(input).toBeTruthy();
|
|
205
|
-
expect(input).toHaveAttribute("type", "password");
|
|
206
|
-
|
|
207
|
-
const button = screen.getByTestId("icon-component-view");
|
|
208
|
-
expect(button).toBeTruthy();
|
|
209
|
-
fireEvent.click(button);
|
|
210
|
-
|
|
211
|
-
expect(input).toHaveAttribute("type", "text");
|
|
212
|
-
});
|
|
213
182
|
});
|
|
214
183
|
|
|
215
184
|
describe("Recovery Modal rendering", () => {
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { act, cleanup, fireEvent, render, screen } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { ThemeProvider } from "styled-components";
|
|
4
|
+
import "@testing-library/jest-dom";
|
|
5
|
+
|
|
6
|
+
import Login, { type ILoginProps } from "@ax/components/Login";
|
|
7
|
+
import { parseTheme } from "@ax/helpers";
|
|
8
|
+
import globalTheme from "@ax/themes/theme.json";
|
|
9
|
+
|
|
10
|
+
afterEach(cleanup);
|
|
11
|
+
|
|
12
|
+
const baseSettings = {
|
|
13
|
+
cloudinaryName: "cloudinary",
|
|
14
|
+
globalLogoBig: "",
|
|
15
|
+
globalLogoMini: "",
|
|
16
|
+
siteLogoBig: "",
|
|
17
|
+
siteLogoMini: "",
|
|
18
|
+
welcomeText1: "Welcome back to",
|
|
19
|
+
welcomeText2: "Griddo",
|
|
20
|
+
autoSummary: false,
|
|
21
|
+
autoTranslation: false,
|
|
22
|
+
SSOActivated: false,
|
|
23
|
+
GriddoIdEnabled: true,
|
|
24
|
+
SSOWelcomeText: "",
|
|
25
|
+
useForms: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const element = (
|
|
29
|
+
settings: Partial<typeof baseSettings>,
|
|
30
|
+
props: Partial<ILoginProps>,
|
|
31
|
+
handlers: Pick<ILoginProps, "handleSubmit" | "handleSSO" | "handleGriddoId">,
|
|
32
|
+
) => (
|
|
33
|
+
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
34
|
+
<Login
|
|
35
|
+
email=""
|
|
36
|
+
handleEmail={vi.fn()}
|
|
37
|
+
password=""
|
|
38
|
+
handlePassword={vi.fn()}
|
|
39
|
+
isLoggingIn={false}
|
|
40
|
+
rememberMe={false}
|
|
41
|
+
handleRememberMe={vi.fn()}
|
|
42
|
+
isLoginSuccess={false}
|
|
43
|
+
handleLoginSuccess={vi.fn()}
|
|
44
|
+
errorSSO={null}
|
|
45
|
+
{...handlers}
|
|
46
|
+
{...props}
|
|
47
|
+
settings={{ ...baseSettings, ...settings } as ILoginProps["settings"]}
|
|
48
|
+
/>
|
|
49
|
+
</ThemeProvider>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const renderLogin = (settings: Partial<typeof baseSettings> = {}, props: Partial<ILoginProps> = {}) => {
|
|
53
|
+
const handlers = {
|
|
54
|
+
handleSubmit: vi.fn((e: React.FormEvent) => e.preventDefault()),
|
|
55
|
+
handleSSO: vi.fn(),
|
|
56
|
+
handleGriddoId: vi.fn(),
|
|
57
|
+
};
|
|
58
|
+
const view = render(element(settings, props, handlers));
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
...handlers,
|
|
62
|
+
...view,
|
|
63
|
+
rerenderWith: (next: Partial<typeof baseSettings>) => view.rerender(element(next, props, handlers)),
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const TOGGLE = "Login with email and password";
|
|
68
|
+
const toggle = () => screen.getByRole("button", { name: TOGGLE });
|
|
69
|
+
const email = () => screen.getByPlaceholderText("Type your email");
|
|
70
|
+
|
|
71
|
+
describe("[UC-AX-sign-in-out] formulario plegable con Griddo ID", () => {
|
|
72
|
+
beforeEach(() => vi.spyOn(window.navigator, "language", "get").mockReturnValue("en-US"));
|
|
73
|
+
|
|
74
|
+
it("AC7 · plegado por defecto: SSO y desplegable visibles; email, contraseña y «Remember me» ocultos", () => {
|
|
75
|
+
renderLogin();
|
|
76
|
+
|
|
77
|
+
expect(screen.getByRole("button", { name: "Sign in with Griddo" })).toBeVisible();
|
|
78
|
+
expect(toggle()).toBeVisible();
|
|
79
|
+
expect(toggle()).toHaveAttribute("aria-expanded", "false");
|
|
80
|
+
expect(email()).not.toBeVisible();
|
|
81
|
+
expect(document.querySelector('input[name="password"]')).not.toBeVisible();
|
|
82
|
+
expect(screen.getByText("Remember me")).not.toBeVisible();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("AC7 · al montar el foco no está en el email", () => {
|
|
86
|
+
renderLogin();
|
|
87
|
+
|
|
88
|
+
expect(email()).not.toHaveFocus();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("AC7 · relación ARIA: aria-controls apunta al contenedor y el desplegable no es un separator", () => {
|
|
92
|
+
renderLogin();
|
|
93
|
+
const id = toggle().getAttribute("aria-controls") as string;
|
|
94
|
+
|
|
95
|
+
expect(id).toBeTruthy();
|
|
96
|
+
expect(document.getElementById(id)).toContainElement(email());
|
|
97
|
+
expect(toggle()).not.toHaveAttribute("role", "separator");
|
|
98
|
+
expect(screen.queryByRole("separator")).toBeNull();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("AC7 · settings que llegan tarde: queda plegado y sin foco en el email", () => {
|
|
102
|
+
const { rerenderWith } = renderLogin({ GriddoIdEnabled: false });
|
|
103
|
+
|
|
104
|
+
rerenderWith({ GriddoIdEnabled: true });
|
|
105
|
+
|
|
106
|
+
expect(toggle()).toHaveAttribute("aria-expanded", "false");
|
|
107
|
+
expect(email()).not.toBeVisible();
|
|
108
|
+
expect(email()).not.toHaveFocus();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("AC8 · desplegar muestra el formulario, aria-expanded=true y enfoca el email", async () => {
|
|
112
|
+
renderLogin();
|
|
113
|
+
|
|
114
|
+
await userEvent.click(toggle());
|
|
115
|
+
|
|
116
|
+
expect(toggle()).toHaveAttribute("aria-expanded", "true");
|
|
117
|
+
expect(email()).toBeVisible();
|
|
118
|
+
expect(email()).toHaveFocus();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("AC8 · plegar de nuevo oculta el formulario, conserva lo escrito y deja el foco en el botón", async () => {
|
|
122
|
+
renderLogin({}, { email: "ana@uni.es", password: "s3cr3t" });
|
|
123
|
+
|
|
124
|
+
await userEvent.click(toggle());
|
|
125
|
+
await userEvent.click(toggle());
|
|
126
|
+
|
|
127
|
+
expect(email()).not.toBeVisible();
|
|
128
|
+
expect(toggle()).toHaveFocus();
|
|
129
|
+
|
|
130
|
+
await userEvent.click(toggle());
|
|
131
|
+
|
|
132
|
+
expect(email()).toHaveValue("ana@uni.es");
|
|
133
|
+
expect(document.querySelector('input[name="password"]')).toHaveValue("s3cr3t");
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("AC8 · re-desplegar vuelve a enfocar el email", async () => {
|
|
137
|
+
renderLogin();
|
|
138
|
+
|
|
139
|
+
await userEvent.click(toggle());
|
|
140
|
+
await userEvent.click(toggle());
|
|
141
|
+
expect(email()).not.toHaveFocus();
|
|
142
|
+
await userEvent.click(toggle());
|
|
143
|
+
|
|
144
|
+
expect(email()).toHaveFocus();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("AC8 · dos pulsaciones seguidas dejan el formulario plegado y sin foco en el email", () => {
|
|
148
|
+
renderLogin();
|
|
149
|
+
|
|
150
|
+
fireEvent.click(toggle());
|
|
151
|
+
fireEvent.click(toggle());
|
|
152
|
+
|
|
153
|
+
expect(toggle()).toHaveAttribute("aria-expanded", "false");
|
|
154
|
+
expect(email()).not.toBeVisible();
|
|
155
|
+
expect(email()).not.toHaveFocus();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it.each([
|
|
159
|
+
["Enter", "{Enter}"],
|
|
160
|
+
["Espacio", " "],
|
|
161
|
+
])("AC8 · con teclado (%s) alterna exactamente una vez", async (_name, key) => {
|
|
162
|
+
renderLogin();
|
|
163
|
+
toggle().focus();
|
|
164
|
+
|
|
165
|
+
await userEvent.keyboard(key);
|
|
166
|
+
|
|
167
|
+
expect(toggle()).toHaveAttribute("aria-expanded", "true");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("AC8 · desde el formulario desplegado se puede iniciar sesión", async () => {
|
|
171
|
+
const { handleSubmit } = renderLogin();
|
|
172
|
+
|
|
173
|
+
await userEvent.click(toggle());
|
|
174
|
+
await userEvent.click(screen.getByText("Login"));
|
|
175
|
+
|
|
176
|
+
expect(handleSubmit).toHaveBeenCalledTimes(1);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("AC8 · «Sign in with Griddo» funciona con el formulario plegado", async () => {
|
|
180
|
+
const { handleGriddoId } = renderLogin();
|
|
181
|
+
|
|
182
|
+
await userEvent.click(screen.getByRole("button", { name: "Sign in with Griddo" }));
|
|
183
|
+
|
|
184
|
+
expect(handleGriddoId).toHaveBeenCalledTimes(1);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("AC9 · con el formulario plegado «Lost your password?» del toast abre el modal de recuperación", () => {
|
|
188
|
+
renderLogin();
|
|
189
|
+
|
|
190
|
+
expect(screen.queryByTestId("recovery-modal-content")).toBeNull();
|
|
191
|
+
|
|
192
|
+
act(() => window.handleErrorClick?.());
|
|
193
|
+
|
|
194
|
+
expect(screen.getByTestId("recovery-modal-content")).toBeInTheDocument();
|
|
195
|
+
expect(toggle()).toHaveAttribute("aria-expanded", "false");
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("AC9 · con el formulario plegado el ErrorToast y el errorSSO siguen visibles", () => {
|
|
199
|
+
renderLogin({}, { errorSSO: "Error de SSO" });
|
|
200
|
+
|
|
201
|
+
expect(screen.getByTestId("error-wrapper")).toBeVisible();
|
|
202
|
+
expect(screen.getByText("Error de SSO")).toBeVisible();
|
|
203
|
+
expect(toggle()).toHaveAttribute("aria-expanded", "false");
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("AC10 · sin GriddoIdEnabled: formulario visible y sin desplegable", () => {
|
|
207
|
+
renderLogin({ GriddoIdEnabled: false });
|
|
208
|
+
|
|
209
|
+
expect(email()).toBeVisible();
|
|
210
|
+
expect(screen.queryByRole("button", { name: TOGGLE })).toBeNull();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("AC10 · con SSOActivated (Comillas) la pantalla no lleva desplegable ni formulario", () => {
|
|
214
|
+
renderLogin({ SSOActivated: true });
|
|
215
|
+
|
|
216
|
+
expect(screen.queryByRole("button", { name: TOGGLE })).toBeNull();
|
|
217
|
+
expect(screen.queryByPlaceholderText("Type your email")).toBeNull();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("AC12 · al volver con Atrás (página restaurada de la caché) el botón vuelve a navegar", () => {
|
|
221
|
+
const { handleGriddoId } = renderLogin({ GriddoIdEnabled: true });
|
|
222
|
+
const button = screen.getByRole("button", { name: "Sign in with Griddo" });
|
|
223
|
+
|
|
224
|
+
fireEvent.click(button);
|
|
225
|
+
fireEvent.click(button);
|
|
226
|
+
expect(handleGriddoId).toHaveBeenCalledTimes(1);
|
|
227
|
+
|
|
228
|
+
const restored = new Event("pageshow");
|
|
229
|
+
|
|
230
|
+
Object.defineProperty(restored, "persisted", { value: true });
|
|
231
|
+
act(() => {
|
|
232
|
+
window.dispatchEvent(restored);
|
|
233
|
+
});
|
|
234
|
+
fireEvent.click(button);
|
|
235
|
+
|
|
236
|
+
expect(handleGriddoId).toHaveBeenCalledTimes(2);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("AC12 · un pageshow de una carga normal no reabre el botón", () => {
|
|
240
|
+
const { handleGriddoId } = renderLogin({ GriddoIdEnabled: true });
|
|
241
|
+
const button = screen.getByRole("button", { name: "Sign in with Griddo" });
|
|
242
|
+
|
|
243
|
+
fireEvent.click(button);
|
|
244
|
+
act(() => {
|
|
245
|
+
window.dispatchEvent(new Event("pageshow"));
|
|
246
|
+
});
|
|
247
|
+
fireEvent.click(button);
|
|
248
|
+
|
|
249
|
+
expect(handleGriddoId).toHaveBeenCalledTimes(1);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it.each([
|
|
253
|
+
["en-US", "Login"],
|
|
254
|
+
["es-ES", "Login"],
|
|
255
|
+
])("AC11 · idioma %s: texto del botón de envío", (language, submit) => {
|
|
256
|
+
vi.spyOn(window.navigator, "language", "get").mockReturnValue(language);
|
|
257
|
+
renderLogin({ GriddoIdEnabled: false });
|
|
258
|
+
|
|
259
|
+
expect(screen.getByRole("button", { name: submit })).toBeInTheDocument();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it.each([
|
|
263
|
+
["en-US", TOGGLE],
|
|
264
|
+
["es-ES", "Login with email and password"],
|
|
265
|
+
])("AC11 · idioma %s: texto del desplegable", (language, toggleText) => {
|
|
266
|
+
vi.spyOn(window.navigator, "language", "get").mockReturnValue(language);
|
|
267
|
+
renderLogin();
|
|
268
|
+
|
|
269
|
+
expect(screen.getByRole("button", { name: toggleText })).toBeInTheDocument();
|
|
270
|
+
});
|
|
271
|
+
});
|