Skip to content

Commit 978a068

Browse files
authored
V15 QA Updated acceptance tests for Link Picker (#18231)
* 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
1 parent 8f6d1bc commit 978a068

File tree

4 files changed

+211
-5
lines changed

4 files changed

+211
-5
lines changed

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

Lines changed: 4 additions & 4 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.27",
24-
"@umbraco/playwright-testhelpers": "^15.0.16",
24+
"@umbraco/playwright-testhelpers": "^15.0.17",
2525
"camelize": "^1.0.0",
2626
"dotenv": "^16.3.1",
2727
"node-fetch": "^2.6.7"

tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithMultiURLPicker.spec.ts

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,134 @@ test('can edit the URL picker in the content', async ({umbracoApi, umbracoUi}) =
264264
expect(contentData.values[0].value[0].name).toEqual(updatedLinkTitle);
265265
expect(contentData.values[0].value[0].url).toEqual(link);
266266
});
267+
268+
test('cannot submit an empty link', async ({umbracoApi, umbracoUi}) => {
269+
// Arrange
270+
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
271+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
272+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
273+
await umbracoUi.goToBackOffice();
274+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
275+
276+
// Act
277+
await umbracoUi.content.goToContentWithName(contentName);
278+
await umbracoUi.content.clickAddMultiURLPickerButton();
279+
await umbracoUi.content.clickManualLinkButton();
280+
await umbracoUi.content.enterLink('');
281+
await umbracoUi.content.enterAnchorOrQuerystring('');
282+
await umbracoUi.content.enterLinkTitle('');
283+
await umbracoUi.content.clickAddButton();
284+
285+
// Assert
286+
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
287+
});
288+
289+
test('cannot update the URL picker with an empty link', async ({umbracoApi, umbracoUi}) => {
290+
// Arrange
291+
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
292+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
293+
await umbracoApi.document.createDocumentWithExternalLinkURLPicker(contentName, documentTypeId, link, linkTitle);
294+
await umbracoUi.goToBackOffice();
295+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
296+
297+
// Act
298+
await umbracoUi.content.goToContentWithName(contentName);
299+
await umbracoUi.content.clickLinkWithName(linkTitle);
300+
await umbracoUi.content.enterLink('');
301+
await umbracoUi.content.enterAnchorOrQuerystring('');
302+
await umbracoUi.content.enterLinkTitle('');
303+
await umbracoUi.content.clickUpdateButton();
304+
305+
// Assert
306+
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
307+
});
308+
309+
// TODO: Remove skip when the front-end ready. Currently it still accept the empty link with an anchor or querystring
310+
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
311+
test.skip('cannot submit an empty URL with an anchor or query', async ({umbracoApi, umbracoUi}) => {
312+
// Arrange
313+
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
314+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
315+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
316+
await umbracoUi.goToBackOffice();
317+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
318+
319+
// Act
320+
await umbracoUi.content.goToContentWithName(contentName);
321+
await umbracoUi.content.clickAddMultiURLPickerButton();
322+
await umbracoUi.content.clickManualLinkButton();
323+
await umbracoUi.content.enterLink('');
324+
await umbracoUi.content.enterAnchorOrQuerystring('#value');
325+
await umbracoUi.content.clickAddButton();
326+
327+
// Assert
328+
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
329+
});
330+
331+
// TODO: Remove skip when the front-end ready. Currently it still accept the empty link using spacebar
332+
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
333+
test.skip('cannot submit an empty link using spacebar', async ({umbracoApi, umbracoUi}) => {
334+
// Arrange
335+
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
336+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
337+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
338+
await umbracoUi.goToBackOffice();
339+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
340+
341+
// Act
342+
await umbracoUi.content.goToContentWithName(contentName);
343+
await umbracoUi.content.clickAddMultiURLPickerButton();
344+
await umbracoUi.content.clickManualLinkButton();
345+
await umbracoUi.content.enterLink('Space', true);
346+
await umbracoUi.content.enterAnchorOrQuerystring('Space', true);
347+
await umbracoUi.content.enterLinkTitle('Space', true);
348+
await umbracoUi.content.clickAddButton();
349+
350+
// Assert
351+
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
352+
});
353+
354+
// TODO: Remove skip when the front-end ready. Currently it is impossible to link to unpublished document
355+
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17974
356+
test.skip('can create content with the link to an unpublished document', async ({umbracoApi, umbracoUi}) => {
357+
// Arrange
358+
const expectedState = 'Draft';
359+
const dataTypeData = await umbracoApi.dataType.getByName(dataTypeName);
360+
await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeData.id);
361+
// Create a document to link
362+
const documentTypeForLinkedDocumentName = 'TestDocumentType';
363+
const documentTypeForLinkedDocumentId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeForLinkedDocumentName);
364+
const linkedDocumentName = 'LinkedDocument';
365+
const linkedDocumentId = await umbracoApi.document.createDefaultDocument(linkedDocumentName, documentTypeForLinkedDocumentId);
366+
await umbracoUi.goToBackOffice();
367+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
368+
369+
// Act
370+
await umbracoUi.content.clickActionsMenuAtRoot();
371+
await umbracoUi.content.clickCreateButton();
372+
await umbracoUi.content.chooseDocumentType(documentTypeName);
373+
await umbracoUi.content.enterContentName(contentName);
374+
await umbracoUi.content.clickAddMultiURLPickerButton();
375+
await umbracoUi.content.clickDocumentLinkButton();
376+
await umbracoUi.content.selectLinkByName(linkedDocumentName);
377+
await umbracoUi.content.clickButtonWithName('Choose');
378+
await umbracoUi.content.clickAddButton();
379+
await umbracoUi.content.clickSaveButton();
380+
381+
// Assert
382+
await umbracoUi.content.isSuccessNotificationVisible();
383+
expect(await umbracoApi.document.doesNameExist(contentName)).toBeTruthy();
384+
const contentData = await umbracoApi.document.getByName(contentName);
385+
expect(contentData.variants[0].state).toBe(expectedState);
386+
expect(contentData.values[0].alias).toEqual(AliasHelper.toAlias(dataTypeName));
387+
expect(contentData.values[0].value.length).toBe(1);
388+
expect(contentData.values[0].value[0].type).toEqual('document');
389+
expect(contentData.values[0].value[0].icon).toEqual('icon-document');
390+
expect(contentData.values[0].value[0].target).toBeNull();
391+
expect(contentData.values[0].value[0].unique).toEqual(linkedDocumentId);
392+
expect(contentData.values[0].value[0].name).toEqual(linkedDocumentName);
393+
394+
// Clean
395+
await umbracoApi.documentType.ensureNameNotExists(documentTypeForLinkedDocumentName);
396+
await umbracoApi.document.ensureNameNotExists(linkedDocumentName);
397+
});

tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithTiptap.spec.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,78 @@ test('can add a video in RTE Tiptap property editor', async ({umbracoApi, umbrac
141141
expect(contentData.values[0].value.markup).toContain('data-embed-url');
142142
expect(contentData.values[0].value.markup).toContain(videoURL);
143143
});
144+
145+
test('cannot submit an empty link in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
146+
// Arrange
147+
const iconTitle = 'Link';
148+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
149+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
150+
await umbracoUi.goToBackOffice();
151+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
152+
153+
// Act
154+
await umbracoUi.content.goToContentWithName(contentName);
155+
await umbracoUi.content.clickTipTapToolbarIconWithTitle(iconTitle);
156+
await umbracoUi.content.clickManualLinkButton();
157+
await umbracoUi.content.enterLink('');
158+
await umbracoUi.content.enterAnchorOrQuerystring('');
159+
await umbracoUi.content.enterLinkTitle('');
160+
await umbracoUi.content.clickAddButton();
161+
162+
// Assert
163+
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
164+
});
165+
166+
// TODO: Remove skip when the front-end ready. Currently it still accept the empty link with an anchor or querystring
167+
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17411
168+
test.skip('cannot submit an empty URL with an anchor or querystring in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
169+
// Arrange
170+
const iconTitle = 'Link';
171+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
172+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
173+
await umbracoUi.goToBackOffice();
174+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
175+
176+
// Act
177+
await umbracoUi.content.goToContentWithName(contentName);
178+
await umbracoUi.content.clickTipTapToolbarIconWithTitle(iconTitle);
179+
await umbracoUi.content.clickManualLinkButton();
180+
await umbracoUi.content.enterLink('');
181+
await umbracoUi.content.enterAnchorOrQuerystring('#value');
182+
await umbracoUi.content.clickAddButton();
183+
184+
// Assert
185+
await umbracoUi.content.isTextWithMessageVisible(ConstantHelper.validationMessages.emptyLinkPicker);
186+
});
187+
188+
// TODO: Remove skip when the front-end ready. Currently it is impossible to link to unpublished document
189+
// Issue link: https://github.com/umbraco/Umbraco-CMS/issues/17974
190+
test.skip('can insert a link to an unpublished document in RTE Tiptap property editor', async ({umbracoApi, umbracoUi}) => {
191+
// Arrange
192+
const iconTitle = 'Link';
193+
const documentTypeId = await umbracoApi.documentType.createDocumentTypeWithPropertyEditor(documentTypeName, customDataTypeName, customDataTypeId);
194+
await umbracoApi.document.createDefaultDocument(contentName, documentTypeId);
195+
// Create a document to link
196+
const documentTypeForLinkedDocumentName = 'TestDocumentType';
197+
const documentTypeForLinkedDocumentId = await umbracoApi.documentType.createDefaultDocumentTypeWithAllowAsRoot(documentTypeForLinkedDocumentName);
198+
const linkedDocumentName = 'LinkedDocument';
199+
await umbracoApi.document.createDefaultDocument(linkedDocumentName, documentTypeForLinkedDocumentId);
200+
await umbracoUi.goToBackOffice();
201+
await umbracoUi.content.goToSection(ConstantHelper.sections.content);
202+
203+
// Act
204+
await umbracoUi.content.goToContentWithName(contentName);
205+
await umbracoUi.content.clickTipTapToolbarIconWithTitle(iconTitle);
206+
await umbracoUi.content.clickDocumentLinkButton();
207+
await umbracoUi.content.selectLinkByName(linkedDocumentName);
208+
await umbracoUi.content.clickButtonWithName('Choose');
209+
await umbracoUi.content.clickAddButton();
210+
await umbracoUi.content.clickSaveButton();
211+
212+
// Assert
213+
await umbracoUi.content.isSuccessNotificationVisible();
214+
215+
// Clean
216+
await umbracoApi.documentType.ensureNameNotExists(documentTypeForLinkedDocumentName);
217+
await umbracoApi.document.ensureNameNotExists(linkedDocumentName);
218+
});

0 commit comments

Comments
 (0)