|
| 1 | +import {ConstantHelper, NotificationConstantHelper, test} from '@umbraco/playwright-testhelpers'; |
| 2 | +import {expect} from '@playwright/test'; |
| 3 | + |
| 4 | +const documentTypeName = 'TestDocumentType'; |
| 5 | +const documentFolderName = 'TestDocumentTypeFolder'; |
| 6 | + |
| 7 | +test.beforeEach(async ({umbracoUi, umbracoApi}) => { |
| 8 | + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); |
| 9 | + await umbracoApi.documentType.ensureNameNotExists(documentFolderName); |
| 10 | + await umbracoUi.goToBackOffice(); |
| 11 | + await umbracoUi.documentType.goToSection(ConstantHelper.sections.settings); |
| 12 | +}); |
| 13 | + |
| 14 | +test.afterEach(async ({umbracoApi}) => { |
| 15 | + await umbracoApi.documentType.ensureNameNotExists(documentTypeName); |
| 16 | + await umbracoApi.documentType.ensureNameNotExists(documentFolderName); |
| 17 | +}); |
| 18 | + |
| 19 | +test('can create a document type using create options', async ({umbracoApi, umbracoUi}) => { |
| 20 | + // Arrange |
| 21 | + await umbracoUi.documentType.clickDocumentTypesMenu(); |
| 22 | + |
| 23 | + // Act |
| 24 | + await umbracoUi.documentType.clickCreateActionWithOptionName('Document Type'); |
| 25 | + await umbracoUi.documentType.enterDocumentTypeName(documentTypeName); |
| 26 | + await umbracoUi.documentType.clickSaveButton(); |
| 27 | + |
| 28 | + // Assert |
| 29 | + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); |
| 30 | + expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeTruthy(); |
| 31 | + // Check if the created document type is displayed in the collection view and has correct icon |
| 32 | + await umbracoUi.documentType.clickDocumentTypesMenu(); |
| 33 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveName(documentTypeName); |
| 34 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveIcon(documentTypeName, 'icon-document'); |
| 35 | +}); |
| 36 | + |
| 37 | +test('can create a document type with a template using create options', async ({umbracoApi, umbracoUi}) => { |
| 38 | + // Arrange |
| 39 | + await umbracoApi.template.ensureNameNotExists(documentTypeName); |
| 40 | + await umbracoUi.documentType.clickDocumentTypesMenu(); |
| 41 | + |
| 42 | + // Act |
| 43 | + await umbracoUi.documentType.clickCreateActionWithOptionName('Document Type with Template'); |
| 44 | + await umbracoUi.documentType.enterDocumentTypeName(documentTypeName); |
| 45 | + await umbracoUi.documentType.clickSaveButton(); |
| 46 | + |
| 47 | + // Assert |
| 48 | + // Checks if both the success notification for document Types and the template are visible |
| 49 | + await umbracoUi.documentType.doesSuccessNotificationsHaveCount(2); |
| 50 | + // Checks if the documentType contains the template |
| 51 | + const documentTypeData = await umbracoApi.documentType.getByName(documentTypeName); |
| 52 | + const templateData = await umbracoApi.template.getByName(documentTypeName); |
| 53 | + expect(documentTypeData.allowedTemplates[0].id).toEqual(templateData.id); |
| 54 | + expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeTruthy(); |
| 55 | + // Check if the created document type is displayed in the collection view and has correct icon |
| 56 | + await umbracoUi.documentType.clickDocumentTypesMenu(); |
| 57 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveName(documentTypeName); |
| 58 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveIcon(documentTypeName, 'icon-document-html'); |
| 59 | + |
| 60 | + // Clean |
| 61 | + await umbracoApi.template.ensureNameNotExists(documentTypeName); |
| 62 | +}); |
| 63 | + |
| 64 | +test('can create a element type using create options', async ({umbracoApi, umbracoUi}) => { |
| 65 | + // Arrange |
| 66 | + await umbracoUi.documentType.clickDocumentTypesMenu(); |
| 67 | + |
| 68 | + // Act |
| 69 | + await umbracoUi.documentType.clickCreateActionWithOptionName('Element Type'); |
| 70 | + await umbracoUi.documentType.enterDocumentTypeName(documentTypeName); |
| 71 | + await umbracoUi.documentType.clickSaveButton(); |
| 72 | + |
| 73 | + // Assert |
| 74 | + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); |
| 75 | + expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeTruthy(); |
| 76 | + // Checks if the isElement is true |
| 77 | + const documentTypeData = await umbracoApi.documentType.getByName(documentTypeName); |
| 78 | + expect(documentTypeData.isElement).toBeTruthy(); |
| 79 | + // Check if the created document type is displayed in the collection view and has correct icon |
| 80 | + await umbracoUi.documentType.clickDocumentTypesMenu(); |
| 81 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveName(documentTypeName); |
| 82 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveIcon(documentTypeName, 'icon-plugin'); |
| 83 | +}); |
| 84 | + |
| 85 | +test('can create a document type folder using create options', async ({umbracoApi, umbracoUi}) => { |
| 86 | + // Arrange |
| 87 | + await umbracoUi.documentType.clickDocumentTypesMenu(); |
| 88 | + |
| 89 | + // Act |
| 90 | + await umbracoUi.documentType.clickCreateActionWithOptionName('Folder'); |
| 91 | + await umbracoUi.documentType.enterFolderName(documentFolderName); |
| 92 | + await umbracoUi.documentType.clickCreateFolderButton(); |
| 93 | + |
| 94 | + // Assert |
| 95 | + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); |
| 96 | + const folder = await umbracoApi.documentType.getByName(documentFolderName); |
| 97 | + expect(folder.name).toBe(documentFolderName); |
| 98 | + // Check if the created document type folder is displayed in the collection view and has correct icon |
| 99 | + await umbracoUi.documentType.clickDocumentTypesMenu(); |
| 100 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveName(documentFolderName); |
| 101 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveIcon(documentFolderName, 'icon-folder'); |
| 102 | +}); |
| 103 | + |
| 104 | +test('can create a document type in a folder using create options', async ({umbracoApi, umbracoUi}) => { |
| 105 | + // Arrange |
| 106 | + await umbracoApi.documentType.createFolder(documentFolderName); |
| 107 | + await umbracoUi.documentType.goToDocumentType(documentFolderName); |
| 108 | + |
| 109 | + // Act |
| 110 | + await umbracoUi.documentType.clickCreateActionWithOptionName('Document Type'); |
| 111 | + await umbracoUi.documentType.enterDocumentTypeName(documentTypeName); |
| 112 | + await umbracoUi.documentType.clickSaveButton(); |
| 113 | + |
| 114 | + // Assert |
| 115 | + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); |
| 116 | + expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeTruthy(); |
| 117 | + // Check if the created document type is displayed in the collection view and has correct icon |
| 118 | + await umbracoUi.documentType.goToDocumentType(documentFolderName); |
| 119 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveName(documentTypeName); |
| 120 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveIcon(documentTypeName, 'icon-document'); |
| 121 | +}); |
| 122 | + |
| 123 | +test('can create a document type with a template in a folder using create options', async ({umbracoApi, umbracoUi}) => { |
| 124 | + // Arrange |
| 125 | + await umbracoApi.template.ensureNameNotExists(documentTypeName); |
| 126 | + await umbracoApi.documentType.createFolder(documentFolderName); |
| 127 | + await umbracoUi.documentType.goToDocumentType(documentFolderName); |
| 128 | + |
| 129 | + // Act |
| 130 | + await umbracoUi.documentType.clickCreateActionWithOptionName('Document Type with Template'); |
| 131 | + await umbracoUi.documentType.enterDocumentTypeName(documentTypeName); |
| 132 | + await umbracoUi.documentType.clickSaveButton(); |
| 133 | + |
| 134 | + // Assert |
| 135 | + // Checks if both the success notification for document Types and the template are visible |
| 136 | + await umbracoUi.documentType.doesSuccessNotificationsHaveCount(2); |
| 137 | + // Checks if the documentType contains the template |
| 138 | + const documentTypeData = await umbracoApi.documentType.getByName(documentTypeName); |
| 139 | + const templateData = await umbracoApi.template.getByName(documentTypeName); |
| 140 | + expect(documentTypeData.allowedTemplates[0].id).toEqual(templateData.id); |
| 141 | + expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeTruthy(); |
| 142 | + // Check if the created document type is displayed in the collection view and has correct icon |
| 143 | + await umbracoUi.documentType.goToDocumentType(documentFolderName); |
| 144 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveName(documentTypeName); |
| 145 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveIcon(documentTypeName, 'icon-document-html'); |
| 146 | + |
| 147 | + // Clean |
| 148 | + await umbracoApi.template.ensureNameNotExists(documentTypeName); |
| 149 | +}); |
| 150 | + |
| 151 | +test('can create a element type in a folder using create options', async ({umbracoApi, umbracoUi}) => { |
| 152 | + // Arrange |
| 153 | + await umbracoApi.documentType.createFolder(documentFolderName); |
| 154 | + await umbracoUi.documentType.goToDocumentType(documentFolderName); |
| 155 | + |
| 156 | + // Act |
| 157 | + await umbracoUi.documentType.clickCreateActionWithOptionName('Element Type'); |
| 158 | + await umbracoUi.documentType.enterDocumentTypeName(documentTypeName); |
| 159 | + await umbracoUi.documentType.clickSaveButton(); |
| 160 | + |
| 161 | + // Assert |
| 162 | + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); |
| 163 | + expect(await umbracoApi.documentType.doesNameExist(documentTypeName)).toBeTruthy(); |
| 164 | + // Checks if the isElement is true |
| 165 | + const documentTypeData = await umbracoApi.documentType.getByName(documentTypeName); |
| 166 | + expect(documentTypeData.isElement).toBeTruthy(); |
| 167 | + // Check if the created document type is displayed in the collection view and has correct icon |
| 168 | + await umbracoUi.documentType.goToDocumentType(documentFolderName); |
| 169 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveName(documentTypeName); |
| 170 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveIcon(documentTypeName, 'icon-plugin'); |
| 171 | +}); |
| 172 | + |
| 173 | +test('can create a document type folder in a folder using create options', async ({umbracoApi, umbracoUi}) => { |
| 174 | + // Arrange |
| 175 | + const childFolderName = 'Test Child Folder'; |
| 176 | + await umbracoApi.documentType.ensureNameNotExists(childFolderName); |
| 177 | + await umbracoApi.documentType.createFolder(documentFolderName); |
| 178 | + await umbracoUi.documentType.goToDocumentType(documentFolderName); |
| 179 | + |
| 180 | + // Act |
| 181 | + await umbracoUi.documentType.clickCreateActionWithOptionName('Folder'); |
| 182 | + await umbracoUi.documentType.enterFolderName(childFolderName); |
| 183 | + await umbracoUi.documentType.clickCreateFolderButton(); |
| 184 | + |
| 185 | + // Assert |
| 186 | + await umbracoUi.documentType.doesSuccessNotificationHaveText(NotificationConstantHelper.success.created); |
| 187 | + const folder = await umbracoApi.documentType.getByName(childFolderName); |
| 188 | + expect(folder.name).toBe(childFolderName); |
| 189 | + // Check if the created document type folder is displayed in the collection view and has correct icon |
| 190 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveName(childFolderName); |
| 191 | + await umbracoUi.documentType.doesCollectionTreeItemTableRowHaveIcon(childFolderName, 'icon-folder'); |
| 192 | + |
| 193 | + // Clean |
| 194 | + await umbracoApi.documentType.ensureNameNotExists(childFolderName); |
| 195 | +}); |
0 commit comments