Skip to content

Commit

Permalink
Introduced Instance's fieldPathWithIndex in post-message payloads and…
Browse files Browse the repository at this point in the history
… fixed tests
  • Loading branch information
csAyushDubey committed Apr 26, 2024
1 parent 7493574 commit 559aba6
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/cslp/__test__/cslpdata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ describe("extractDetailsFromCslp", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "field1.field2.0.field3",
}
};
expect(extractDetailsFromCslp(cslpValue)).toEqual(expected);
});
Expand All @@ -38,6 +41,9 @@ describe("extractDetailsFromCslp", () => {
parentDetails: null,
index: -1,
},
instance: {
fieldPathWithIndex: "field1.field2.field3",
}
};
expect(extractDetailsFromCslp(cslpValue)).toEqual(expected);
});
Expand All @@ -58,6 +64,9 @@ describe("extractDetailsFromCslp", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "field.0",
}
};
expect(extractDetailsFromCslp(cslpValue)).toEqual(expected);
});
Expand All @@ -81,6 +90,9 @@ describe("extractDetailsFromCslp", () => {
},
index: 3,
},
instance: {
fieldPathWithIndex: "field1.0.field3.field4.3",
}
};
expect(extractDetailsFromCslp(cslpValue)).toEqual(expected);
});
Expand Down
5 changes: 4 additions & 1 deletion src/cslp/cslpdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { DeepSignal } from "deepsignal";
export function extractDetailsFromCslp(cslpValue: string): CslpData {
const [content_type_uid, entry_uid, locale, ...fieldPath] =
cslpValue.split(".");

const instancePathWithInstance = fieldPath.join(".");
const calculatedPath = fieldPath.filter((path) => {
const isEmpty = isNil(path);
const isNumber = isFinite(+path);
Expand Down Expand Up @@ -47,6 +47,9 @@ export function extractDetailsFromCslp(cslpValue: string): CslpData {
fieldPath: calculatedPath.join("."),
fieldPathWithIndex: fieldPath.join("."),
multipleFieldMetadata: multipleFieldMetadata,
instance: {
fieldPathWithIndex: instancePathWithInstance
},
};
}

Expand Down
3 changes: 3 additions & 0 deletions src/cslp/types/cslp.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export interface CslpData {
*/
fieldPathWithIndex: string;
multipleFieldMetadata: CslpDataMultipleFieldMetadata;
instance: {
fieldPathWithIndex: string;
}
}

export interface CslpDataMultipleFieldMetadata {
Expand Down
12 changes: 12 additions & 0 deletions src/liveEditor/__test__/visualEditorClick.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ describe("When an element is clicked in visual editor mode", () => {
parentDetails: null,
index: -1,
},
instance: {
fieldPathWithIndex: "rich_text_editor",
},
},
cslpData: "all_fields.bltapikey.en-us.rich_text_editor",
}
Expand Down Expand Up @@ -1191,6 +1194,9 @@ describe("When an element is clicked in visual editor mode", () => {
parentDetails: null,
index: -1,
},
instance: {
fieldPathWithIndex: "markdown",
},
},
cslpData: "all_fields.bltapikey.en-us.markdown",
}
Expand Down Expand Up @@ -2461,6 +2467,9 @@ describe("When an element is clicked in visual editor mode", () => {
parentDetails: null,
index: -1,
},
instance: {
fieldPathWithIndex: "link.href",
}
},
cslpData: "all_fields.bltapikey.en-us.link.href",
}
Expand Down Expand Up @@ -2990,6 +2999,9 @@ describe("When an element is clicked in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "group_multiple_.0",
}
},
cslpData: "all_fields.bltapikey.en-us.group_multiple_.0",
}
Expand Down
67 changes: 67 additions & 0 deletions src/liveEditor/__test__/visualEditorHover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ describe("When an element is hovered in visual editor mode", () => {
parentPath: "single_line_textbox_multiple_",
},
},
instance: {
fieldPathWithIndex: "single_line_textbox_multiple_.0",
},
}
},
index: 0,
}
Expand All @@ -409,6 +413,9 @@ describe("When an element is hovered in visual editor mode", () => {
parentPath: "single_line_textbox_multiple_",
},
},
instance: {
fieldPathWithIndex: "single_line_textbox_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -590,6 +597,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "multi_line_textbox_multiple_.0",
}
},
index: 0,
}
Expand All @@ -615,6 +625,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "multi_line_textbox_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -797,6 +810,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "rich_text_editor_multiple_.0",
}
},
index: 0,
}
Expand All @@ -822,6 +838,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "rich_text_editor_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -1002,6 +1021,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "json_rich_text_editor_multiple_.0",
}
},
index: 0,
}
Expand All @@ -1027,6 +1049,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "json_rich_text_editor_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -1209,6 +1234,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "markdown_multiple_.0",
}
},
index: 0,
}
Expand All @@ -1234,6 +1262,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "markdown_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -1414,6 +1445,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "select_multiple_.0",
}
},
index: 0,
}
Expand All @@ -1439,6 +1473,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "select_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -1617,6 +1654,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "number_multiple_.0",
}
},
index: 0,
}
Expand All @@ -1642,6 +1682,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "number_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -1913,6 +1956,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "file_multiple_.0",
}
},
index: 0,
}
Expand All @@ -1938,6 +1984,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "file_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -2200,6 +2249,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "link_multiple_.0",
}
},
index: 0,
}
Expand All @@ -2225,6 +2277,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "link_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -2403,6 +2458,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "reference_multiple_.0",
}
},
index: 0,
}
Expand All @@ -2429,6 +2487,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "reference_multiple_.0",
}
},
index: 1,
}
Expand Down Expand Up @@ -2657,6 +2718,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "group_multiple_.0",
}
},
index: 0,
}
Expand All @@ -2683,6 +2747,9 @@ describe("When an element is hovered in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "group_multiple_.0",
}
},
index: 1,
}
Expand Down
18 changes: 18 additions & 0 deletions src/liveEditor/__test__/visualEditorInput.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ describe("When an inline element is edited in visual editor mode", () => {
parentDetails: null,
index: -1,
},
instance: {
fieldPathWithIndex: "single_line",
}
},
}
);
Expand Down Expand Up @@ -280,6 +283,9 @@ describe("When an inline element is edited in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "single_line_textbox_multiple_.0",
}
},
}
);
Expand Down Expand Up @@ -328,6 +334,9 @@ describe("When an inline element is edited in visual editor mode", () => {
},
index: 1,
},
instance: {
fieldPathWithIndex: "single_line_textbox_multiple_.1",
}
},
}
);
Expand Down Expand Up @@ -420,6 +429,9 @@ describe("When an inline element is edited in visual editor mode", () => {
parentDetails: null,
index: -1,
},
instance: {
fieldPathWithIndex: "multi_line",
}
},
}
);
Expand Down Expand Up @@ -552,6 +564,9 @@ describe("When an inline element is edited in visual editor mode", () => {
},
index: 0,
},
instance: {
fieldPathWithIndex: "single_line_textbox_multiple_.0",
}
},
}
);
Expand Down Expand Up @@ -600,6 +615,9 @@ describe("When an inline element is edited in visual editor mode", () => {
},
index: 1,
},
instance: {
fieldPathWithIndex: "single_line_textbox_multiple_.1",
}
},
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ describe("FieldLabelWrapperComponent", () => {
parentCslpValue: "",
},
},
instance: {
fieldPathWithIndex: "",
},
};

const mockEventDetails: VisualEditorCslpEventDetails = {
Expand Down
Loading

0 comments on commit 559aba6

Please sign in to comment.