Skip to content

Commit

Permalink
V15 QA Updated acceptance tests for Link Picker (#18231)
Browse files Browse the repository at this point in the history
* Added tests to ensure that the empty link is not accepted in url picker

* Added tests to ensure that the empty link is not accepted in tiptap

* Updated link picker tests due to UX changes

* Cleaned up

* Make Content tests run in the pipeline

* Added tests for unpublished document

* Fixed comments

* Bumped version

* Cleaned up

* Updated test name

* Reverted

* Bumped version
  • Loading branch information
nhudinh0309 authored Feb 10, 2025
1 parent 8f6d1bc commit 978a068
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 5 deletions.
8 changes: 4 additions & 4 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.

2 changes: 1 addition & 1 deletion tests/Umbraco.Tests.AcceptanceTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"dependencies": {
"@umbraco/json-models-builders": "^2.0.27",
"@umbraco/playwright-testhelpers": "^15.0.16",
"@umbraco/playwright-testhelpers": "^15.0.17",
"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
Expand Up @@ -264,3 +264,134 @@ test('can edit the URL picker in the content', async ({umbracoApi, umbracoUi}) =
expect(contentData.values[0].value[0].name).toEqual(updatedLinkTitle);
expect(contentData.values[0].value[0].url).toEqual(link);
});

test('cannot submit an empty link', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickAddMultiURLPickerButton();
await umbracoUi.content.clickManualLinkButton();
await umbracoUi.content.enterLink('');
await umbracoUi.content.enterAnchorOrQuerystring('');
await umbracoUi.content.enterLinkTitle('');
await umbracoUi.content.clickAddButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

test('cannot update the URL picker with an empty link', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.document.createDocumentWithExternalLinkURLPicker(contentName, documentTypeId, link, linkTitle);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickLinkWithName(linkTitle);
await umbracoUi.content.enterLink('');
await umbracoUi.content.enterAnchorOrQuerystring('');
await umbracoUi.content.enterLinkTitle('');
await umbracoUi.content.clickUpdateButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

// TODO: Remove skip when the front-end ready. Currently it still accept the empty link with an anchor or querystring
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
test.skip('cannot submit an empty URL with an anchor or query', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickAddMultiURLPickerButton();
await umbracoUi.content.clickManualLinkButton();
await umbracoUi.content.enterLink('');
await umbracoUi.content.enterAnchorOrQuerystring('#value');
await umbracoUi.content.clickAddButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

// TODO: Remove skip when the front-end ready. Currently it still accept the empty link using spacebar
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
test.skip('cannot submit an empty link using spacebar', async ({umbracoApi, umbracoUi}) => {
// Arrange
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickAddMultiURLPickerButton();
await umbracoUi.content.clickManualLinkButton();
await umbracoUi.content.enterLink('Space', true);
await umbracoUi.content.enterAnchorOrQuerystring('Space', true);
await umbracoUi.content.enterLinkTitle('Space', true);
await umbracoUi.content.clickAddButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

// TODO: Remove skip when the front-end ready. Currently it is impossible to link to unpublished document
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17974
test.skip('can create content with the link to an unpublished document', async ({umbracoApi, umbracoUi}) => {
// Arrange
const expectedState = 'Draft';
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
// Create a document to link
const documentTypeForLinkedDocumentName = 'TestDocumentType';
const documentTypeForLinkedDocumentId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeForLinkedDocumentName);
const linkedDocumentName = 'LinkedDocument';
const linkedDocumentId = await umbracoApi.document.createDefaultDocument(linkedDocumentName, documentTypeForLinkedDocumentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.clickActionsMenuAtRoot();
await umbracoUi.content.clickCreateButton();
await umbracoUi.content.chooseDocumentType(documentTypeName);
await umbracoUi.content.enterContentName(contentName);
await umbracoUi.content.clickAddMultiURLPickerButton();
await umbracoUi.content.clickDocumentLinkButton();
await umbracoUi.content.selectLinkByName(linkedDocumentName);
await umbracoUi.content.clickButtonWithName('Choose');
await umbracoUi.content.clickAddButton();
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
const contentData = await umbracoApi.document.getByName(contentName);
expect(contentData.variants[0].state).toBe(expectedState);
expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(dataTypeName));
expect(contentData.values[0].value.length).toBe(1);
expect(contentData.values[0].value[0].type).toEqual('document');
expect(contentData.values[0].value[0].icon).toEqual('icon-document');
expect(contentData.values[0].value[0].target).toBeNull();
expect(contentData.values[0].value[0].unique).toEqual(linkedDocumentId);
expect(contentData.values[0].value[0].name).toEqual(linkedDocumentName);

// Clean
await umbracoApi.documentType.ensureNameNotExists(documentTypeForLinkedDocumentName);
await umbracoApi.document.ensureNameNotExists(linkedDocumentName);
});
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,78 @@ test('can add a video in RTE Tiptap property editor', async ({umbracoApi, umbrac
expect(contentData.values[0].value.markup).toContain('data-embed-url');
expect(contentData.values[0].value.markup).toContain(videoURL);
});

test('cannot submit an empty link in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Link';
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.clickManualLinkButton();
await umbracoUi.content.enterLink('');
await umbracoUi.content.enterAnchorOrQuerystring('');
await umbracoUi.content.enterLinkTitle('');
await umbracoUi.content.clickAddButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

// TODO: Remove skip when the front-end ready. Currently it still accept the empty link with an anchor or querystring
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
test.skip('cannot submit an empty URL with an anchor or querystring in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Link';
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.clickManualLinkButton();
await umbracoUi.content.enterLink('');
await umbracoUi.content.enterAnchorOrQuerystring('#value');
await umbracoUi.content.clickAddButton();

// Assert
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
});

// TODO: Remove skip when the front-end ready. Currently it is impossible to link to unpublished document
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17974
test.skip('can insert a link to an unpublished document in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
// Arrange
const iconTitle = 'Link';
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
// Create a document to link
const documentTypeForLinkedDocumentName = 'TestDocumentType';
const documentTypeForLinkedDocumentId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeForLinkedDocumentName);
const linkedDocumentName = 'LinkedDocument';
await umbracoApi.document.createDefaultDocument(linkedDocumentName, documentTypeForLinkedDocumentId);
await umbracoUi.goToBackOffice();
await umbracoUi.content.goToSection(ConstantHelper.sections.content);

// Act
await umbracoUi.content.goToContentWithName(contentName);
await umbracoUi.content.clickTipTapToolbarIconWithTitle(iconTitle);
await umbracoUi.content.clickDocumentLinkButton();
await umbracoUi.content.selectLinkByName(linkedDocumentName);
await umbracoUi.content.clickButtonWithName('Choose');
await umbracoUi.content.clickAddButton();
await umbracoUi.content.clickSaveButton();

// Assert
await umbracoUi.content.isSuccessNotificationVisible();

// Clean
await umbracoApi.documentType.ensureNameNotExists(documentTypeForLinkedDocumentName);
await umbracoApi.document.ensureNameNotExists(linkedDocumentName);
});

0 comments on commit 978a068

Please sign in to comment.