Skip to content

Commit

Permalink
[APPS-2136] migrate search-datetime-range to date-fns (#9004)
Browse files Browse the repository at this point in the history
* strongly typed forms

* migrate to date-fns

* [ci:force] mark moment pipes for deprecation

* [ci:force] try migrate the metadata smoke e2e

* [ci:force] remove dead code

* cleanup dead code and switch e2e to date-fns

* [ci:force] migrate tests

* revert metadata

* [ci:force] migrate e2e

* [ci:force] delete date util
  • Loading branch information
DenysVuika authored Oct 18, 2023
1 parent af24ace commit 7d5fbec
Show file tree
Hide file tree
Showing 22 changed files with 350 additions and 428 deletions.
84 changes: 16 additions & 68 deletions e2e/core/pages/content-services.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,13 @@
* limitations under the License.
*/

import {
DropActions,
BrowserActions,
BrowserVisibility,
DateUtil,
DocumentListPage,
DropdownPage,
Logger
} from '@alfresco/adf-testing';
import { DropActions, BrowserActions, BrowserVisibility, DocumentListPage, DropdownPage, Logger } from '@alfresco/adf-testing';
import { $$, browser, by, element, protractor, $ } from 'protractor';
import { FolderDialogPage } from './dialog/folder-dialog.page';
import { NavigationBarPage } from './navigation-bar.page';

import * as path from 'path';

export class ContentServicesPage {

columns = {
name: 'Display name',
size: 'Size',
Expand Down Expand Up @@ -94,28 +84,28 @@ export class ContentServicesPage {
await BrowserVisibility.waitUntilElementIsVisible(disabledDelete);
}

async deleteContent(content): Promise<void> {
async deleteContent(content: string): Promise<void> {
await this.contentList.clickOnActionMenu(content);
await BrowserActions.click(this.deleteContentElement);
await this.checkContentIsNotDisplayed(content);
}

async metadataContent(content): Promise<void> {
async metadataContent(content: string): Promise<void> {
await this.contentList.clickOnActionMenu(content);
await BrowserActions.click(this.metadataAction);
}

async versionManagerContent(content): Promise<void> {
async versionManagerContent(content: string): Promise<void> {
await this.contentList.clickOnActionMenu(content);
await BrowserActions.click(this.versionManagerAction);
}

async clickFileHyperlink(fileName): Promise<void> {
async clickFileHyperlink(fileName: string): Promise<void> {
const hyperlink = this.contentList.dataTablePage().getFileHyperlink(fileName);
await BrowserActions.click(hyperlink);
}

async checkFileHyperlinkIsEnabled(fileName): Promise<void> {
async checkFileHyperlinkIsEnabled(fileName: string): Promise<void> {
const hyperlink = this.contentList.dataTablePage().getFileHyperlink(fileName);
await BrowserVisibility.waitUntilElementIsVisible(hyperlink);
}
Expand All @@ -129,38 +119,6 @@ export class ContentServicesPage {
return this.contentList.dataTablePage().getAllRowsColumnValues(this.columns.nodeId);
}

checkElementsDateSortedAsc(elements) {
let sorted = true;
let i = 0;

while (elements.length > 1 && sorted === true && i < (elements.length - 1)) {
const left = DateUtil.parse(elements[i], 'DD-MM-YY');
const right = DateUtil.parse(elements[i + 1], 'DD-MM-YY');
if (left > right) {
sorted = false;
}
i++;
}

return sorted;
}

checkElementsDateSortedDesc(elements) {
let sorted = true;
let i = 0;

while (elements.length > 1 && sorted === true && i < (elements.length - 1)) {
const left = DateUtil.parse(elements[i], 'DD-MM-YY');
const right = DateUtil.parse(elements[i + 1], 'DD-MM-YY');
if (left < right) {
sorted = false;
}
i++;
}

return sorted;
}

// @deprecated prefer waitTillContentLoaded
async checkDocumentListElementsAreDisplayed(): Promise<void> {
await this.checkAcsContainer();
Expand Down Expand Up @@ -368,16 +326,16 @@ export class ContentServicesPage {
await DropActions.dropFile(this.dragAndDrop, file);
}

async checkLockIsDisplayedForElement(name): Promise<void> {
async checkLockIsDisplayedForElement(name: string): Promise<void> {
const lockButton = $(`div.adf-datatable-cell[data-automation-id="${name}"] button`);
await BrowserVisibility.waitUntilElementIsVisible(lockButton);
}

async getColumnValueForRow(file, columnName): Promise<string> {
async getColumnValueForRow(file: string, columnName: string): Promise<string> {
return this.contentList.dataTablePage().getColumnValueForRow(this.columns.name, file, columnName);
}

async checkEmptyFolderTextToBe(text): Promise<void> {
async checkEmptyFolderTextToBe(text: string): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.emptyFolder);
await expect(await this.emptyFolder.getText()).toContain(text);
}
Expand All @@ -386,7 +344,7 @@ export class ContentServicesPage {
await expect(await BrowserActions.getAttribute(this.emptyFolderImage, 'src')).toContain(url);
}

async getRowIconImageUrl(fileName): Promise<string> {
async getRowIconImageUrl(fileName: string): Promise<string> {
const iconRow = $(`.app-document-list-container div.adf-datatable-cell[data-automation-id="${fileName}"] img`);
return BrowserActions.getAttribute(iconRow, 'src');
}
Expand Down Expand Up @@ -415,12 +373,16 @@ export class ContentServicesPage {
}

async checkDocumentCardPropertyIsShowed(elementName: string, propertyName: string): Promise<void> {
const elementProperty = $(`.app-document-list-container div.adf-datatable-cell[data-automation-id="${elementName}"][title="${propertyName}"]`);
const elementProperty = $(
`.app-document-list-container div.adf-datatable-cell[data-automation-id="${elementName}"][title="${propertyName}"]`
);
await BrowserVisibility.waitUntilElementIsVisible(elementProperty);
}

async getAttributeValueForElement(elementName: string, propertyName: string): Promise<string> {
const elementSize = $(`.app-document-list-container div.adf-datatable-cell[data-automation-id="${elementName}"][title="${propertyName}"] span`);
const elementSize = $(
`.app-document-list-container div.adf-datatable-cell[data-automation-id="${elementName}"][title="${propertyName}"] span`
);
return BrowserActions.getText(elementSize);
}

Expand All @@ -429,24 +391,10 @@ export class ContentServicesPage {
await BrowserVisibility.waitUntilElementIsVisible(elementMenu);
}

async navigateToCardFolder(folderName: string): Promise<void> {
await BrowserActions.closeMenuAndDialogs();
const folderCard = $(`.app-document-list-container div.adf-image-table-cell.adf-datatable-cell[data-automation-id="${folderName}"]`);
await BrowserActions.click(folderCard);
const folderSelected = $(`.adf-datatable-row.adf-is-selected div[data-automation-id="${folderName}"].adf-datatable-cell--image`);
await BrowserVisibility.waitUntilElementIsVisible(folderSelected);
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
}

async selectGridSortingFromDropdown(sortingOption: string): Promise<void> {
await this.sortingDropdown.selectDropdownOption(sortingOption);
}

async checkRowIsDisplayed(rowName: string): Promise<void> {
const row = this.contentList.dataTablePage().getCellElementByValue(this.columns.name, rowName);
await BrowserVisibility.waitUntilElementIsVisible(row);
}

async checkSelectedSiteIsDisplayed(siteName: string): Promise<void> {
await this.siteListDropdown.checkOptionIsSelected(siteName);
}
Expand Down
3 changes: 1 addition & 2 deletions e2e/core/pages/dialog/folder-dialog.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { $$ } from 'protractor';
import { BrowserActions } from '@alfresco/adf-testing';

export class FolderDialogPage {

folderDialog = $$('adf-folder-dialog').first();
folderNameField = this.folderDialog.$('#adf-folder-name-input');
createUpdateButton = this.folderDialog.$('#adf-folder-create-button');
Expand All @@ -29,7 +28,7 @@ export class FolderDialogPage {
await BrowserActions.click(this.createUpdateButton);
}

async addFolderName(folderName): Promise<void> {
async addFolderName(folderName: string): Promise<void> {
await BrowserActions.clearSendKeys(this.folderNameField, folderName);
}
}
6 changes: 0 additions & 6 deletions e2e/core/pages/dialog/upload-toggles.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { $, browser } from 'protractor';
import { BrowserActions, BrowserVisibility, TogglePage } from '@alfresco/adf-testing';

export class UploadTogglesPage {

togglePage = new TogglePage();
multipleFileUploadToggle = $('#adf-multiple-upload-switch');
uploadFolderToggle = $('#adf-folder-upload-switch');
Expand All @@ -44,11 +43,6 @@ export class UploadTogglesPage {
await this.togglePage.enableToggle(this.uploadFolderToggle);
}

async checkMultipleFileUploadToggleIsEnabled(): Promise<void> {
const enabledToggle = $('mat-slide-toggle[id="adf-multiple-upload-switch"][class*="mat-checked"]');
await BrowserVisibility.waitUntilElementIsVisible(enabledToggle);
}

async checkMaxSizeToggleIsEnabled(): Promise<void> {
const enabledToggle = $('mat-slide-toggle[id="adf-max-size-filter-upload-switch"][class*="mat-checked"]');
await BrowserVisibility.waitUntilElementIsVisible(enabledToggle);
Expand Down
5 changes: 0 additions & 5 deletions e2e/core/pages/metadata-view.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class MetadataViewPage {
size = $(`[data-automation-id='card-textitem-value-content.sizeInBytes']`);
description = $(`span[data-automation-id='card-textitem-value-properties.cm:description']`);
author = $(`[data-automation-id='card-textitem-value-properties.cm:author']`);
titleProperty = $(`span[data-automation-id='card-textitem-value-properties.cm:title'] span`);
editIcon = $(`button[data-automation-id='meta-data-card-toggle-edit']`);
informationButton = $(`button[data-automation-id='meta-data-card-toggle-expand']`);
informationSpan = $(`span[data-automation-id='meta-data-card-toggle-expand-label']`);
Expand Down Expand Up @@ -96,10 +95,6 @@ export class MetadataViewPage {
return BrowserActions.getInputValue(this.author);
}

async getTitleProperty(): Promise<string> {
return BrowserActions.getText(this.titleProperty);
}

async editIconIsDisplayed(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.editIcon);
}
Expand Down
51 changes: 0 additions & 51 deletions e2e/core/pages/trashcan.page.ts

This file was deleted.

2 changes: 1 addition & 1 deletion e2e/models/ACS/file.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class FileModel {
lastPageText = browser.params.resources.Files.ADF_DOCUMENTS.PDF.last_page_text;
secondPageText = browser.params.resources.Files.ADF_DOCUMENTS.PDF.second_page_text;
lastPageNumber = browser.params.resources.Files.ADF_DOCUMENTS.PDF.last_page_number;
createdAt = '';
createdAt: Date = null;
password = '';
createdByUser = new CreatedByModel();
modifiedByUser = new CreatedByModel();
Expand Down
10 changes: 4 additions & 6 deletions e2e/process-services/pages/task-details.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class TaskDetailsPage {
return BrowserActions.getText(this.taskDetailsTitle);
}

async checkSelectedForm(formName): Promise<void> {
async checkSelectedForm(formName: string): Promise<void> {
await this.attachFormDropdown.checkOptionIsSelected(formName);
}

Expand Down Expand Up @@ -263,7 +263,7 @@ export class TaskDetailsPage {
await BrowserActions.clearSendKeys(this.addPeopleField, user);
}

async selectUserToInvolve(user): Promise<void> {
async selectUserToInvolve(user: string): Promise<void> {
const row = this.getRowsUser(user);
await BrowserActions.click(row);
}
Expand All @@ -282,15 +282,14 @@ export class TaskDetailsPage {
return $(`div[data-automation-id="adf-people-full-name-${user.replace(' ', '-')}"]`);
}

async removeInvolvedUser(user): Promise<void> {
async removeInvolvedUser(user: string): Promise<void> {
const row = this.getRowsUser(user).element(by.xpath('ancestor::adf-datatable-row[contains(@class, "adf-datatable-row")]'));
await BrowserActions.click(row.$('button[data-automation-id="action_menu_0"]'));
await BrowserVisibility.waitUntilElementIsVisible(this.removeInvolvedPeople);
await BrowserActions.click(this.removeInvolvedPeople);

}

async getInvolvedUserEmail(user): Promise<string> {
async getInvolvedUserEmail(user: string): Promise<string> {
return BrowserActions.getText($(`div[data-automation-id="adf-people-email-${user.replace(' ', '-')}"]`));
}

Expand Down Expand Up @@ -401,5 +400,4 @@ export class TaskDetailsPage {
await BrowserVisibility.waitUntilElementIsVisible(this.saveFormButton);
await BrowserActions.click(this.saveFormButton);
}

}
13 changes: 5 additions & 8 deletions e2e/process-services/pages/tasks.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import { TaskDetailsPage } from './task-details.page';
import { FiltersPage } from './filters.page';
import { ChecklistDialog } from './dialog/create-checklist-dialog.page';
import { TasksListPage } from './tasks-list.page';
import { element, by, $ } from 'protractor';
import { BrowserVisibility, BrowserActions, FormFields } from '@alfresco/adf-testing';
import { $, by, element } from 'protractor';
import { BrowserActions, BrowserVisibility, FormFields } from '@alfresco/adf-testing';

export class TasksPage {
createButton = $('button[data-automation-id="create-button"');
newTaskButton = $('button[data-automation-id="btn-start-task"]');
addChecklistButton = $('button[class*="adf-add-to-checklist-button"]');
rowByRowName = by.xpath('ancestor::mat-chip');
checklistContainer = $('div[class*="checklist-menu"]');
Expand All @@ -42,10 +41,10 @@ export class TasksPage {
return new StartTaskDialogPage();
}

async createTask({ name, description = '', dueDate = '', formName = 'None'}): Promise<void> {
async createTask({ name, description = '', dueDate = '', formName = 'None' }): Promise<void> {
await this.clickOnCreateButton();
await BrowserActions.clickExecuteScript('button[data-automation-id="btn-start-task"]');
const dialog = new StartTaskDialogPage();
const dialog = new StartTaskDialogPage();
await dialog.addName(name);
await dialog.addDescription(description);
await dialog.addDueDate(dueDate);
Expand Down Expand Up @@ -88,8 +87,7 @@ export class TasksPage {

getChecklistByName(name: string) {
const elem = this.getRowsName(name);
const row = elem.element(this.rowByRowName);
return row;
return elem.element(this.rowByRowName);
}

async checkChecklistIsDisplayed(name: string): Promise<void> {
Expand Down Expand Up @@ -150,5 +148,4 @@ export class TasksPage {
async clickSortByNameDesc(): Promise<any> {
return this.tasksListPage().getDataTable().sortByColumn('DESC', 'name');
}

}
Loading

0 comments on commit 7d5fbec

Please sign in to comment.