From da2a4d17138f0e8ee5e40cb8665aaf94ea620094 Mon Sep 17 00:00:00 2001 From: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com> Date: Mon, 14 Oct 2024 11:57:52 +0700 Subject: [PATCH] V14 QA Added the acceptance tests for rendering content with textstring (#17247) * Added tests for textstring in the rendered content * Updated tests for rendering content with textstring * Added tests for rendering content with numeric * Added tests for rendering content with textarea * Removed tests * Bumped version * Make all tests for rendering content run in the pipeline * Make all smoke tests run in the pipeline --- .../RenderingContentWithTextstring.spec.ts | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextstring.spec.ts diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextstring.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextstring.spec.ts new file mode 100644 index 0000000000..9a394ffd07 --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextstring.spec.ts @@ -0,0 +1,43 @@ +import {test} from '@umbraco/playwright-testhelpers'; + +const contentName = 'Test Rendering Content'; +const documentTypeName = 'TestDocumentTypeForContent'; +const dataTypeName = 'Textstring'; +const templateName = 'TestTemplateForContent'; +let dataTypeData; + +test.beforeEach(async ({umbracoApi}) => { + dataTypeData = await umbracoApi.dataType.getByName(dataTypeName); +}); + +test.afterEach(async ({umbracoApi}) => { + await umbracoApi.document.ensureNameNotExists(contentName); + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); + await umbracoApi.template.ensureNameNotExists(templateName); +}); + +const textstrings = [ + {type: 'an empty textstring', value: ''}, + {type: 'a non-empty textstring', value: 'Welcome to Umbraco site'}, + {type: 'a textstring contains special characters', value: '@#^&*()_+[]{};:"<>,./?'}, + {type: 'a numeric textstring', value: '0123456789'}, + {type: 'a textstring contains an SQL injection', value: "' OR '1'='1'; --"}, + {type: 'a textstring contains a cross-site scripting', value: ""} +]; + +for (const textstring of textstrings) { + test(`can render content with ${textstring.type}`, async ({umbracoApi, umbracoUi}) => { + // Arrange + const textstringValue = textstring.value; + await umbracoApi.document.createPublishedDocumentWithValue(contentName, textstringValue, dataTypeData.id, documentTypeName, templateName); + const contentData = await umbracoApi.document.getByName(contentName); + const contentURL = contentData.urls[0].url; + + // Act + await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL); + + // Assert + await umbracoUi.contentRender.doesContentRenderValueHaveText(textstringValue); + }); +} +