From 68458512a21fb6d53bdad3fde13a484c54ebf1f5 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:05:21 +0800 Subject: [PATCH 1/3] rename and split constants --- .../core/test/unit/html/NodeProcessor.data.ts | 88 ++++++++++--------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index b255e4de57..5c85c8d41b 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -38,29 +38,6 @@ export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "panel has a header slot, 'header' attribute has no effect."; -export const PROCESS_PANEL_HEADER_NO_OVERRIDE = ` - -
- This existing header slot should be preserved in favour over header attribute. -
- Header attribute should not be inserted under panel since there is both an alt attribute and header slot, - but should be deleted. - Alt attribute should be inserted under panel as slot. -
-`; - -export const PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED = ` - - - Header attribute should not be inserted under panel since there is both an alt attribute and header slot, - but should be deleted. - Alt attribute should be inserted under panel as slot. - -`; - // Post Process export const POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT = ` @@ -92,18 +69,38 @@ export const PROCESS_QUESTION_ATTRIBUTES_EXPECTED = ` `; -export const PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE = ` - +export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY = ` + - - `; -export const PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED = ` +export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` + +`; + +export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY = ` + + + +`; + +export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_EXPECTED = ` + + +`; + +export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY = ` + + + +`; + +export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_EXPECTED = ` + `; @@ -119,13 +116,13 @@ export const PROCESS_QOPTION_ATTRIBUTES_EXPECTED = ` `; -export const PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE = ` +export const PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY = ` `; -export const PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED = ` +export const PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_EXPECTED = ` @@ -142,13 +139,13 @@ export const PROCESS_QUIZ_ATTRIBUTES_EXPECTED = ` `; -export const PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE = ` +export const PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY = ` `; -export const PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE_EXPECTED = ` +export const PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_EXPECTED = ` @@ -171,24 +168,35 @@ export const PROCESS_POPOVER_ATTRIBUTES_EXPECTED = ` `; -export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE = ` - +export const PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY = ` +
Some header slot content that should not be overwritten
-
Some content slot that should not be overwritten
- Content and header attributes should not be inserted under panel as slots, but should be deleted. + Header attribute should not be inserted under panel as slot, but should be deleted.
`; -export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_EXPECTED = ` +export const PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` - - Content and header attributes should not be inserted under panel as slots, but should be deleted. + Header attribute should not be inserted under panel as slot, but should be deleted. `; export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG = "popover has a header slot, 'header' attribute has no effect."; + +export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY = ` + +
Some content slot that should not be overwritten
+ Content attribute should not be inserted under panel as slot, but should be deleted. +
+`; + +export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + Content attribute should not be inserted under panel as slot, but should be deleted. + +`; export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_CONTENT_WARN_MSG = "popover has a content slot, 'content' attribute has no effect."; /* From 21fc2997cf71e0436684eacd44abd30f5defaeb4 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Fri, 29 Mar 2024 21:05:36 +0800 Subject: [PATCH 2/3] update test --- .../core/test/unit/html/NodeProcessor.test.ts | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index 10505ccd2c..8e7e8cf5be 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -58,39 +58,42 @@ test('processNode processes panel attributes and inserts into dom as slots corre processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY, testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED); expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); - processAndVerifyTemplate(testData.PROCESS_PANEL_HEADER_NO_OVERRIDE, - testData.PROCESS_PANEL_HEADER_NO_OVERRIDE_EXPECTED); - expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); }); test('processNode processes question attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_QUESTION_ATTRIBUTES, testData.PROCESS_QUESTION_ATTRIBUTES_EXPECTED); - processAndVerifyTemplate(testData.PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE, - testData.PROCESS_QUESTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED); + processAndVerifyTemplate(testData.PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY, + testData.PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_EXPECTED); + processAndVerifyTemplate(testData.PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY, + testData.PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_EXPECTED); + processAndVerifyTemplate(testData.PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY, + testData.PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_EXPECTED); }); test('processNode processes q-option attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_QOPTION_ATTRIBUTES, testData.PROCESS_QOPTION_ATTRIBUTES_EXPECTED); - processAndVerifyTemplate(testData.PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE, - testData.PROCESS_QOPTION_ATTRIBUTES_NO_OVERRIDE_EXPECTED); + processAndVerifyTemplate(testData.PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY, + testData.PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_EXPECTED); }); test('processNode processes quiz attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_QUIZ_ATTRIBUTES, testData.PROCESS_QUIZ_ATTRIBUTES_EXPECTED); - processAndVerifyTemplate(testData.PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE, - testData.PROCESS_QUIZ_ATTRIBUTES_NO_OVERRIDE_EXPECTED); + processAndVerifyTemplate(testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY, + testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_EXPECTED); }); test('processNode processes popover attributes and inserts into dom as slots correctly', () => { const warnSpy = jest.spyOn(logger, 'warn'); processAndVerifyTemplate(testData.PROCESS_POPOVER_ATTRIBUTES, testData.PROCESS_POPOVER_ATTRIBUTES_EXPECTED); - processAndVerifyTemplate(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE, - testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_EXPECTED); + processAndVerifyTemplate(testData.PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY, + testData.PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY_EXPECTED); expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG); + processAndVerifyTemplate(testData.PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY, + testData.PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED); expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_CONTENT_WARN_MSG); }); From 7f6f663df9ccb85948b3122172cac50104270994 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Sat, 30 Mar 2024 16:16:59 +0800 Subject: [PATCH 3/3] delete other constant, fix nit --- .../core/test/unit/html/NodeProcessor.data.ts | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 5c85c8d41b..0f6900c05a 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -19,20 +19,25 @@ export const PROCESS_PANEL_ATTRIBUTES_EXPECTED = ` `; export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY = ` - +
- This existing header slot should be preserved in favour over header attribute, with a logger warning for repeated attributes. + This existing header slot should be preserved in favour over header attribute.
- Header attribute should be ignored and deleted while header slot is reserved. + Header attribute should not be inserted under panel since there is both an alt attribute and header slot, + but should be deleted. + Alt attribute should be inserted under panel as slot.
`; export const PROCESS_PANEL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` - + - Header attribute should be ignored and deleted while header slot is reserved. + Header attribute should not be inserted under panel since there is both an alt attribute and header slot, + but should be deleted. + Alt attribute should be inserted under panel as slot. `; @@ -70,7 +75,7 @@ export const PROCESS_QUESTION_ATTRIBUTES_EXPECTED = ` `; export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY = ` - + `; @@ -82,7 +87,7 @@ export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` `; export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY = ` - + `; @@ -94,7 +99,7 @@ export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_EXPECTED = ` `; export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY = ` - + `;