Skip to content

Commit dc2dc09

Browse files
V15 QA Added tests for rendering content with member picker, multi url picker and media picker (#17717)
* Added test for rendering content with member picker value * Added tests for rendering content with multiple media picker * Added tests for rendering content with multi url picker * Bumped version * Updated tests for member picker * Make all rendering content tests run in the pipeline * Bumped version * Fixed indentation * Added clean for media * Reverted --------- Co-authored-by: Andreas Zerbst <[email protected]> Co-authored-by: Andreas Zerbst <[email protected]>
1 parent 6f08178 commit dc2dc09

File tree

6 files changed

+217
-7
lines changed

6 files changed

+217
-7
lines changed

build/azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ stages:
493493
matrix:
494494
LinuxPart1Of3:
495495
vmImage: "ubuntu-latest"
496-
testCommand: 'npx playwright test DefaultConfig --grep "@smoke"--shard=1/3'
496+
testCommand: 'npx playwright test DefaultConfig --grep "@smoke" --shard=1/3'
497497
LinuxPart2Of3:
498498
vmImage: "ubuntu-latest"
499499
testCommand: 'npx playwright test DefaultConfig --grep "@smoke" --shard=2/3'

tests/Umbraco.Tests.AcceptanceTest/package-lock.json

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Umbraco.Tests.AcceptanceTest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"dependencies": {
2323
"@umbraco/json-models-builders": "^2.0.26",
24-
"@umbraco/playwright-testhelpers": "^15.0.5",
24+
"@umbraco/playwright-testhelpers": "^15.0.6",
2525
"camelize": "^1.0.0",
2626
"dotenv": "^16.3.1",
2727
"node-fetch": "^2.6.7"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';
2+
3+
const contentName = 'Test Rendering Content';
4+
const documentTypeName = 'TestDocumentTypeForContent';
5+
const dataTypeName = 'Member Picker';
6+
const templateName = 'TestTemplateForContent';
7+
const propertyName = 'Test Member Picker';
8+
let dataTypeData = null;
9+
const memberName = 'Test Member';
10+
const memberTypeName = 'Test Member Type';
11+
const username = 'testmember';
12+
const email = '[email protected]';
13+
const password = '0123456789';
14+
15+
test.beforeEach(async ({umbracoApi}) => {
16+
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
17+
});
18+
19+
test.afterEach(async ({umbracoApi}) => {
20+
await umbracoApi.document.ensureNameNotExists(contentName);
21+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
22+
await umbracoApi.template.ensureNameNotExists(templateName);
23+
});
24+
25+
test('can render content with member picker value', async ({umbracoApi, umbracoUi}) => {
26+
// Arrange
27+
// Create member
28+
await umbracoApi.memberType.ensureNameNotExists(memberTypeName);
29+
const memberTypeId = await umbracoApi.memberType.createDefaultMemberType(memberTypeName);
30+
const memberId = await umbracoApi.member.createDefaultMember(memberName, memberTypeId, email, username, password);
31+
const templateId = await umbracoApi.template.createTemplateWithDisplayingMemberPickerValue(templateName, AliasHelper.toAlias(propertyName));
32+
await umbracoApi.document.createPublishedDocumentWithValue(contentName, memberId, dataTypeData.id, templateId, propertyName, documentTypeName);
33+
const contentData = await umbracoApi.document.getByName(contentName);
34+
const contentURL = contentData.urls[0].url;
35+
36+
// Act
37+
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);
38+
39+
// Assert
40+
await umbracoUi.contentRender.doesContentRenderValueContainText(memberName);
41+
});
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';
2+
3+
const contentName = 'Test Rendering Content';
4+
const documentTypeName = 'TestDocumentTypeForContent';
5+
const dataTypeName = 'Multi URL Picker';
6+
const templateName = 'TestTemplateForContent';
7+
const propertyName = 'Test Member Picker';
8+
let dataTypeData = null;
9+
10+
test.beforeEach(async ({umbracoApi}) => {
11+
dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
12+
});
13+
14+
test.afterEach(async ({umbracoApi}) => {
15+
await umbracoApi.document.ensureNameNotExists(contentName);
16+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
17+
await umbracoApi.template.ensureNameNotExists(templateName);
18+
});
19+
20+
test('can render content with document link value', async ({umbracoApi, umbracoUi}) => {
21+
// Arrange
22+
// Create a document to link
23+
const documentTypeForLinkedDocumentName = 'TestDocumentType';
24+
const documentTypeForLinkedDocumentId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeForLinkedDocumentName);
25+
const linkedDocumentName = 'LinkedDocument';
26+
const linkedDocumentId = await umbracoApi.document.createDefaultDocument(linkedDocumentName, documentTypeForLinkedDocumentId);
27+
await umbracoApi.document.publish(linkedDocumentId);
28+
// Create a published document with document link value
29+
const templateId = await umbracoApi.template.createTemplateWithDisplayingMultiURLPickerValue(templateName, AliasHelper.toAlias(propertyName));
30+
await umbracoApi.document.createPublishedDocumentWithDocumentLinkURLPicker(contentName, linkedDocumentName, linkedDocumentId, dataTypeData.id, templateId, propertyName, documentTypeName);
31+
const contentData = await umbracoApi.document.getByName(contentName);
32+
const contentURL = contentData.urls[0].url;
33+
34+
// Act
35+
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);
36+
37+
// Assert
38+
await umbracoUi.contentRender.doesContentRenderValueContainText(linkedDocumentName);
39+
40+
// Clean
41+
await umbracoApi.document.ensureNameNotExists(linkedDocumentName);
42+
await umbracoApi.documentType.ensureNameNotExists(documentTypeForLinkedDocumentName);
43+
});
44+
45+
test('can render content with media link value', async ({umbracoApi, umbracoUi}) => {
46+
// Arrange
47+
// Create a media to pick
48+
const mediaFileName = 'TestMediaFileForContent';
49+
await umbracoApi.media.ensureNameNotExists(mediaFileName);
50+
const mediaFileId = await umbracoApi.media.createDefaultMediaWithImage(mediaFileName);
51+
// Create a published document with media link value
52+
const templateId = await umbracoApi.template.createTemplateWithDisplayingMultiURLPickerValue(templateName, AliasHelper.toAlias(propertyName));
53+
await umbracoApi.document.createPublishedDocumentWithImageLinkURLPicker(contentName, mediaFileName, mediaFileId, dataTypeData.id, templateId, propertyName, documentTypeName);
54+
const contentData = await umbracoApi.document.getByName(contentName);
55+
const contentURL = contentData.urls[0].url;
56+
57+
// Act
58+
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);
59+
60+
// Assert
61+
await umbracoUi.contentRender.doesContentRenderValueContainText(mediaFileName);
62+
63+
// Clean
64+
await umbracoApi.media.ensureNameNotExists(mediaFileName);
65+
});
66+
67+
test('can render content with external link value', async ({umbracoApi, umbracoUi}) => {
68+
// Arrange
69+
const linkUrl = 'https://docs.umbraco.com';
70+
const linkTitle = 'Umbraco Documentation';
71+
// Create a published document with external link value
72+
const templateId = await umbracoApi.template.createTemplateWithDisplayingMultiURLPickerValue(templateName, AliasHelper.toAlias(propertyName));
73+
await umbracoApi.document.createPublishedDocumentWithExternalLinkURLPicker(contentName, linkTitle, linkUrl, dataTypeData.id, templateId, propertyName, documentTypeName);
74+
const contentData = await umbracoApi.document.getByName(contentName);
75+
const contentURL = contentData.urls[0].url;
76+
77+
// Act
78+
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);
79+
80+
// Assert
81+
await umbracoUi.contentRender.doesContentRenderValueContainText(linkTitle);
82+
});
83+
84+
test('can render content with multiple url value', async ({umbracoApi, umbracoUi}) => {
85+
// Arrange
86+
const linkUrl = 'https://docs.umbraco.com';
87+
const linkTitle = 'Umbraco Documentation';
88+
// Create a media to pick
89+
const mediaFileName = 'TestMediaFileForContent';
90+
await umbracoApi.media.ensureNameNotExists(mediaFileName);
91+
const mediaFileId = await umbracoApi.media.createDefaultMediaWithImage(mediaFileName);
92+
// Create a published document with external link value and image url value
93+
const templateId = await umbracoApi.template.createTemplateWithDisplayingMultiURLPickerValue(templateName, AliasHelper.toAlias(propertyName));
94+
await umbracoApi.document.createPublishedDocumentWithImageLinkAndExternalLink(contentName, mediaFileName, mediaFileId, linkTitle, linkUrl, dataTypeData.id, templateId, propertyName, documentTypeName);
95+
const contentData = await umbracoApi.document.getByName(contentName);
96+
const contentURL = contentData.urls[0].url;
97+
98+
// Act
99+
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);
100+
101+
// Assert
102+
await umbracoUi.contentRender.doesContentRenderValueContainText(linkTitle);
103+
await umbracoUi.contentRender.doesContentRenderValueContainText(mediaFileName);
104+
105+
// Clean
106+
await umbracoApi.media.ensureNameNotExists(mediaFileName);
107+
});
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import {AliasHelper, test} from '@umbraco/playwright-testhelpers';
2+
3+
const contentName = 'Test Rendering Content';
4+
const documentTypeName = 'TestDocumentTypeForContent';
5+
const templateName = 'TestTemplateForContent';
6+
const propertyName = 'Test Multiple Media Picker';
7+
const firstMediaFileName = 'TestFirstMedia';
8+
const secondMediaFileName = 'TestSecondMedia';
9+
10+
test.beforeEach(async ({umbracoApi}) => {
11+
await umbracoApi.media.ensureNameNotExists(firstMediaFileName);
12+
await umbracoApi.media.ensureNameNotExists(secondMediaFileName);
13+
});
14+
15+
test.afterEach(async ({umbracoApi}) => {
16+
await umbracoApi.document.ensureNameNotExists(contentName);
17+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
18+
await umbracoApi.template.ensureNameNotExists(templateName);
19+
await umbracoApi.media.ensureNameNotExists(firstMediaFileName);
20+
await umbracoApi.media.ensureNameNotExists(secondMediaFileName);
21+
});
22+
23+
test('can render content with multiple media picker value', async ({umbracoApi, umbracoUi}) => {
24+
// Arrange
25+
const dataTypeName = 'Multiple Media Picker';
26+
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
27+
// Create multiple images
28+
const firstMediaFileId = await umbracoApi.media.createDefaultMediaFile(firstMediaFileName);
29+
const secondMediaFileId = await umbracoApi.media.createDefaultMediaWithArticle(secondMediaFileName);
30+
// Create a published document with multiple media picker value
31+
const templateId = await umbracoApi.template.createTemplateWithDisplayingMultipleMediaPickerValue(templateName, AliasHelper.toAlias(propertyName));
32+
await umbracoApi.document.createPublishedDocumentWithTwoMediaPicker(contentName, firstMediaFileId, secondMediaFileId, dataTypeData.id, templateId, propertyName, documentTypeName);
33+
const contentData = await umbracoApi.document.getByName(contentName);
34+
const contentURL = contentData.urls[0].url;
35+
36+
// Act
37+
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);
38+
39+
// Assert
40+
await umbracoUi.contentRender.doesContentRenderValueContainText(firstMediaFileName);
41+
await umbracoUi.contentRender.doesContentRenderValueContainText(secondMediaFileName);
42+
});
43+
44+
test('can render content with multiple image media picker value', async ({umbracoApi, umbracoUi}) => {
45+
// Arrange
46+
const dataTypeName = 'Multiple Image Media Picker';
47+
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
48+
// Create multiple images
49+
const firstMediaFileId = await umbracoApi.media.createDefaultMediaWithImage(firstMediaFileName);
50+
const secondMediaFileId = await umbracoApi.media.createDefaultMediaWithImage(secondMediaFileName);
51+
// Create a published document with multiple image media picker value
52+
const templateId = await umbracoApi.template.createTemplateWithDisplayingMultipleMediaPickerValue(templateName, AliasHelper.toAlias(propertyName));
53+
await umbracoApi.document.createPublishedDocumentWithTwoMediaPicker(contentName, firstMediaFileId, secondMediaFileId, dataTypeData.id, templateId, propertyName, documentTypeName);
54+
const contentData = await umbracoApi.document.getByName(contentName);
55+
const contentURL = contentData.urls[0].url;
56+
57+
// Act
58+
await umbracoUi.contentRender.navigateToRenderedContentPage(contentURL);
59+
60+
// Assert
61+
await umbracoUi.contentRender.doesContentRenderValueContainText(firstMediaFileName);
62+
await umbracoUi.contentRender.doesContentRenderValueContainText(secondMediaFileName);
63+
});

0 commit comments

Comments
 (0)