@griddo/ax 12.10.3 → 12.10.5-rc.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "12.10.3",
4
+ "version": "12.10.5-rc.0",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -201,5 +201,5 @@
201
201
  "publishConfig": {
202
202
  "access": "public"
203
203
  },
204
- "gitHead": "2d015ededd3170ca82057b809faaafc6b91c80ff"
204
+ "gitHead": "1b249444fef8e63a26ee518b8d49c2939b2d3992"
205
205
  }
@@ -87,6 +87,23 @@ describe("ConditionalField component rendering", () => {
87
87
  });
88
88
  });
89
89
 
90
+ describe("ConditionalField spacing", () => {
91
+ it("should reset the bottom margin of its direct child only", () => {
92
+ render(
93
+ <ThemeProvider theme={parseTheme(globalTheme)}>
94
+ <ConditionalField {...defaultProps} />
95
+ </ThemeProvider>,
96
+ );
97
+
98
+ const conditionalFieldContent = screen.getByTestId("conditionalFieldContent");
99
+
100
+ expect(conditionalFieldContent).toHaveStyleRule("margin-bottom", "0", { modifier: "> div:last-child" });
101
+ // A descendant selector would also reach every nested field and "Add" button,
102
+ // flattening the spacing of nested ArrayFieldGroups (sc-110266).
103
+ expect(conditionalFieldContent).not.toHaveStyleRule("margin-bottom", "0", { modifier: "div:last-child" });
104
+ });
105
+ });
106
+
90
107
  interface IConditionalFieldProps {
91
108
  value: string | boolean;
92
109
  options: any[];
@@ -0,0 +1,110 @@
1
+ import { parseTheme } from "@ax/helpers";
2
+ import PageImporter from "@ax/modules/Content/NewContentModal/PageImporter";
3
+ import globalTheme from "@ax/themes/theme.json";
4
+
5
+ import configureStore from "redux-mock-store";
6
+ import thunk from "redux-thunk";
7
+ import { ThemeProvider } from "styled-components";
8
+
9
+ import { act, cleanup, fireEvent, render, screen } from "./../../../../../config/tests/test-utils";
10
+
11
+ const getGlobalPagesLight = vi.fn();
12
+
13
+ vi.mock("@ax/api", async (importOriginal) => {
14
+ const actual = (await importOriginal()) as any;
15
+
16
+ return {
17
+ ...actual,
18
+ sites: {
19
+ ...actual.sites,
20
+ getGlobalPagesLight: (...args: any[]) => getGlobalPagesLight(...args),
21
+ },
22
+ };
23
+ });
24
+
25
+ afterEach(cleanup);
26
+
27
+ const buildPage = (id: number) => ({
28
+ id,
29
+ title: `insti news ${id}`,
30
+ slug: `/insti-news-${id}`,
31
+ modified: "2026-09-22T10:00:00.000Z",
32
+ });
33
+
34
+ const setPagesToImport = vi.fn();
35
+
36
+ const renderImporter = async () => {
37
+ const store = configureStore([thunk])({
38
+ app: { lang: { id: 4, locale: "en_GB" } },
39
+ sites: { currentSiteInfo: { id: 1 } },
40
+ });
41
+
42
+ await act(async () => {
43
+ render(
44
+ <ThemeProvider theme={parseTheme(globalTheme)}>
45
+ <PageImporter
46
+ structuredDataID="INS_NEWS"
47
+ title="Get Institutional News from Global"
48
+ setPagesToImport={setPagesToImport}
49
+ toggleImporter={vi.fn()}
50
+ importPage={vi.fn()}
51
+ />
52
+ </ThemeProvider>,
53
+ { store },
54
+ );
55
+ });
56
+ };
57
+
58
+ const search = async (query: string) => {
59
+ const input = screen.getByTestId("search-input");
60
+ await act(async () => {
61
+ fireEvent.change(input, { target: { value: query } });
62
+ });
63
+ await act(async () => {
64
+ fireEvent.keyDown(input, { key: "Enter" });
65
+ });
66
+ };
67
+
68
+ const selectPage = async (pageId: number) => {
69
+ const checkbox = screen
70
+ .getAllByTestId("check-field-input")
71
+ .find((input) => input.getAttribute("value") === String(pageId)) as HTMLElement;
72
+
73
+ await act(async () => {
74
+ fireEvent.click(checkbox);
75
+ });
76
+ };
77
+
78
+ const addPagesButton = () => screen.getByTestId("button-default");
79
+
80
+ describe("[UC-AX-explore-manage-pages] PageImporter — importar páginas globales", () => {
81
+ beforeEach(() => {
82
+ // El listado inicial trae una primera tanda; la búsqueda devuelve una página
83
+ // que no venía en ella, que es justo lo que hace el backend al filtrar por query.
84
+ getGlobalPagesLight.mockImplementation(async ({ query }: { query: string }) => ({
85
+ status: 200,
86
+ data: { items: query ? [buildPage(3)] : [buildPage(1), buildPage(2)] },
87
+ }));
88
+ });
89
+
90
+ it("habilita 'Add pages' con una página de la primera tanda", async () => {
91
+ await renderImporter();
92
+
93
+ await selectPage(1);
94
+
95
+ expect(addPagesButton()).not.toBeDisabled();
96
+ });
97
+
98
+ it("habilita 'Add pages' con una página que solo aparece al buscar", async () => {
99
+ await renderImporter();
100
+
101
+ await search("insti news 3");
102
+ await selectPage(3);
103
+
104
+ expect(addPagesButton()).not.toBeDisabled();
105
+ // Y la columna de la derecha la lista, en vez de seguir pidiendo una selección.
106
+ expect(screen.queryByText(/You have to select at least one page/)).not.toBeInTheDocument();
107
+ // El conjunto que se importa es el seleccionado, no el de la primera tanda.
108
+ expect(setPagesToImport).toHaveBeenLastCalledWith([3]);
109
+ });
110
+ });
@@ -7,7 +7,7 @@ export const Wrapper = styled.div`
7
7
  export const Content = styled.div`
8
8
  transition: all 0.5s ease-in-out;
9
9
  margin-top: ${(p) => p.theme.spacing.m};
10
- div:last-child {
10
+ > div:last-child {
11
11
  margin-bottom: 0;
12
12
  }
13
13
  `;
@@ -48,7 +48,14 @@ const PageImporter = (props: IPageImporterProps) => {
48
48
  data: { items },
49
49
  } = response;
50
50
  setPages(items);
51
- if (!allPages) setAllPages(items);
51
+ // `allPages` acumula todo lo que se ha listado, no solo la primera tanda: la
52
+ // columna de seleccionadas y el botón "Add pages" tienen que poder resolver
53
+ // una página que apareció por primera vez en una búsqueda posterior.
54
+ setAllPages((prevPages) => {
55
+ const knownPages = prevPages ?? [];
56
+ const newPages = items.filter((item: IPage) => !knownPages.some((page) => page.id === item.id));
57
+ return newPages.length ? [...knownPages, ...newPages] : knownPages;
58
+ });
52
59
  }
53
60
  setIsLoading(false);
54
61
  } catch (error) {