-
Notifications
You must be signed in to change notification settings - Fork 261
/
document-list-gallery.e2e.ts
179 lines (149 loc) · 9.6 KB
/
document-list-gallery.e2e.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ContentServicesPage } from '../../core/pages/content-services.page';
import { browser } from 'protractor';
import { createApiService, LoginPage, StringUtil, UploadActions, UsersActions } from '@alfresco/adf-testing';
import { FileModel } from '../../models/ACS/file.model';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
describe('Document List Component', () => {
const loginPage = new LoginPage();
const contentServicesPage = new ContentServicesPage();
const apiService = createApiService();
const usersActions = new UsersActions(apiService);
const uploadActions = new UploadActions(apiService);
let acsUser = null;
const navigationBarPage = new NavigationBarPage();
describe('Gallery View', () => {
const cardProperties = {
DISPLAY_NAME: 'Display name',
SIZE: 'Size',
LOCK: 'Lock',
CREATED_BY: 'Created by',
CREATED: 'Created'
};
const pdfFile = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.PDF.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.PDF.file_path
});
const testFile = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.TEST.file_path
});
const docxFile = new FileModel({
name: browser.params.resources.Files.ADF_DOCUMENTS.DOCX.file_name,
location: browser.params.resources.Files.ADF_DOCUMENTS.DOCX.file_path
});
const folderName = `MEESEEKS_${StringUtil.generateRandomString(5)}_LOOK_AT_ME`;
let filePdfNode, fileTestNode, fileDocxNode, folderNode, filePDFSubNode;
beforeAll(async () => {
await apiService.loginWithProfile('admin');
acsUser = await usersActions.createUser();
await apiService.login(acsUser.username, acsUser.password);
filePdfNode = await uploadActions.uploadFile(pdfFile.location, pdfFile.name, '-my-');
fileTestNode = await uploadActions.uploadFile(testFile.location, testFile.name, '-my-');
fileDocxNode = await uploadActions.uploadFile(docxFile.location, docxFile.name, '-my-');
folderNode = await uploadActions.createFolder(folderName, '-my-');
filePDFSubNode = await uploadActions.uploadFile(pdfFile.location, pdfFile.name, folderNode.entry.id);
await loginPage.login(acsUser.username, acsUser.password);
});
afterAll(async () => {
await navigationBarPage.clickLogoutButton();
await apiService.loginWithProfile('admin');
if (filePdfNode) {
await uploadActions.deleteFileOrFolder(filePdfNode.entry.id);
}
if (fileTestNode) {
await uploadActions.deleteFileOrFolder(fileTestNode.entry.id);
}
if (fileDocxNode) {
await uploadActions.deleteFileOrFolder(fileDocxNode.entry.id);
}
if (filePDFSubNode) {
await uploadActions.deleteFileOrFolder(filePDFSubNode.entry.id);
}
if (folderNode) {
await uploadActions.deleteFileOrFolder(folderNode.entry.id);
}
});
beforeEach(async () => {
await navigationBarPage.clickHomeButton();
await contentServicesPage.goToDocumentList();
await contentServicesPage.clickGridViewButton();
await contentServicesPage.checkCardViewContainerIsDisplayed();
});
it('[C280016] Should be able to choose Gallery View', async () => {
await expect(await contentServicesPage.getCardElementShowedInPage()).toBe(4);
});
it('[C280023] Gallery Card should show details', async () => {
await expect(await contentServicesPage.getDocumentCardIconForElement(folderName)).toContain('/assets/images/ft_ic_folder.svg');
await expect(await contentServicesPage.getDocumentCardIconForElement(pdfFile.name)).toContain('/assets/images/ft_ic_pdf.svg');
await expect(await contentServicesPage.getDocumentCardIconForElement(docxFile.name)).toContain('/assets/images/ft_ic_ms_word.svg');
await expect(await contentServicesPage.getDocumentCardIconForElement(testFile.name)).toContain('/assets/images/ft_ic_document.svg');
await contentServicesPage.checkMenuIsShowedForElementIndex(0);
await contentServicesPage.checkMenuIsShowedForElementIndex(1);
await contentServicesPage.checkMenuIsShowedForElementIndex(2);
await contentServicesPage.checkMenuIsShowedForElementIndex(3);
});
it('[C280069] Gallery Card should show attributes', async () => {
await contentServicesPage.checkDocumentCardPropertyIsShowed(folderName, cardProperties.DISPLAY_NAME);
await contentServicesPage.checkDocumentCardPropertyIsShowed(folderName, cardProperties.SIZE);
await contentServicesPage.checkDocumentCardPropertyIsShowed(folderName, cardProperties.CREATED_BY);
await contentServicesPage.checkDocumentCardPropertyIsShowed(folderName, cardProperties.CREATED);
await expect(await contentServicesPage.getAttributeValueForElement(folderName, cardProperties.DISPLAY_NAME)).toBe(folderName);
await expect(await contentServicesPage.getAttributeValueForElement(folderName, cardProperties.CREATED_BY)).toBe(`${acsUser.firstName} ${acsUser.lastName}`);
await expect(await contentServicesPage.getAttributeValueForElement(folderName, cardProperties.CREATED)).toMatch(/(ago|few)/);
await expect(await contentServicesPage.getAttributeValueForElement(pdfFile.name, cardProperties.DISPLAY_NAME)).toBe(pdfFile.name);
await expect(await contentServicesPage.getAttributeValueForElement(pdfFile.name, cardProperties.SIZE)).toBe(`105.02 KB`);
await expect(await contentServicesPage.getAttributeValueForElement(pdfFile.name, cardProperties.CREATED_BY)).toBe(`${acsUser.firstName} ${acsUser.lastName}`);
await expect(await contentServicesPage.getAttributeValueForElement(pdfFile.name, cardProperties.CREATED)).toMatch(/(ago|few)/);
await expect(await contentServicesPage.getAttributeValueForElement(docxFile.name, cardProperties.DISPLAY_NAME)).toBe(docxFile.name);
await expect(await contentServicesPage.getAttributeValueForElement(docxFile.name, cardProperties.SIZE)).toBe(`11.81 KB`);
await expect(await contentServicesPage.getAttributeValueForElement(docxFile.name, cardProperties.CREATED_BY))
.toBe(`${acsUser.firstName} ${acsUser.lastName}`);
await expect(await contentServicesPage.getAttributeValueForElement(docxFile.name, cardProperties.CREATED)).toMatch(/(ago|few)/);
await expect(await contentServicesPage.getAttributeValueForElement(testFile.name, cardProperties.DISPLAY_NAME)).toBe(testFile.name);
await expect(await contentServicesPage.getAttributeValueForElement(testFile.name, cardProperties.SIZE)).toBe(`14 Bytes`);
await expect(await contentServicesPage.getAttributeValueForElement(testFile.name, cardProperties.CREATED_BY))
.toBe(`${acsUser.firstName} ${acsUser.lastName}`);
await expect(await contentServicesPage.getAttributeValueForElement(testFile.name, cardProperties.CREATED)).toMatch(/(ago|few)/);
});
// eslint-disable-next-line ban/ban
xit('[C280129] Should keep Gallery View when accessing a folder', async () => {
await contentServicesPage.navigateToCardFolder(folderName);
await expect(await contentServicesPage.getCardElementShowedInPage()).toBe(1);
await expect(await contentServicesPage.getDocumentCardIconForElement(pdfFile.name)).toContain('/assets/images/ft_ic_pdf.svg');
});
it('[C280130] Should be able to go back to List View', async () => {
await contentServicesPage.clickGridViewButton();
await contentServicesPage.checkAcsContainer();
await contentServicesPage.openFolder(folderName);
await contentServicesPage.checkRowIsDisplayed(pdfFile.name);
});
it('[C261993] Should be able to sort Gallery Cards by display name', async () => {
await contentServicesPage.selectGridSortingFromDropdown(cardProperties.DISPLAY_NAME);
await contentServicesPage.checkListIsSortedByNameColumn('asc');
});
it('[C261995] Should be able to sort Gallery Cards by author', async () => {
await contentServicesPage.selectGridSortingFromDropdown(cardProperties.CREATED_BY);
await contentServicesPage.checkListIsSortedByAuthorColumn('asc');
});
it('[C261996] Should be able to sort Gallery Cards by created date', async () => {
await contentServicesPage.selectGridSortingFromDropdown(cardProperties.CREATED);
await contentServicesPage.checkListIsSortedByCreatedColumn('asc');
});
});
});