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
This commit is contained in:
Andreas Zerbst
2025-08-05 13:29:23 +02:00
committed by GitHub
parent 50eeb76c5a
commit 240e155d91
2 changed files with 186 additions and 108 deletions

View File

@@ -1,108 +1 @@
import {test} from '@umbraco/playwright-testhelpers';
import {expect} from "@playwright/test";
const relationTypeName = 'Test Relation Type';
const objectTypeName = 'Document';
let relationTypeId = '';
let objectTypeId = '';
test.beforeEach(async ({umbracoApi, umbracoUi}) => {
await umbracoApi.relationType.ensureNameNotExists(relationTypeName);
await umbracoUi.goToBackOffice();
await umbracoUi.relationType.goToSettingsTreeItem('Relation Types');
objectTypeId = await umbracoApi.objectTypes.getIdByName(objectTypeName);
});
test.afterEach(async ({umbracoApi}) => {
await umbracoApi.relationType.ensureNameNotExists(relationTypeName);
});
// Skip all tests as this feature is removed
test.skip('can create a relation type', async ({umbracoApi, umbracoUi}) => {
// Act
await umbracoUi.relationType.clickActionsMenuAtRoot();
await umbracoUi.relationType.clickCreateActionMenuOption();
await umbracoUi.relationType.enterRelationTypeName(relationTypeName);
await umbracoUi.relationType.selectParentOption(objectTypeName);
await umbracoUi.relationType.selectChildOption(objectTypeName);
await umbracoUi.relationType.clickSaveButton();
// Assert
//await umbracoUi.relationType.isSuccessNotificationVisible();
await umbracoUi.relationType.isErrorNotificationVisible(false);
expect(await umbracoApi.relationType.doesNameExist(relationTypeName)).toBeTruthy();
// TODO: when frontend is ready, verify the new relation type name is displayed in the Relation Types tree
});
test.skip('can update name of a relation type', async ({umbracoApi, umbracoUi}) => {
// Arrange
const wrongRelationTypeName = 'Updated Relation Type';
await umbracoApi.relationType.ensureNameNotExists(wrongRelationTypeName);
relationTypeId = await umbracoApi.relationType.create(wrongRelationTypeName, false, false, objectTypeId, objectTypeId);
// Act
await umbracoUi.relationType.openRelationTypeByNameAtRoot(wrongRelationTypeName);
await umbracoUi.relationType.enterRelationTypeName(relationTypeName);
await umbracoUi.relationType.clickSaveButton();
// Assert
//await umbracoUi.relationType.isSuccessNotificationVisible();
await umbracoUi.relationType.isErrorNotificationVisible(false);
const relationTypeData = await umbracoApi.relationType.get(relationTypeId);
expect(relationTypeData.name).toEqual(relationTypeName);
expect(await umbracoApi.relationType.doesNameExist(wrongRelationTypeName)).toBeFalsy();
});
test.skip('can update direction value of a relation type', async ({umbracoApi, umbracoUi}) => {
// Arrange
relationTypeId = await umbracoApi.relationType.create(relationTypeName, false, false, objectTypeId, objectTypeId);
// Act
await umbracoUi.relationType.openRelationTypeByNameAtRoot(relationTypeName);
await umbracoUi.relationType.clickBidirectionalRadioButton();
await umbracoUi.relationType.clickSaveButton();
// Assert
//await umbracoUi.relationType.isSuccessNotificationVisible();
await umbracoUi.relationType.isErrorNotificationVisible(false);
const relationTypeData = await umbracoApi.relationType.get(relationTypeId);
expect(relationTypeData.isBidirectional).toEqual(true);
});
test.skip('can update isDependency value of a relation type', async ({umbracoApi, umbracoUi}) => {
// Arrange
const updatedObjectTypeName = 'Media';
relationTypeId = await umbracoApi.relationType.create(relationTypeName, false, false, objectTypeId, objectTypeId);
// Act
await umbracoUi.relationType.openRelationTypeByNameAtRoot(relationTypeName);
await umbracoUi.relationType.clickIsDependencyToggle();
await umbracoUi.relationType.clickSaveButton();
// Assert
//await umbracoUi.relationType.isSuccessNotificationVisible();
await umbracoUi.relationType.isErrorNotificationVisible(false);
const relationTypeData = await umbracoApi.relationType.get(relationTypeId);
expect(relationTypeData.isDependency).toEqual(true);
});
test.skip('can delete a relation type', async ({umbracoApi, umbracoUi}) => {
// Arrange
await umbracoApi.relationType.create(relationTypeName, false, false, objectTypeId, objectTypeId);
// Act
await umbracoUi.relationType.clickRootFolderCaretButton();
await umbracoUi.relationType.clickActionsMenuForRelationType(relationTypeName);
await umbracoUi.relationType.clickDeleteActionMenuOption();
await umbracoUi.relationType.clickConfirmToDeleteButton();
// Assert
//await umbracoUi.relationType.isSuccessNotificationVisible();
await umbracoUi.relationType.isErrorNotificationVisible(false);
expect(await umbracoApi.relationType.doesNameExist(relationTypeName)).toBeFalsy();
// TODO: when frontend is ready, verify the deleted relation type name is NOT displayed in the Relation Types tree
});
test.skip('can show relations of a relation type', async ({umbracoApi, umbracoUi}) => {
// TODO: implement this later as the frontend is missing now
});

View File

@@ -0,0 +1,185 @@
import {test} from '@umbraco/playwright-testhelpers';
const documentTypeName = 'TestDocumentType';
const contentName = 'TestContent';
test.beforeEach(async ({umbracoUi}) => {
await umbracoUi.goToBackOffice();
await umbracoUi.relationType.goToSettingsTreeItem('Relations');
});
test.afterEach(async ({umbracoApi}) => {
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
});
const relationTypes = [
{name: 'Relate Document On Copy', parentType: 'Document', childType: 'Document', biDirectional: 'true', dependency: 'false'},
{name: 'Relate Parent Document On Delete', parentType: 'Document', childType: 'Document', biDirectional: 'false', dependency: 'false'},
{name: 'Relate Parent Media Folder On Delete', parentType: 'Media', childType: 'Media', biDirectional: 'false', dependency: 'false'},
{name: 'Related Document', parentType: '', childType: '', biDirectional: 'false', dependency: 'true'},
{name: 'Related Media', parentType: '', childType: '', biDirectional: 'false', dependency: 'true'},
{name: 'Related Member', parentType: '', childType: '', biDirectional: 'false', dependency: 'true'}
];
for (const relationType of relationTypes) {
test(`can see relation type ${relationType.name}`, async ({umbracoUi}) => {
// Act
await umbracoUi.waitForTimeout(2000);
await umbracoUi.relationType.goToRelationTypeWithName(relationType.name);
// Assert
await umbracoUi.relationType.doesParentTypeContainValue(relationType.parentType);
await umbracoUi.relationType.doesChildTypeContainValue(relationType.childType);
await umbracoUi.relationType.doesBidirectionalContainValue(relationType.biDirectional);
await umbracoUi.relationType.doesDependencyContainValue(relationType.dependency);
});
}
test('can see related document in relation type', async ({umbracoApi, umbracoUi}) => {
// Arrange
// Content Picker
const contentPickerName = 'Content Picker';
const contentPickerData = await umbracoApi.dataType.getByName(contentPickerName);
// Document Type
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, contentPickerName, contentPickerData.id);
// Content
const contentToBePickedName = 'ContentToBePicked';
const contentToBePickedId = await umbracoApi.document.createDefaultDocument(contentToBePickedName, documentTypeId);
await umbracoApi.document.createDocumentWithContentPicker(contentName, documentTypeId, contentToBePickedId);
await umbracoUi.waitForTimeout(2000);
// Act
await umbracoUi.relationType.goToRelationTypeWithName('Related Document');
// Assert
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, contentToBePickedName);
});
test('can see related media in relation type', async ({umbracoApi, umbracoUi}) => {
// Arrange
// Media Picker
const mediaPickerName = 'Media Picker';
const mediaPickerData = await umbracoApi.dataType.getByName(mediaPickerName);
// Media
const mediaName = 'TestMedia';
const mediaFileId = await umbracoApi.media.createDefaultMediaFile(mediaName);
// Document Type
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, mediaPickerName, mediaPickerData.id);
// Content
await umbracoApi.document.createDocumentWithOneMediaPicker(contentName, documentTypeId, mediaFileId);
await umbracoUi.waitForTimeout(2000);
// Act
await umbracoUi.relationType.goToRelationTypeWithName('Related Media');
// Assert
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, mediaName);
// Clean
await umbracoApi.media.ensureNameNotExists(mediaName);
});
test('can see related member in relation type', async ({umbracoApi, umbracoUi}) => {
// Arrange
// MemberPicker
const memberPickerName = 'Member Picker';
const memberPickerData = await umbracoApi.dataType.getByName(memberPickerName);
// Member
const memberTypeData = await umbracoApi.memberType.getByName('Member');
const memberName = 'TestMember';
const memberEmail = 'TestMemberEmail@test.com';
const memberId = await umbracoApi.member.createDefaultMember(memberName, memberTypeData.id, memberEmail, memberEmail, memberEmail);
// DocumentType
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, memberPickerName, memberPickerData.id);
// Content
await umbracoApi.document.createDocumentWithMemberPicker(contentName, documentTypeId, memberId);
await umbracoUi.waitForTimeout(2000);
// Act
await umbracoUi.relationType.goToRelationTypeWithName('Related Member');
// Assert
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, memberName);
// Clean
await umbracoApi.member.ensureNameNotExists(memberName);
});
test('can not see relation after content with relation is deleted', async ({umbracoApi, umbracoUi}) => {
// Arrange
// Content Picker
const contentPickerName = 'Content Picker';
const contentPickerData = await umbracoApi.dataType.getByName(contentPickerName);
// Document Type
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, contentPickerName, contentPickerData.id);
// Content
const contentToBePickedName = 'ContentToBePicked';
const contentToBePickedId = await umbracoApi.document.createDefaultDocument(contentToBePickedName, documentTypeId);
await umbracoApi.document.createDocumentWithContentPicker(contentName, documentTypeId, contentToBePickedId);
await umbracoUi.waitForTimeout(2000);
await umbracoUi.relationType.goToRelationTypeWithName('Related Document');
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, contentToBePickedName);
// Act
await umbracoApi.documentType.ensureNameNotExists(documentTypeName);
// Assert
await umbracoUi.relationType.goToSettingsTreeItem('Relations');
await umbracoUi.relationType.goToRelationTypeWithName('Related Document');
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, contentToBePickedName, false);
});
test('can not see relation after media with relation is deleted', async ({umbracoApi, umbracoUi}) => {
// Arrange
// Media Picker
const mediaPickerName = 'Media Picker';
const mediaPickerData = await umbracoApi.dataType.getByName(mediaPickerName);
// Media
const mediaName = 'TestMedia';
const mediaFileId = await umbracoApi.media.createDefaultMediaFile(mediaName);
// Document Type
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, mediaPickerName, mediaPickerData.id);
// Content
await umbracoApi.document.createDocumentWithOneMediaPicker(contentName, documentTypeId, mediaFileId);
await umbracoUi.waitForTimeout(2000);
await umbracoUi.relationType.goToRelationTypeWithName('Related Media');
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, mediaName);
// Act
await umbracoApi.media.ensureNameNotExists(mediaName);
// Assert
await umbracoUi.relationType.goToSettingsTreeItem('Relations');
await umbracoUi.relationType.goToRelationTypeWithName('Related Media');
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, mediaName, false);
});
test('can not see relation after member with relation is deleted', async ({umbracoApi, umbracoUi}) => {
// Arrange
// MemberPicker
const memberPickerName = 'Member Picker';
const memberPickerData = await umbracoApi.dataType.getByName(memberPickerName);
// Member
const memberTypeData = await umbracoApi.memberType.getByName('Member');
const memberName = 'TestMember';
const memberEmail = 'TestMemberEmail@test.com';
const memberId = await umbracoApi.member.createDefaultMember(memberName, memberTypeData.id, memberEmail, memberEmail, memberEmail);
// DocumentType
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, memberPickerName, memberPickerData.id);
// Content
await umbracoApi.document.createDocumentWithMemberPicker(contentName, documentTypeId, memberId);
await umbracoUi.waitForTimeout(2000);
await umbracoUi.relationType.goToRelationTypeWithName('Related Member');
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, memberName);
// Act
await umbracoApi.member.ensureNameNotExists(memberName);
// Assert
await umbracoUi.relationType.goToSettingsTreeItem('Relations');
await umbracoUi.relationType.goToRelationTypeWithName('Related Member');
await umbracoUi.relationType.isRelationWithParentAndChildVisible(contentName, memberName, false);
});