Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V14 QA Added the acceptance tests for rendering content with different value #17293

Open
wants to merge 12 commits into
base: v14/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tests/Umbraco.Tests.AcceptanceTest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/Umbraco.Tests.AcceptanceTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"test": "npx playwright test DefaultConfig",
"all": "npx playwright test",
"createTest": "node createTest.js",
"smokeTest": "npx playwright test DefaultConfig --grep \"@smoke\""
"smokeTest": "npx playwright test DefaultConfig/RenderingContent"
},
"devDependencies": {
"@playwright/test": "^1.43",
Expand All @@ -19,7 +19,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.21",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.90",
"@umbraco/playwright-testhelpers": "^2.0.0-beta.91",
"camelize": "^1.0.0",
"dotenv": "^16.3.1",
"node-fetch": "^2.6.7"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';

const contentName = 'Test Rendering Content';
const documentTypeName = 'TestDocumentTypeForContent';
const customDataTypeName = 'Custom Approved Color';
const templateName = 'TestTemplateForContent';
const propertyName = 'Test Approved Color';
const colorValue = {label: "Test Label", value: "038c33"};
let dataTypeId;

test.beforeEach(async ({umbracoApi}) => {
dataTypeId = await umbracoApi.dataType.createApprovedColorDataTypeWithOneItem(customDataTypeName, colorValue.label, colorValue.value);
});

test.afterEach(async ({umbracoApi}) => {
await umbracoApi.document.ensureNameNotExists(contentName);
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
await umbracoApi.template.ensureNameNotExists(templateName);
await umbracoApi.dataType.ensureNameNotExists(customDataTypeName);
});

test('can render content with an approved color with label', async ({umbracoApi, umbracoUi}) => {
// Arrange
const templateId = await umbracoApi.template.createTemplateWithDisplayingApprovedColorValue(templateName, AliasHelper.toAlias(propertyName));
await umbracoApi.document.createPublishedDocumentWithValue(contentName, colorValue, dataTypeId, templateId, propertyName, documentTypeName);
const contentData = await umbracoApi.document.getByName(contentName);
const contentURL = contentData.urls[0].url;

// Act
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);

// Assert
await umbracoUi.contentRender.doesContentRenderValueHaveText(colorValue.label);
});

test('can render content with an approved color without label', async ({umbracoApi, umbracoUi}) => {
// Arrange
const templateId = await umbracoApi.template.createTemplateWithDisplayingApprovedColorValue(templateName, AliasHelper.toAlias(propertyName), false);
await umbracoApi.document.createPublishedDocumentWithValue(contentName, colorValue, dataTypeId, templateId, propertyName, documentTypeName);
const contentData = await umbracoApi.document.getByName(contentName);
const contentURL = contentData.urls[0].url;

// Act
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);

// Assert
await umbracoUi.contentRender.doesContentRenderValueHaveText(colorValue.value);
});


Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';

const contentName = 'Test Rendering Content';
const documentTypeName = 'TestDocumentTypeForContent';
const dataTypeName = 'Numeric';
const templateName = 'TestTemplateForContent';
const propertyName = 'Test Numeric';
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 numerics = [
{type: 'an positive integer', value: '1234567890'},
{type: 'a negative integer', value: '-1234567890'},
];

for (const numeric of numerics) {
test(`can render content with ${numeric.type}`, async ({umbracoApi, umbracoUi}) => {
// Arrange
const numericValue = numeric.value;
const templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName));
await umbracoApi.document.createPublishedDocumentWithValue(contentName, numericValue, dataTypeData.id, templateId, propertyName, documentTypeName);
const contentData = await umbracoApi.document.getByName(contentName);
const contentURL = contentData.urls[0].url;

// Act
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);

// Assert
await umbracoUi.contentRender.doesContentRenderValueHaveText(numericValue);
});
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';

const contentName = 'Test Rendering Content';
const documentTypeName = 'TestDocumentTypeForContent';
const dataTypeName = 'Tags';
const templateName = 'TestTemplateForContent';
const propertyName = 'Test Tags';
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 tags = [
{type: 'an empty tags', value: []},
{type: 'a non-empty tags', value: ['test tag']},
{type: 'multiple tags', value: ['test tag 1', 'test tag 2']},
];

for (const tag of tags) {
test(`can render content with ${tag.type}`, async ({umbracoApi, umbracoUi}) => {
// Arrange
const tagValue = tag.value;
const templateId = await umbracoApi.template.createTemplateWithDisplayingTagsValue(templateName, AliasHelper.toAlias(propertyName));
await umbracoApi.document.createPublishedDocumentWithValue(contentName, tagValue, dataTypeData.id, templateId, propertyName, documentTypeName);
const contentData = await umbracoApi.document.getByName(contentName);
const contentURL = contentData.urls[0].url;

// Act
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);

// Assert
tagValue.forEach(async value => {
await umbracoUi.contentRender.doesContentRenderValueHaveText(value);
});
});
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';

const contentName = 'Test Rendering Content';
const documentTypeName = 'TestDocumentTypeForContent';
const dataTypeName = 'Textarea';
const templateName = 'TestTemplateForContent';
const propertyName = 'Test Textarea';
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 textareas = [
{type: 'an empty textarea', value: ''},
{type: 'a non-empty textarea', value: 'Welcome to Umbraco site'},
{type: 'a textarea contains special characters', value: '@#^&*()_+[]{};:"<>,./?'},
{type: 'a textarea contains multiple lines', value: 'First line\n Second line\n Third line'},
{type: 'a textarea contains an SQL injection', value: "' OR '1'='1'; --"},
{type: 'a textarea contains a cross-site scripting', value: "<script>alert('XSS')</script>"}
];

for (const textarea of textareas) {
test(`can render content with ${textarea.type}`, async ({umbracoApi, umbracoUi}) => {
// Arrange
const textareaValue = textarea.value;
const templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName));
await umbracoApi.document.createPublishedDocumentWithValue(contentName, textareaValue, dataTypeData.id, templateId, propertyName, documentTypeName);
const contentData = await umbracoApi.document.getByName(contentName);
const contentURL = contentData.urls[0].url;

// Act
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);

// Assert
await umbracoUi.contentRender.doesContentRenderValueHaveText(textareaValue);
});
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {test} from '@umbraco/playwright-testhelpers';
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';

const contentName = 'Test Rendering Content';
const documentTypeName = 'TestDocumentTypeForContent';
const dataTypeName = 'Textstring';
const templateName = 'TestTemplateForContent';
const propertyName = 'Test Textstring';
let dataTypeData;

test.beforeEach(async ({umbracoApi}) => {
Expand All @@ -29,7 +30,8 @@ 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 templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName));
await umbracoApi.document.createPublishedDocumentWithValue(contentName, textstringValue, dataTypeData.id, templateId, propertyName, documentTypeName);
const contentData = await umbracoApi.document.getByName(contentName);
const contentURL = contentData.urls[0].url;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';

const contentName = 'Test Rendering Content';
const documentTypeName = 'TestDocumentTypeForContent';
const dataTypeName = 'True/false';
const templateName = 'TestTemplateForContent';
const propertyName = 'Test TrueFalse';
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 trueFalses = [
{type: 'true value ', value: true, expectedValue: 'True'},
{type: 'false value', value: false, expectedValue: 'False'},
];

for (const trueFalse of trueFalses) {
test(`can render content with ${trueFalse.type}`, async ({umbracoApi, umbracoUi}) => {
// Arrange
const templateId = await umbracoApi.template.createTemplateWithDisplayingStringValue(templateName, AliasHelper.toAlias(propertyName));
await umbracoApi.document.createPublishedDocumentWithValue(contentName, trueFalse.value, dataTypeData.id, templateId, propertyName, documentTypeName);
const contentData = await umbracoApi.document.getByName(contentName);
const contentURL = contentData.urls[0].url;

// Act
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);

// Assert
await umbracoUi.contentRender.doesContentRenderValueHaveText(trueFalse.expectedValue);
});
}

Loading