diff --git a/src/main/js/bundles/dn_welcome/tests/WelcomeWidgetTest.ts b/src/main/js/bundles/dn_welcome/tests/WelcomeWidgetTest.ts index f8f8258..0cf6c9d 100644 --- a/src/main/js/bundles/dn_welcome/tests/WelcomeWidgetTest.ts +++ b/src/main/js/bundles/dn_welcome/tests/WelcomeWidgetTest.ts @@ -142,4 +142,73 @@ describe(module.id, function () { const buttonWrapper = wrapper.findComponent({ name: 'v-btn' }); assert.isFalse(buttonWrapper.vm.$props.disabled); }); + + const sanitizerTests = [ + { + message: "Event attributes should be removed from info text", + testInfoText: "Welcome!

Click here!

", + shouldNotInclude: "onclick" + }, + { + message: "'script' tags should be removed from info text", + testInfoText: "Welcome! ", + shouldNotInclude: "script" + }, + { + message: "Uppercase 'SCRIPT' tags should be removed from info text", + testInfoText: "Welcome! ", + shouldNotInclude: "SCRIPT" + }, + { + message: "'iframe' tags should be removed from info text", + testInfoText: "Welcome! ", + shouldNotInclude: "iframe" + }, + { + message: "'object' tags should be removed from info text", + testInfoText: "Welcome! ", + shouldNotInclude: "object" + }, + { + message: "'embed' tags should be removed from info text", + testInfoText: "Welcome! ", + shouldNotInclude: "embed" + }, + { + message: "'i' tags should be preserved in info text", + testInfoText: "Welcome!", + shouldInclude: "" + }, + { + message: "'style' attributes on tags should be preserved in info text", + testInfoText: "

Welcome

", + shouldInclude: "style" + } + ] as SanitizerTestCase[]; + + sanitizerTests.forEach(testCase => { + it(testCase.message, async function () { + const wrapper = mount(WelcomeWidget); + await wrapper.setData({ + infoText: testCase.testInfoText + }); + const infoTextWrapper = wrapper.find(".dn-welcome-widget__info-text"); + + const html = infoTextWrapper.html(); + + if (testCase.shouldNotInclude) { + assert.notInclude(html, testCase.shouldNotInclude); + } + if (testCase.shouldInclude) { + assert.include(html, testCase.shouldInclude); + } + }); + }); }); + +interface SanitizerTestCase { + message: string; + testInfoText: string; + shouldNotInclude?: string; + shouldInclude?: string; +}