From 91e2df0fa63cc71dd9a2327b669674a0cb2a4318 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:17:35 +0800 Subject: [PATCH 01/14] add test for panel alt slot --- .../core/test/unit/html/NodeProcessor.data.ts | 20 +++++++++++++++++++ .../core/test/unit/html/NodeProcessor.test.ts | 12 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 0f6900c05a..f5bd081f2d 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -43,6 +43,26 @@ 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_ALT_SLOT_TAKES_PRIORITY = ` + +
+ Alt slot text +
+ Alt attribute should be ignored and deleted while alt slot is reserved. +
+`; + +export const PROCESS_PANEL_ALT_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + Alt attribute should be ignored and deleted while alt slot is reserved. + +`; + +export const PROCESS_PANEL_ALT_SLOT_TAKES_PRIORITY_WARN_MSG = "panel has a _alt slot, 'alt' attribute has no effect."; + // Post Process export const POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT = ` diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index 8e7e8cf5be..2f1712e6e7 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -52,14 +52,24 @@ const processAndVerifyTemplate = (template: string, expectedTemplate: string, po }; test('processNode processes panel attributes and inserts into dom as slots correctly', () => { - const warnSpy = jest.spyOn(logger, 'warn'); processAndVerifyTemplate(testData.PROCESS_PANEL_ATTRIBUTES, testData.PROCESS_PANEL_ATTRIBUTES_EXPECTED); +}); + +test('processNode processes panel with header slot taking priority over header attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); 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); }); +test('processNode processes panel with _alt slot taking priority over alt attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_PANEL_ALT_SLOT_TAKES_PRIORITY, + testData.PROCESS_PANEL_ALT_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_ALT_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); From cae2ff84967d6c87f553864558f29b865a9ac7fd Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:26:05 +0800 Subject: [PATCH 02/14] add logger tests for question attributes --- .../core/test/unit/html/NodeProcessor.data.ts | 6 ++++++ .../core/test/unit/html/NodeProcessor.test.ts | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index f5bd081f2d..c305af6c96 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -106,6 +106,8 @@ export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` `; +export const PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "question has a header slot, 'header' attribute has no effect."; + export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY = ` @@ -118,6 +120,8 @@ export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_EXPECTED = ` `; +export const PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_WARN_MSG = "question has a hint slot, 'hint' attribute has no effect."; + export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY = ` @@ -130,6 +134,8 @@ export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_EXPECTED = ` `; +export const PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_WARN_MSG = "question has a answer slot, 'answer' attribute has no effect."; + export const PROCESS_QOPTION_ATTRIBUTES = ` diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index 2f1712e6e7..25cb233f02 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -73,12 +73,27 @@ test('processNode processes panel with _alt slot taking priority over alt attrib test('processNode processes question attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_QUESTION_ATTRIBUTES, testData.PROCESS_QUESTION_ATTRIBUTES_EXPECTED); +}); + +test('processNode processes question with header slot taking priority over header attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); processAndVerifyTemplate(testData.PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY, testData.PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_QUESTION_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + +test('processNode processes question with hint slot taking priority over hint attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); processAndVerifyTemplate(testData.PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY, testData.PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_QUESTION_HINT_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + +test('processNode processes question with answer slot taking priority over answer attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); processAndVerifyTemplate(testData.PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY, testData.PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_QUESTION_ANSWER_SLOT_TAKES_PRIORITY_WARN_MSG); }); test('processNode processes q-option attributes and inserts into dom as slots correctly', () => { From 985e1ad261f67e612a87fc13ef6c28f4fb6fe27c Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:28:34 +0800 Subject: [PATCH 03/14] add logger test for q-option --- packages/core/test/unit/html/NodeProcessor.data.ts | 2 ++ packages/core/test/unit/html/NodeProcessor.test.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index c305af6c96..2a6b5639b2 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -159,6 +159,8 @@ export const PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_EXPECTED = ` `; +export const PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_WARN_MSG = "q-option has a reason slot, 'reason' attribute has no effect."; + export const PROCESS_QUIZ_ATTRIBUTES = ` diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index 25cb233f02..f4531f8dc6 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -99,8 +99,13 @@ test('processNode processes question with answer slot taking priority over answe test('processNode processes q-option attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_QOPTION_ATTRIBUTES, testData.PROCESS_QOPTION_ATTRIBUTES_EXPECTED); +}); + +test('processNode processes q-option with reason slot taking priority over reason attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); processAndVerifyTemplate(testData.PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY, testData.PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_QOPTION_REASON_SLOT_TAKES_PRIORITY_WARN_MSG); }); test('processNode processes quiz attributes and inserts into dom as slots correctly', () => { From 8ebf749af0c00de1dda1cfd5622371447f2410c5 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:37:42 +0800 Subject: [PATCH 04/14] add logger test for quiz --- packages/core/test/unit/html/NodeProcessor.data.ts | 2 ++ packages/core/test/unit/html/NodeProcessor.test.ts | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 2a6b5639b2..c5c277ed1c 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -184,6 +184,8 @@ export const PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_EXPECTED = ` `; +export const PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_WARN_MSG = "quiz has a intro slot, 'intro' attribute has no effect."; + /* * Popovers */ diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index f4531f8dc6..f8e69ebac4 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -115,6 +115,13 @@ test('processNode processes quiz attributes and inserts into dom as slots correc testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_EXPECTED); }); +test('processNode processes quiz with intro slot taking priority over intro attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY, + testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_QUIZ_INTRO_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + test('processNode processes popover attributes and inserts into dom as slots correctly', () => { const warnSpy = jest.spyOn(logger, 'warn'); processAndVerifyTemplate(testData.PROCESS_POPOVER_ATTRIBUTES, From 2c2e0f65c2c36ec3c75bfe7bd12c06497752a2eb Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:39:46 +0800 Subject: [PATCH 05/14] split popover tests --- packages/core/test/unit/html/NodeProcessor.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index f8e69ebac4..67a9998ce4 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -123,12 +123,19 @@ test('processNode processes quiz with intro slot taking priority over intro attr }); 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); +}); + +test('processNode processes popover with header slot taking priority over header attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); 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); +}); + +test('processNode processes popover with content slot taking priority over content attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); 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 a7ae27d35cc9f7e855a7bfa761662d0cb8fcb1c8 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:45:28 +0800 Subject: [PATCH 06/14] add test for tooltip content slot --- .../core/test/unit/html/NodeProcessor.data.ts | 16 ++++++++++++++++ .../core/test/unit/html/NodeProcessor.test.ts | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index c5c277ed1c..05eb7dca4a 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -250,6 +250,22 @@ export const PROCESS_TOOLTIP_CONTENT_EXPECTED = ` `; +export const PROCESS_TOOLTIP_CONTENT_SLOT_TAKES_PRIORITY = ` + +
Some content slot that should not be overwritten
+ Content attribute should not be inserted under tooltip as slot, but should be deleted. +
+`; + +export const PROCESS_TOOLTIP_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + Content attribute should not be inserted under tooltip as slot, but should be deleted. + +`; + +export const PROCESS_TOOLTIP_CONTENT_SLOT_TAKES_PRIORITY_WARN_MSG = "tooltip has a content slot, 'content' attribute has no effect."; + /* * Modals */ diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index 67a9998ce4..df483887db 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -146,6 +146,13 @@ test('processNode processes tooltip attributes and inserts into dom as slots cor testData.PROCESS_TOOLTIP_CONTENT_EXPECTED); }); +test('processNode processes tooltip with content slot taking priority over content attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_TOOLTIP_CONTENT_SLOT_TAKES_PRIORITY, + testData.PROCESS_TOOLTIP_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_TOOLTIP_CONTENT_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + test('processNode processes modal attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_MODAL_HEADER, testData.PROCESS_MODAL_HEADER_EXPECTED); From 17ed53de09fdc69155c86e036103d981a53db571 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:46:23 +0800 Subject: [PATCH 07/14] rename popover warn msg constants --- packages/core/test/unit/html/NodeProcessor.data.ts | 4 ++-- packages/core/test/unit/html/NodeProcessor.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 05eb7dca4a..58655536d0 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -217,7 +217,7 @@ export const PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` `; -export const PROCESS_POPOVER_ATTRIBUTES_NO_OVERRIDE_HEADER_WARN_MSG = "popover has a header slot, 'header' attribute has no effect."; +export const PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "popover has a header slot, 'header' attribute has no effect."; export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY = ` @@ -232,7 +232,7 @@ 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."; +export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_WARN_MSG = "popover has a content slot, 'content' attribute has no effect."; /* * Tooltips diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index df483887db..5f97cc7e5b 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -131,14 +131,14 @@ test('processNode processes popover with header slot taking priority over header const warnSpy = jest.spyOn(logger, 'warn'); 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); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); }); test('processNode processes popover with content slot taking priority over content attribute', () => { const warnSpy = jest.spyOn(logger, 'warn'); 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); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_WARN_MSG); }); test('processNode processes tooltip attributes and inserts into dom as slots correctly', () => { From 15fe19609b560317379ccdc4bf5a1968f6e93e12 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 10:55:05 +0800 Subject: [PATCH 08/14] add test for modal header slot --- .../core/test/unit/html/NodeProcessor.data.ts | 16 ++++++++++++++++ .../core/test/unit/html/NodeProcessor.test.ts | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 58655536d0..9b705cf671 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -294,6 +294,22 @@ export const PROCESS_MODAL_OK_TEXT_EXPECTED = ` `; +export const PROCESS_MODAL_HEADER_SLOT_TAKES_PRIORITY = ` + +
Some header slot content that should not be overwritten
+ Header attribute should not be inserted under modal as slot, but should be deleted. +
+`; + +export const PROCESS_MODAL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + Header attribute should not be inserted under modal as slot, but should be deleted. + +`; + +export const PROCESS_MODAL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "modal has a header slot, 'header' attribute has no effect."; + /* * Tab, tab-group */ diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index 5f97cc7e5b..abda11e431 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -162,6 +162,13 @@ test('processNode processes modal attributes and inserts into dom as slots corre testData.PROCESS_MODAL_OK_TEXT_EXPECTED); }); +test('processNode processes modal with header slot taking priority over header attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_MODAL_HEADER_SLOT_TAKES_PRIORITY, + testData.PROCESS_MODAL_HEADER_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_MODAL_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + test('processNode processes tab & tab-group attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_TAB_HEADER, testData.PROCESS_TAB_HEADER_EXPECTED); From 9792dbb192731edd7901a1b6629cc8a52f55b401 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:08:14 +0800 Subject: [PATCH 09/14] add tests for tab and tab-group header slots --- .../core/test/unit/html/NodeProcessor.data.ts | 32 +++++++++++++++++++ .../core/test/unit/html/NodeProcessor.test.ts | 14 ++++++++ 2 files changed, 46 insertions(+) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 9b705cf671..35650adc6b 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -326,6 +326,22 @@ export const PROCESS_TAB_HEADER_EXPECTED = ` `; +export const PROCESS_TAB_HEADER_SLOT_TAKES_PRIORITY = ` + +
Some header slot content that should not be overwritten
+ Header attribute should not be inserted under tab as slot, but should be deleted. +
+`; + +export const PROCESS_TAB_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + Header attribute should not be inserted under tab as slot, but should be deleted. + +`; + +export const PROCESS_TAB_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "tab has a header slot, 'header' attribute has no effect."; + export const PROCESS_TAB_GROUP_HEADER = ` Header attribute should be inserted as header slot and deleted. @@ -338,6 +354,22 @@ export const PROCESS_TAB_GROUP_HEADER_EXPECTED = ` `; +export const PROCESS_TAB_GROUP_HEADER_SLOT_TAKES_PRIORITY = ` + +
Some header slot content that should not be overwritten
+ Header attribute should not be inserted under tab-group as slot, but should be deleted. +
+`; + +export const PROCESS_TAB_GROUP_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + Header attribute should not be inserted under tab-group as slot, but should be deleted. + +`; + +export const PROCESS_TAB_GROUP_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "tab-group has a header slot, 'header' attribute has no effect."; + /* * Boxes */ diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index abda11e431..ceb092a1a7 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -176,6 +176,20 @@ test('processNode processes tab & tab-group attributes and inserts into dom as s testData.PROCESS_TAB_GROUP_HEADER_EXPECTED); }); +test('processNode processes tab with header slot taking priority over header attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_TAB_HEADER_SLOT_TAKES_PRIORITY, + testData.PROCESS_TAB_HEADER_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_TAB_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + +test('processNode processes tab-group with header slot taking priority over header attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_TAB_GROUP_HEADER_SLOT_TAKES_PRIORITY, + testData.PROCESS_TAB_GROUP_HEADER_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_TAB_GROUP_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + test('processNode processes box attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_BOX_ICON, testData.PROCESS_BOX_ICON_EXPECTED); From 78ee7a6b576c36095efcf728730b6e5516c3594f Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:24:15 +0800 Subject: [PATCH 10/14] add tests for box icon and header slot --- .../core/test/unit/html/NodeProcessor.data.ts | 32 +++++++++++++++++++ .../core/test/unit/html/NodeProcessor.test.ts | 14 ++++++++ 2 files changed, 46 insertions(+) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 35650adc6b..00b654159b 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -399,6 +399,38 @@ export const PROCESS_BOX_HEADER_EXPECTED = ` `; +export const PROCESS_BOX_ICON_SLOT_TAKES_PRIORITY = ` + +
:rocket:
+ Icon attribute should not be inserted under box as slot, but should be deleted. +
+`; + +export const PROCESS_BOX_ICON_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + Icon attribute should not be inserted under box as slot, but should be deleted. + +`; + +export const PROCESS_BOX_ICON_SLOT_TAKES_PRIORITY_WARN_MSG = "box has a icon slot, 'icon' attribute has no effect."; + +export const PROCESS_BOX_HEADER_SLOT_TAKES_PRIORITY = ` + +
Some header slot content that should not be overwritten
+ Header attribute should not be inserted under box as slot, but should be deleted. +
+`; + +export const PROCESS_BOX_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + Header attribute should not be inserted under box as slot, but should be deleted. + +`; + +export const PROCESS_BOX_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "box has a header slot, 'header' attribute has no effect."; + /** * Dropdowns */ diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index ceb092a1a7..40864dd145 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -197,6 +197,20 @@ test('processNode processes box attributes and inserts into dom as slots correct testData.PROCESS_BOX_HEADER_EXPECTED); }); +test('processNode processes box with icon slot taking priority over header attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_BOX_ICON_SLOT_TAKES_PRIORITY, + testData.PROCESS_BOX_ICON_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_BOX_ICON_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + +test('processNode processes box with header slot taking priority over header attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_BOX_HEADER_SLOT_TAKES_PRIORITY, + testData.PROCESS_BOX_HEADER_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_BOX_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + test('postProcessNode assigns the correct panel id to panels', () => { processAndVerifyTemplate(testData.POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT, testData.POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT_EXPECTED, From 27f8beb80c8d261ee83127fa4642b6f632f6de50 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:26:43 +0800 Subject: [PATCH 11/14] shift postprocessnode panel test to be with other panel tests --- packages/core/test/unit/html/NodeProcessor.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index 40864dd145..ef69f1028c 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -70,6 +70,12 @@ test('processNode processes panel with _alt slot taking priority over alt attrib expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_PANEL_ALT_SLOT_TAKES_PRIORITY_WARN_MSG); }); +test('postProcessNode assigns the correct panel id to panels', () => { + processAndVerifyTemplate(testData.POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT, + testData.POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT_EXPECTED, + true); +}); + test('processNode processes question attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_QUESTION_ATTRIBUTES, testData.PROCESS_QUESTION_ATTRIBUTES_EXPECTED); @@ -211,12 +217,6 @@ test('processNode processes box with header slot taking priority over header att expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_BOX_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); }); -test('postProcessNode assigns the correct panel id to panels', () => { - processAndVerifyTemplate(testData.POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT, - testData.POST_PROCESS_PANEL_ID_ASSIGNED_USING_HEADER_SLOT_EXPECTED, - true); -}); - test('processNode processes dropdown header attribute and inserts into DOM as header slot correctly', () => { processAndVerifyTemplate(testData.PROCESS_DROPDOWN_HEADER, testData.PROCESS_DROPDOWN_HEADER_EXPECTED); From aefb136d2c640fd79d921080038516ffa39d8d1a Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:33:03 +0800 Subject: [PATCH 12/14] add tests for scroll-top-button --- .../core/test/unit/html/NodeProcessor.data.ts | 28 +++++++++++++++++++ .../core/test/unit/html/NodeProcessor.test.ts | 14 +++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 00b654159b..89cc55830d 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -463,4 +463,32 @@ export const PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` export const PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "dropdown has a header slot, 'header' attribute has no effect."; +/** + * Scroll-to-top button + */ + +export const PROCESS_SCROLL_TOP_BUTTON_ICON = ` + + +`; + +export const PROCESS_SCROLL_TOP_BUTTON_ICON_EXPECTED = ` + + +`; + +export const PROCESS_SCROLL_TOP_BUTTON_ICON_SLOT_TAKES_PRIORITY = ` + +
:rocket:
+
+`; + +export const PROCESS_SCROLL_TOP_BUTTON_ICON_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + +`; + +export const PROCESS_SCROLL_TOP_BUTTON_ICON_SLOT_TAKES_PRIORITY_WARN_MSG = "scroll-top-button has a icon slot, 'icon' attribute has no effect."; + /* eslint-enable max-len */ diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index ef69f1028c..0e152babb1 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -203,7 +203,7 @@ test('processNode processes box attributes and inserts into dom as slots correct testData.PROCESS_BOX_HEADER_EXPECTED); }); -test('processNode processes box with icon slot taking priority over header attribute', () => { +test('processNode processes box with icon slot taking priority over icon attribute', () => { const warnSpy = jest.spyOn(logger, 'warn'); processAndVerifyTemplate(testData.PROCESS_BOX_ICON_SLOT_TAKES_PRIORITY, testData.PROCESS_BOX_ICON_SLOT_TAKES_PRIORITY_EXPECTED); @@ -229,6 +229,18 @@ test('processNode processes dropdown with header slot taking priority over heade expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_DROPDOWN_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); }); +test('processNode processes scroll-top-button attributes and inserts into dom as slots correctly', () => { + processAndVerifyTemplate(testData.PROCESS_SCROLL_TOP_BUTTON_ICON, + testData.PROCESS_SCROLL_TOP_BUTTON_ICON_EXPECTED); +}); + +test('processNode processes scroll-top-button with icon slot taking priority over icon attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_SCROLL_TOP_BUTTON_ICON_SLOT_TAKES_PRIORITY, + testData.PROCESS_SCROLL_TOP_BUTTON_ICON_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_SCROLL_TOP_BUTTON_ICON_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + test('processNode does not log warning when lazy pic has width or height', () => { const nodeProcessor = getNewDefaultNodeProcessor(); From b543d10415950d7803df7276f813c631b7d042f9 Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:54:27 +0800 Subject: [PATCH 13/14] add tests for a-point --- .../core/test/unit/html/NodeProcessor.data.ts | 79 +++++++++++++++++++ .../core/test/unit/html/NodeProcessor.test.ts | 30 +++++++ 2 files changed, 109 insertions(+) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 89cc55830d..8e96a4ec39 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -491,4 +491,83 @@ export const PROCESS_SCROLL_TOP_BUTTON_ICON_SLOT_TAKES_PRIORITY_EXPECTED = ` export const PROCESS_SCROLL_TOP_BUTTON_ICON_SLOT_TAKES_PRIORITY_WARN_MSG = "scroll-top-button has a icon slot, 'icon' attribute has no effect."; +/** + * A-points + */ + +export const PROCESS_A_POINT_HEADER = ` + + +`; + +export const PROCESS_A_POINT_HEADER_EXPECTED = ` + + +`; + +export const PROCESS_A_POINT_CONTENT = ` + + +`; + +export const PROCESS_A_POINT_CONTENT_EXPECTED = ` + + +`; + +export const PROCESS_A_POINT_LABEL = ` + + +`; + +export const PROCESS_A_POINT_LABEL_EXPECTED = ` + + +`; + +export const PROCESS_A_POINT_HEADER_SLOT_TAKES_PRIORITY = ` + +
Some header slot content that should not be overwritten
+
+`; + +export const PROCESS_A_POINT_HEADER_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + +`; + +export const PROCESS_A_POINT_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG = "a-point has a header slot, 'header' attribute has no effect."; + +export const PROCESS_A_POINT_CONTENT_SLOT_TAKES_PRIORITY = ` + +
Some content slot content that should not be overwritten
+
+`; + +export const PROCESS_A_POINT_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + +`; + +export const PROCESS_A_POINT_CONTENT_SLOT_TAKES_PRIORITY_WARN_MSG = "a-point has a content slot, 'content' attribute has no effect."; + +export const PROCESS_A_POINT_LABEL_SLOT_TAKES_PRIORITY = ` + +
O
+
+`; + +export const PROCESS_A_POINT_LABEL_SLOT_TAKES_PRIORITY_EXPECTED = ` + + + +`; + +export const PROCESS_A_POINT_LABEL_SLOT_TAKES_PRIORITY_WARN_MSG = "a-point has a label slot, 'label' attribute has no effect."; + /* eslint-enable max-len */ diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index 0e152babb1..d00d4d9383 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -241,6 +241,36 @@ test('processNode processes scroll-top-button with icon slot taking priority ove expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_SCROLL_TOP_BUTTON_ICON_SLOT_TAKES_PRIORITY_WARN_MSG); }); +test('processNode processes a-point attributes and inserts into dom as slots correctly', () => { + processAndVerifyTemplate(testData.PROCESS_A_POINT_HEADER, + testData.PROCESS_A_POINT_HEADER_EXPECTED); + processAndVerifyTemplate(testData.PROCESS_A_POINT_CONTENT, + testData.PROCESS_A_POINT_CONTENT_EXPECTED); + processAndVerifyTemplate(testData.PROCESS_A_POINT_LABEL, + testData.PROCESS_A_POINT_LABEL_EXPECTED); +}); + +test('processNode processes a-point with header slot taking priority over header attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_A_POINT_HEADER_SLOT_TAKES_PRIORITY, + testData.PROCESS_A_POINT_HEADER_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_A_POINT_HEADER_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + +test('processNode processes a-point with content slot taking priority over content attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_A_POINT_CONTENT_SLOT_TAKES_PRIORITY, + testData.PROCESS_A_POINT_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_A_POINT_CONTENT_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + +test('processNode processes a-point with label slot taking priority over label attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_A_POINT_LABEL_SLOT_TAKES_PRIORITY, + testData.PROCESS_A_POINT_LABEL_SLOT_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_A_POINT_LABEL_SLOT_TAKES_PRIORITY_WARN_MSG); +}); + test('processNode does not log warning when lazy pic has width or height', () => { const nodeProcessor = getNewDefaultNodeProcessor(); From 618604b55bb54cdefa49f072de19d421807afcea Mon Sep 17 00:00:00 2001 From: Isaac Lee <68138671+luminousleek@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:00:29 +0800 Subject: [PATCH 14/14] add test for popover content attr --- packages/core/test/unit/html/NodeProcessor.data.ts | 13 +++++++++++++ packages/core/test/unit/html/NodeProcessor.test.ts | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/packages/core/test/unit/html/NodeProcessor.data.ts b/packages/core/test/unit/html/NodeProcessor.data.ts index 8e96a4ec39..142548b09b 100644 --- a/packages/core/test/unit/html/NodeProcessor.data.ts +++ b/packages/core/test/unit/html/NodeProcessor.data.ts @@ -234,6 +234,19 @@ export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_EXPECTED = ` `; export const PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_WARN_MSG = "popover has a content slot, 'content' attribute has no effect."; +export const PROCESS_POPOVER_CONTENT_ATTRIBUTE_TAKES_PRIORITY = ` + + Src attribute should not be inserted under panel as slot, but should be deleted. + +`; + +export const PROCESS_POPOVER_CONTENT_ATTRIBUTE_TAKES_PRIORITY_EXPECTED = ` + + Src attribute should not be inserted under panel as slot, but should be deleted. + +`; +export const PROCESS_POPOVER_CONTENT_ATTRIBUTE_TAKES_PRIORITY_WARN_MSG = "popover has a 'content' attribute, 'src' attribute has no effect."; + /* * Tooltips */ diff --git a/packages/core/test/unit/html/NodeProcessor.test.ts b/packages/core/test/unit/html/NodeProcessor.test.ts index d00d4d9383..b94afade25 100644 --- a/packages/core/test/unit/html/NodeProcessor.test.ts +++ b/packages/core/test/unit/html/NodeProcessor.test.ts @@ -147,6 +147,13 @@ test('processNode processes popover with content slot taking priority over conte expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_CONTENT_SLOT_TAKES_PRIORITY_WARN_MSG); }); +test('processNode processes popover with content attribute taking priority over src attribute', () => { + const warnSpy = jest.spyOn(logger, 'warn'); + processAndVerifyTemplate(testData.PROCESS_POPOVER_CONTENT_ATTRIBUTE_TAKES_PRIORITY, + testData.PROCESS_POPOVER_CONTENT_ATTRIBUTE_TAKES_PRIORITY_EXPECTED); + expect(warnSpy).toHaveBeenCalledWith(testData.PROCESS_POPOVER_CONTENT_ATTRIBUTE_TAKES_PRIORITY_WARN_MSG); +}); + test('processNode processes tooltip attributes and inserts into dom as slots correctly', () => { processAndVerifyTemplate(testData.PROCESS_TOOLTIP_CONTENT, testData.PROCESS_TOOLTIP_CONTENT_EXPECTED);