|
| 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 | +}); |
0 commit comments