Skip to content

Commit 240e155

Browse files
authored
16 QA added relation type tests (#19490)
* Updated relation type tests * Created tests * Bumped version * Fixed tests * Fixed tests * Fixes based on comments * Added waits to figure out why tests fail on pipeline * Added a reload to check if test passes on pipeline * Added reloads * Removed reload page * Reverted smokeTest command
1 parent 50eeb76 commit 240e155

File tree

2 files changed

+186
-108
lines changed

2 files changed

+186
-108
lines changed
Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1 @@
1-
import {test} from '@umbraco/playwright-testhelpers';
2-
import {expect} from "@playwright/test";
3-
4-
const relationTypeName = 'Test Relation Type';
5-
const objectTypeName = 'Document';
6-
let relationTypeId = '';
7-
let objectTypeId = '';
8-
9-
test.beforeEach(async ({umbracoApi, umbracoUi}) => {
10-
await umbracoApi.relationType.ensureNameNotExists(relationTypeName);
11-
await umbracoUi.goToBackOffice();
12-
await umbracoUi.relationType.goToSettingsTreeItem('Relation Types');
13-
objectTypeId = await umbracoApi.objectTypes.getIdByName(objectTypeName);
14-
});
15-
16-
test.afterEach(async ({umbracoApi}) => {
17-
await umbracoApi.relationType.ensureNameNotExists(relationTypeName);
18-
});
19-
20-
// Skip all tests as this feature is removed
21-
test.skip('can create a relation type', async ({umbracoApi, umbracoUi}) => {
22-
// Act
23-
await umbracoUi.relationType.clickActionsMenuAtRoot();
24-
await umbracoUi.relationType.clickCreateActionMenuOption();
25-
await umbracoUi.relationType.enterRelationTypeName(relationTypeName);
26-
await umbracoUi.relationType.selectParentOption(objectTypeName);
27-
await umbracoUi.relationType.selectChildOption(objectTypeName);
28-
await umbracoUi.relationType.clickSaveButton();
29-
30-
// Assert
31-
//await umbracoUi.relationType.isSuccessNotificationVisible();
32-
await umbracoUi.relationType.isErrorNotificationVisible(false);
33-
expect(await umbracoApi.relationType.doesNameExist(relationTypeName)).toBeTruthy();
34-
// TODO: when frontend is ready, verify the new relation type name is displayed in the Relation Types tree
35-
});
36-
37-
test.skip('can update name of a relation type', async ({umbracoApi, umbracoUi}) => {
38-
// Arrange
39-
const wrongRelationTypeName = 'Updated Relation Type';
40-
await umbracoApi.relationType.ensureNameNotExists(wrongRelationTypeName);
41-
relationTypeId = await umbracoApi.relationType.create(wrongRelationTypeName, false, false, objectTypeId, objectTypeId);
42-
43-
// Act
44-
await umbracoUi.relationType.openRelationTypeByNameAtRoot(wrongRelationTypeName);
45-
await umbracoUi.relationType.enterRelationTypeName(relationTypeName);
46-
await umbracoUi.relationType.clickSaveButton();
47-
48-
// Assert
49-
//await umbracoUi.relationType.isSuccessNotificationVisible();
50-
await umbracoUi.relationType.isErrorNotificationVisible(false);
51-
const relationTypeData = await umbracoApi.relationType.get(relationTypeId);
52-
expect(relationTypeData.name).toEqual(relationTypeName);
53-
expect(await umbracoApi.relationType.doesNameExist(wrongRelationTypeName)).toBeFalsy();
54-
});
55-
56-
test.skip('can update direction value of a relation type', async ({umbracoApi, umbracoUi}) => {
57-
// Arrange
58-
relationTypeId = await umbracoApi.relationType.create(relationTypeName, false, false, objectTypeId, objectTypeId);
59-
60-
// Act
61-
await umbracoUi.relationType.openRelationTypeByNameAtRoot(relationTypeName);
62-
await umbracoUi.relationType.clickBidirectionalRadioButton();
63-
await umbracoUi.relationType.clickSaveButton();
64-
65-
// Assert
66-
//await umbracoUi.relationType.isSuccessNotificationVisible();
67-
await umbracoUi.relationType.isErrorNotificationVisible(false);
68-
const relationTypeData = await umbracoApi.relationType.get(relationTypeId);
69-
expect(relationTypeData.isBidirectional).toEqual(true);
70-
});
71-
72-
test.skip('can update isDependency value of a relation type', async ({umbracoApi, umbracoUi}) => {
73-
// Arrange
74-
const updatedObjectTypeName = 'Media';
75-
relationTypeId = await umbracoApi.relationType.create(relationTypeName, false, false, objectTypeId, objectTypeId);
76-
77-
// Act
78-
await umbracoUi.relationType.openRelationTypeByNameAtRoot(relationTypeName);
79-
await umbracoUi.relationType.clickIsDependencyToggle();
80-
await umbracoUi.relationType.clickSaveButton();
81-
82-
// Assert
83-
//await umbracoUi.relationType.isSuccessNotificationVisible();
84-
await umbracoUi.relationType.isErrorNotificationVisible(false);
85-
const relationTypeData = await umbracoApi.relationType.get(relationTypeId);
86-
expect(relationTypeData.isDependency).toEqual(true);
87-
});
88-
89-
test.skip('can delete a relation type', async ({umbracoApi, umbracoUi}) => {
90-
// Arrange
91-
await umbracoApi.relationType.create(relationTypeName, false, false, objectTypeId, objectTypeId);
92-
93-
// Act
94-
await umbracoUi.relationType.clickRootFolderCaretButton();
95-
await umbracoUi.relationType.clickActionsMenuForRelationType(relationTypeName);
96-
await umbracoUi.relationType.clickDeleteActionMenuOption();
97-
await umbracoUi.relationType.clickConfirmToDeleteButton();
98-
99-
// Assert
100-
//await umbracoUi.relationType.isSuccessNotificationVisible();
101-
await umbracoUi.relationType.isErrorNotificationVisible(false);
102-
expect(await umbracoApi.relationType.doesNameExist(relationTypeName)).toBeFalsy();
103-
// TODO: when frontend is ready, verify the deleted relation type name is NOT displayed in the Relation Types tree
104-
});
105-
106-
test.skip('can show relations of a relation type', async ({umbracoApi, umbracoUi}) => {
107-
// TODO: implement this later as the frontend is missing now
108-
});
1+

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
import {test} from '@umbraco/playwright-testhelpers';
2+
3+
const documentTypeName = 'TestDocumentType';
4+
const contentName = 'TestContent';
5+
6+
test.beforeEach(async ({umbracoUi}) => {
7+
await umbracoUi.goToBackOffice();
8+
await umbracoUi.relationType.goToSettingsTreeItem('Relations');
9+
});
10+
11+
test.afterEach(async ({umbracoApi}) => {
12+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
13+
});
14+
15+
const relationTypes = [
16+
{name: 'Relate Document On Copy', parentType: 'Document', childType: 'Document', biDirectional: 'true', dependency: 'false'},
17+
{name: 'Relate Parent Document On Delete', parentType: 'Document', childType: 'Document', biDirectional: 'false', dependency: 'false'},
18+
{name: 'Relate Parent Media Folder On Delete', parentType: 'Media', childType: 'Media', biDirectional: 'false', dependency: 'false'},
19+
{name: 'Related Document', parentType: '', childType: '', biDirectional: 'false', dependency: 'true'},
20+
{name: 'Related Media', parentType: '', childType: '', biDirectional: 'false', dependency: 'true'},
21+
{name: 'Related Member', parentType: '', childType: '', biDirectional: 'false', dependency: 'true'}
22+
];
23+
24+
for (const relationType of relationTypes) {
25+
test(`can see relation type ${relationType.name}`, async ({umbracoUi}) => {
26+
// Act
27+
await umbracoUi.waitForTimeout(2000);
28+
await umbracoUi.relationType.goToRelationTypeWithName(relationType.name);
29+
30+
// Assert
31+
await umbracoUi.relationType.doesParentTypeContainValue(relationType.parentType);
32+
await umbracoUi.relationType.doesChildTypeContainValue(relationType.childType);
33+
await umbracoUi.relationType.doesBidirectionalContainValue(relationType.biDirectional);
34+
await umbracoUi.relationType.doesDependencyContainValue(relationType.dependency);
35+
});
36+
}
37+
38+
test('can see related document in relation type', async ({umbracoApi, umbracoUi}) => {
39+
// Arrange
40+
// Content Picker
41+
const contentPickerName = 'Content Picker';
42+
const contentPickerData = await umbracoApi.dataType.getByName(contentPickerName);
43+
// Document Type
44+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, contentPickerName, contentPickerData.id);
45+
// Content
46+
const contentToBePickedName = 'ContentToBePicked';
47+
const contentToBePickedId = await umbracoApi.document.createDefaultDocument(contentToBePickedName, documentTypeId);
48+
await umbracoApi.document.createDocumentWithContentPicker(contentName, documentTypeId, contentToBePickedId);
49+
await umbracoUi.waitForTimeout(2000);
50+
51+
// Act
52+
await umbracoUi.relationType.goToRelationTypeWithName('Related Document');
53+
54+
// Assert
55+
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, contentToBePickedName);
56+
});
57+
58+
test('can see related media in relation type', async ({umbracoApi, umbracoUi}) => {
59+
// Arrange
60+
// Media Picker
61+
const mediaPickerName = 'Media Picker';
62+
const mediaPickerData = await umbracoApi.dataType.getByName(mediaPickerName);
63+
// Media
64+
const mediaName = 'TestMedia';
65+
const mediaFileId = await umbracoApi.media.createDefaultMediaFile(mediaName);
66+
// Document Type
67+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, mediaPickerName, mediaPickerData.id);
68+
// Content
69+
await umbracoApi.document.createDocumentWithOneMediaPicker(contentName, documentTypeId, mediaFileId);
70+
await umbracoUi.waitForTimeout(2000);
71+
72+
// Act
73+
await umbracoUi.relationType.goToRelationTypeWithName('Related Media');
74+
75+
// Assert
76+
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, mediaName);
77+
78+
// Clean
79+
await umbracoApi.media.ensureNameNotExists(mediaName);
80+
});
81+
82+
test('can see related member in relation type', async ({umbracoApi, umbracoUi}) => {
83+
// Arrange
84+
// MemberPicker
85+
const memberPickerName = 'Member Picker';
86+
const memberPickerData = await umbracoApi.dataType.getByName(memberPickerName);
87+
// Member
88+
const memberTypeData = await umbracoApi.memberType.getByName('Member');
89+
const memberName = 'TestMember';
90+
const memberEmail = '[email protected]';
91+
const memberId = await umbracoApi.member.createDefaultMember(memberName, memberTypeData.id, memberEmail, memberEmail, memberEmail);
92+
// DocumentType
93+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, memberPickerName, memberPickerData.id);
94+
// Content
95+
await umbracoApi.document.createDocumentWithMemberPicker(contentName, documentTypeId, memberId);
96+
await umbracoUi.waitForTimeout(2000);
97+
98+
// Act
99+
await umbracoUi.relationType.goToRelationTypeWithName('Related Member');
100+
101+
// Assert
102+
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, memberName);
103+
104+
// Clean
105+
await umbracoApi.member.ensureNameNotExists(memberName);
106+
});
107+
108+
test('can not see relation after content with relation is deleted', async ({umbracoApi, umbracoUi}) => {
109+
// Arrange
110+
// Content Picker
111+
const contentPickerName = 'Content Picker';
112+
const contentPickerData = await umbracoApi.dataType.getByName(contentPickerName);
113+
// Document Type
114+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, contentPickerName, contentPickerData.id);
115+
// Content
116+
const contentToBePickedName = 'ContentToBePicked';
117+
const contentToBePickedId = await umbracoApi.document.createDefaultDocument(contentToBePickedName, documentTypeId);
118+
await umbracoApi.document.createDocumentWithContentPicker(contentName, documentTypeId, contentToBePickedId);
119+
await umbracoUi.waitForTimeout(2000);
120+
121+
await umbracoUi.relationType.goToRelationTypeWithName('Related Document');
122+
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, contentToBePickedName);
123+
124+
// Act
125+
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
126+
127+
// Assert
128+
await umbracoUi.relationType.goToSettingsTreeItem('Relations');
129+
await umbracoUi.relationType.goToRelationTypeWithName('Related Document');
130+
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, contentToBePickedName, false);
131+
});
132+
133+
test('can not see relation after media with relation is deleted', async ({umbracoApi, umbracoUi}) => {
134+
// Arrange
135+
// Media Picker
136+
const mediaPickerName = 'Media Picker';
137+
const mediaPickerData = await umbracoApi.dataType.getByName(mediaPickerName);
138+
// Media
139+
const mediaName = 'TestMedia';
140+
const mediaFileId = await umbracoApi.media.createDefaultMediaFile(mediaName);
141+
// Document Type
142+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, mediaPickerName, mediaPickerData.id);
143+
// Content
144+
await umbracoApi.document.createDocumentWithOneMediaPicker(contentName, documentTypeId, mediaFileId);
145+
await umbracoUi.waitForTimeout(2000);
146+
147+
await umbracoUi.relationType.goToRelationTypeWithName('Related Media');
148+
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, mediaName);
149+
150+
// Act
151+
await umbracoApi.media.ensureNameNotExists(mediaName);
152+
153+
// Assert
154+
await umbracoUi.relationType.goToSettingsTreeItem('Relations');
155+
await umbracoUi.relationType.goToRelationTypeWithName('Related Media');
156+
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, mediaName, false);
157+
});
158+
159+
test('can not see relation after member with relation is deleted', async ({umbracoApi, umbracoUi}) => {
160+
// Arrange
161+
// MemberPicker
162+
const memberPickerName = 'Member Picker';
163+
const memberPickerData = await umbracoApi.dataType.getByName(memberPickerName);
164+
// Member
165+
const memberTypeData = await umbracoApi.memberType.getByName('Member');
166+
const memberName = 'TestMember';
167+
const memberEmail = '[email protected]';
168+
const memberId = await umbracoApi.member.createDefaultMember(memberName, memberTypeData.id, memberEmail, memberEmail, memberEmail);
169+
// DocumentType
170+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, memberPickerName, memberPickerData.id);
171+
// Content
172+
await umbracoApi.document.createDocumentWithMemberPicker(contentName, documentTypeId, memberId);
173+
await umbracoUi.waitForTimeout(2000);
174+
175+
await umbracoUi.relationType.goToRelationTypeWithName('Related Member');
176+
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, memberName);
177+
178+
// Act
179+
await umbracoApi.member.ensureNameNotExists(memberName);
180+
181+
// Assert
182+
await umbracoUi.relationType.goToSettingsTreeItem('Relations');
183+
await umbracoUi.relationType.goToRelationTypeWithName('Related Member');
184+
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, memberName, false);
185+
});

0 commit comments

Comments
 (0)