mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[APPS-2132] migrate components to date-fns (#9001)
* migrate edit process filter to date-fns * refresh unit tests * fix a11y for date-fns * Revert "fix a11y for date-fns" This reverts commit 2e706d4aed1b8a50d1de62fe11d9d528530d628c. * update e2e * start task fixes * cleanup code * remove fdescribe * remove moment, improve unit testing * remove dependency on date util * cleanup search date range component * cleanup code * migrate search date range component * revert e2e changes for now * extra fixes and tests * add missing functionality, extra tests * increase time constraints * improved code, disabled e2e * move e2e to unit tests, extra rework for insights * extra unit test for date range validation * migrate date-range to date-fns
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
|
||||
import { createApiService,
|
||||
AppListCloudPage,
|
||||
DateUtil,
|
||||
GroupIdentityService,
|
||||
IdentityService,
|
||||
LocalStorageUtil,
|
||||
@@ -67,17 +66,26 @@ describe('Process filters cloud', () => {
|
||||
const queryService = new QueryService(apiService);
|
||||
const tasksService = new TasksService(apiService);
|
||||
|
||||
const beforeDate = format(subDays(new Date(), 1), 'dd/MM/yyyy');
|
||||
const currentDate = DateUtil.formatDate('DD/MM/YYYY');
|
||||
const afterDate = format(addDays(new Date(), 1), 'dd/MM/yyyy');
|
||||
const beforeDate = format(subDays(new Date(), 2), 'dd/MM/yyyy');
|
||||
const currentDate = format(new Date(), 'dd/MM/yyyy');
|
||||
const afterDate = format(addDays(new Date(), 2), 'dd/MM/yyyy');
|
||||
const processListCloudConfiguration = new ProcessListCloudConfiguration();
|
||||
const editProcessFilterConfiguration = new EditProcessFilterConfiguration();
|
||||
const processListCloudConfigFile = processListCloudConfiguration.getConfiguration();
|
||||
const editProcessFilterConfigFile = editProcessFilterConfiguration.getConfiguration();
|
||||
|
||||
let completedProcess; let runningProcessInstance; let suspendProcessInstance; let testUser; let anotherUser; let groupInfo;
|
||||
let anotherProcessInstance; let processDefinition; let anotherProcessDefinition;
|
||||
let differentAppUserProcessInstance; let simpleAppProcessDefinition;
|
||||
let completedProcess: any;
|
||||
let runningProcessInstance: any;
|
||||
let suspendProcessInstance: any;
|
||||
let testUser: any;
|
||||
let anotherUser: any;
|
||||
let groupInfo: any;
|
||||
let anotherProcessInstance: any;
|
||||
let processDefinition: any;
|
||||
let anotherProcessDefinition: any;
|
||||
let differentAppUserProcessInstance: any;
|
||||
let simpleAppProcessDefinition: any;
|
||||
|
||||
const candidateBaseApp = browser.params.resources.ACTIVITI_CLOUD_APPS.CANDIDATE_BASE_APP.name;
|
||||
const simpleApp = browser.params.resources.ACTIVITI_CLOUD_APPS.SIMPLE_APP.name;
|
||||
|
||||
@@ -252,7 +260,7 @@ describe('Process filters cloud', () => {
|
||||
await processList.checkContentIsNotDisplayedByName(runningProcessInstance.entry.name);
|
||||
});
|
||||
|
||||
it('[C306892] Should be able to filter by process status - Running', async () => {
|
||||
it('[C306892-1] Should be able to filter by process status - Running', async () => {
|
||||
await editProcessFilter.openFilter();
|
||||
await editProcessFilter.setStatusFilterDropDown(PROCESS_STATUS.RUNNING);
|
||||
await processList.getDataTable().waitTillContentLoaded();
|
||||
@@ -269,7 +277,7 @@ describe('Process filters cloud', () => {
|
||||
await processList.checkContentIsNotDisplayedByName(completedProcess.entry.name);
|
||||
});
|
||||
|
||||
it('[C306892] Should be able to filter by process status - Completed', async () => {
|
||||
it('[C306892-2] Should be able to filter by process status - Completed', async () => {
|
||||
await editProcessFilter.openFilter();
|
||||
await editProcessFilter.setStatusFilterDropDown(PROCESS_STATUS.COMPLETED);
|
||||
await processList.getDataTable().waitTillContentLoaded();
|
||||
@@ -286,7 +294,7 @@ describe('Process filters cloud', () => {
|
||||
await processList.checkContentIsNotDisplayedByName(anotherProcessInstance.entry.name);
|
||||
});
|
||||
|
||||
it('[C306892] Should be able to filter by process status - Suspended', async () => {
|
||||
it('[C306892-3] Should be able to filter by process status - Suspended', async () => {
|
||||
await editProcessFilter.openFilter();
|
||||
await editProcessFilter.setStatusFilterDropDown(PROCESS_STATUS.SUSPENDED);
|
||||
await processList.getDataTable().waitTillContentLoaded();
|
||||
@@ -303,7 +311,7 @@ describe('Process filters cloud', () => {
|
||||
await processList.checkContentIsNotDisplayedByName(completedProcess.entry.name);
|
||||
});
|
||||
|
||||
it('[C306892] Should be able to filter by process status - All', async () => {
|
||||
it('[C306892-4] Should be able to filter by process status - All', async () => {
|
||||
await processCloudDemoPage.processFilterCloudComponent.clickAllProcessesFilter();
|
||||
|
||||
await editProcessFilter.openFilter();
|
||||
@@ -315,17 +323,17 @@ describe('Process filters cloud', () => {
|
||||
await processList.checkContentIsDisplayedByName(completedProcess.entry.name);
|
||||
});
|
||||
|
||||
it('[C311318] Should be able to filter by lastModifiedFrom - displays record when date = currentDate', async () => {
|
||||
it('[C311318-1] Should be able to filter by lastModifiedFrom - displays record when date = currentDate', async () => {
|
||||
await setProcessName(currentDate, 'lastModifiedFrom');
|
||||
await processList.checkContentIsDisplayedByName(runningProcessInstance.entry.name);
|
||||
});
|
||||
|
||||
it('[C311318] Should be able to filter by lastModifiedFrom - displays record when date = beforeDate', async () => {
|
||||
it('[C311318-2] Should be able to filter by lastModifiedFrom - displays record when date = beforeDate', async () => {
|
||||
await setProcessName(beforeDate, 'lastModifiedFrom');
|
||||
await processList.checkContentIsDisplayedByName(runningProcessInstance.entry.name);
|
||||
});
|
||||
|
||||
it('[C311318] Should be able to filter by lastModifiedFrom - does not display record when date = afterDate', async () => {
|
||||
it('[C311318-3] Should be able to filter by lastModifiedFrom - does not display record when date = afterDate', async () => {
|
||||
await editProcessFilter.openFilter();
|
||||
await editProcessFilter.setProcessName(runningProcessInstance.entry.name);
|
||||
await processList.getDataTable().waitTillContentLoaded();
|
||||
@@ -333,17 +341,17 @@ describe('Process filters cloud', () => {
|
||||
await processList.checkContentIsNotDisplayedByName(runningProcessInstance.entry.name);
|
||||
});
|
||||
|
||||
it('[C311319] Should be able to filter by lastModifiedTo - displays record when date = currentDate', async () => {
|
||||
it('[C311319-1] Should be able to filter by lastModifiedTo - displays record when date = currentDate', async () => {
|
||||
await setProcessName(currentDate);
|
||||
await processList.checkContentIsDisplayedByName(runningProcessInstance.entry.name);
|
||||
});
|
||||
|
||||
it('[C311319] Should be able to filter by lastModifiedTo - does not display record when date = beforeDate', async () => {
|
||||
it('[C311319-2] Should be able to filter by lastModifiedTo - does not display record when date = beforeDate', async () => {
|
||||
await setProcessName(beforeDate);
|
||||
await processList.checkContentIsNotDisplayedByName(runningProcessInstance.entry.name);
|
||||
});
|
||||
|
||||
it('[C311319] Should be able to filter by lastModifiedTo - displays record when date = afterDate', async () => {
|
||||
it('[C311319-3] Should be able to filter by lastModifiedTo - displays record when date = afterDate', async () => {
|
||||
await editProcessFilter.openFilter();
|
||||
await editProcessFilter.setProperty('lastModifiedTo', afterDate);
|
||||
await processList.getDataTable().waitTillContentLoaded();
|
||||
@@ -351,7 +359,7 @@ describe('Process filters cloud', () => {
|
||||
await processList.checkContentIsDisplayedByName(runningProcessInstance.entry.name);
|
||||
});
|
||||
|
||||
it('[C311319] Should not display any processes when the lastModifiedFrom and lastModifiedTo are set to a future date', async () => {
|
||||
it('[C311319-4] Should not display any processes when the lastModifiedFrom and lastModifiedTo are set to a future date', async () => {
|
||||
await editProcessFilter.openFilter();
|
||||
await editProcessFilter.setProperty('lastModifiedFrom', afterDate);
|
||||
await processList.getDataTable().waitTillContentLoaded();
|
||||
|
@@ -20,7 +20,7 @@ import {
|
||||
StringUtil, TasksService,
|
||||
ProcessDefinitionsService, ProcessInstancesService,
|
||||
LoginPage, createApiService,
|
||||
AppListCloudPage, LocalStorageUtil, IdentityService, GroupIdentityService, DateUtil
|
||||
AppListCloudPage, LocalStorageUtil, IdentityService, GroupIdentityService
|
||||
} from '@alfresco/adf-testing';
|
||||
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
|
||||
import { TasksCloudDemoPage } from './../pages/tasks-cloud-demo.page';
|
||||
@@ -50,12 +50,21 @@ describe('Edit task filters and task list properties', () => {
|
||||
const processInstancesService = new ProcessInstancesService(apiService);
|
||||
|
||||
const noTasksFoundMessage = 'No Tasks Found';
|
||||
let createdTask; let notAssigned; let notDisplayedTask; let processDefinition; let processInstance; let priorityTask; let subTask;
|
||||
let otherOwnerTask; let testUser; let groupInfo; let simpleTask;
|
||||
let createdTask: any;
|
||||
let notAssigned: any;
|
||||
let notDisplayedTask: any;
|
||||
let processDefinition: any;
|
||||
let processInstance: any;
|
||||
let priorityTask: any;
|
||||
let subTask: any;
|
||||
let otherOwnerTask: any;
|
||||
let testUser: any;
|
||||
let groupInfo: any;
|
||||
let simpleTask: any;
|
||||
const priority = 1;
|
||||
|
||||
const beforeDate = format(subDays(new Date(), 1), 'dd/MM/yyyy');
|
||||
const currentDate = DateUtil.formatDate('DD/MM/YYYY');
|
||||
const currentDate = format(new Date(), 'dd/MM/yyyy');
|
||||
const afterDate = format(addDays(new Date(), 1), 'dd/MM/yyyy');
|
||||
|
||||
beforeAll(async () => {
|
||||
|
@@ -23,7 +23,7 @@ import { ProcessServiceTabBarPage } from '../pages/process-service-tab-bar.page'
|
||||
import { ProcessListPage } from '../pages/process-list.page';
|
||||
import { ProcessDetailsPage } from '../pages/process-details.page';
|
||||
import { AppDefinitionRepresentation, ProcessInstanceRepresentation, ProcessInstancesApi } from '@alfresco/js-api';
|
||||
import { DateFnsUtils } from '../../../lib/core/src/lib/common/utils/date-fns-utils';
|
||||
import { format } from 'date-fns';
|
||||
|
||||
describe('Process Instance Details', () => {
|
||||
const app = browser.params.resources.Files.SIMPLE_APP_WITH_USER_FORM;
|
||||
@@ -45,8 +45,6 @@ describe('Process Instance Details', () => {
|
||||
let process: ProcessInstanceRepresentation;
|
||||
let user: UserModel;
|
||||
|
||||
const PROCESS_DATE_FORMAT = 'll';
|
||||
|
||||
beforeAll(async () => {
|
||||
await apiService.loginWithProfile('admin');
|
||||
|
||||
@@ -76,6 +74,10 @@ describe('Process Instance Details', () => {
|
||||
|
||||
it('[C307031] Should display the created date in the default format', async () => {
|
||||
await processDetailsPage.checkProcessHeaderDetailsAreVisible();
|
||||
await expect(await processDetailsPage.getCreated()).toEqual(DateFnsUtils.formatDate(process.started, PROCESS_DATE_FORMAT));
|
||||
|
||||
const created = await processDetailsPage.getCreated();
|
||||
const expected = format(process.started, 'PP');
|
||||
|
||||
expect(created).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
@@ -7,5 +7,8 @@
|
||||
"C216430": "https://alfresco.atlassian.net/browse/ACS-4595",
|
||||
"C280063": "https://alfresco.atlassian.net/browse/ACS-4595",
|
||||
"C280064": "https://alfresco.atlassian.net/browse/ACS-4595",
|
||||
"C313200": "https://alfresco.atlassian.net/browse/APPS-2234"
|
||||
"C313200": "https://alfresco.atlassian.net/browse/APPS-2234",
|
||||
"C311318-3": "https://alfresco.atlassian.net/browse/APPS-2254",
|
||||
"C311319-2": "https://alfresco.atlassian.net/browse/APPS-2254",
|
||||
"C311319-4": "https://alfresco.atlassian.net/browse/APPS-2254"
|
||||
}
|
||||
|
@@ -15,30 +15,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
BrowserActions,
|
||||
DataTableComponentPage,
|
||||
DatePickerCalendarPage,
|
||||
DateUtil,
|
||||
LocalStorageUtil,
|
||||
LoginPage
|
||||
} from '@alfresco/adf-testing';
|
||||
import { BrowserActions, DataTableComponentPage, DateUtil, LoginPage } from '@alfresco/adf-testing';
|
||||
import { browser, ElementFinder } from 'protractor';
|
||||
import { SearchBarPage } from '../pages/search-bar.page';
|
||||
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
|
||||
import { SearchFiltersPage } from '../pages/search-filters.page';
|
||||
import { SearchResultsPage } from '../pages/search-results.page';
|
||||
import { SearchConfiguration } from '../search.config';
|
||||
|
||||
describe('Search Date Range Filter', () => {
|
||||
|
||||
const loginPage = new LoginPage();
|
||||
const searchBarPage = new SearchBarPage();
|
||||
const searchFilters = new SearchFiltersPage();
|
||||
const dateRangeFilter = searchFilters.createdDateRangeFilterPage();
|
||||
const searchResults = new SearchResultsPage();
|
||||
const datePicker = new DatePickerCalendarPage();
|
||||
const navigationBar = new NavigationBarPage();
|
||||
const dataTable = new DataTableComponentPage();
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -58,29 +46,6 @@ describe('Search Date Range Filter', () => {
|
||||
|
||||
afterEach(async () => {
|
||||
await browser.refresh();
|
||||
});
|
||||
|
||||
it('[C277106] Should display default values for Date Range widget', async () => {
|
||||
await dateRangeFilter.checkFromFieldIsDisplayed();
|
||||
await dateRangeFilter.checkFromDateToggleIsDisplayed();
|
||||
await dateRangeFilter.checkToFieldIsDisplayed();
|
||||
await dateRangeFilter.checkToDateToggleIsDisplayed();
|
||||
await dateRangeFilter.checkApplyButtonIsDisplayed();
|
||||
await dateRangeFilter.checkApplyButtonIsDisabled();
|
||||
await dateRangeFilter.checkClearButtonIsDisplayed();
|
||||
});
|
||||
|
||||
it('[C277104] Should be able to set dates using date pickers', async () => {
|
||||
await dateRangeFilter.checkFromDateToggleIsDisplayed();
|
||||
const fromDatePicker = await dateRangeFilter.openFromDatePicker();
|
||||
await fromDatePicker.selectTodayDate();
|
||||
await expect(await dateRangeFilter.getFromDate()).toEqual(await dateRangeFilter.getFromCalendarSelectedDate());
|
||||
});
|
||||
|
||||
it('[C277105] Should be able to type a date', async () => {
|
||||
const date = '01-May-18';
|
||||
await dateRangeFilter.putFromDate(date);
|
||||
await expect(await dateRangeFilter.getFromCalendarSelectedDate()).toEqual(await dateRangeFilter.getFromDate());
|
||||
});
|
||||
|
||||
it('[C277119] FROM and TO dates should depend on each other', async () => {
|
||||
@@ -129,7 +94,7 @@ describe('Search Date Range Filter', () => {
|
||||
|
||||
await searchResults.sortByCreated('ASC');
|
||||
|
||||
const results = await dataTable.geCellElementDetail('Created') as ElementFinder[];
|
||||
const results = (await dataTable.geCellElementDetail('Created')) as ElementFinder[];
|
||||
for (const currentResult of results) {
|
||||
const currentDate = await BrowserActions.getAttribute(currentResult, 'title');
|
||||
const currentDateFormatted = DateUtil.parse(currentDate, 'MMM DD, YYYY, h:mm:ss a');
|
||||
@@ -138,66 +103,4 @@ describe('Search Date Range Filter', () => {
|
||||
await expect(currentDateFormatted >= DateUtil.parse(fromDate, 'DD-MM-YY')).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('[C277108] Should display a warning message when user doesn\'t set the date range at all', async () => {
|
||||
await dateRangeFilter.checkFromFieldIsDisplayed();
|
||||
await dateRangeFilter.clickFromField();
|
||||
await dateRangeFilter.clickToField();
|
||||
await dateRangeFilter.checkFromErrorMessageIsDisplayed('Required value');
|
||||
await dateRangeFilter.clickFromField();
|
||||
await dateRangeFilter.checkToErrorMessageIsDisplayed('Required value');
|
||||
});
|
||||
|
||||
it('[C277114] Should display warning message if user doesn\'t set the date range properly', async () => {
|
||||
const toDate = '01-May-18';
|
||||
const fromDate = '16-May-18';
|
||||
|
||||
await dateRangeFilter.checkToFieldIsDisplayed();
|
||||
await dateRangeFilter.putToDate(toDate);
|
||||
await dateRangeFilter.checkFromFieldIsDisplayed();
|
||||
await dateRangeFilter.putFromDate(fromDate);
|
||||
await dateRangeFilter.clickFromField();
|
||||
await dateRangeFilter.checkToErrorMessageIsDisplayed('No days selected.');
|
||||
});
|
||||
|
||||
it('[C277115] Should display warning message if user types a date later than today\'s date', async () => {
|
||||
await dateRangeFilter.checkFromFieldIsDisplayed();
|
||||
await dateRangeFilter.putFromDate(DateUtil.formatDate('DD-MMM-YY', new Date(), 1));
|
||||
await dateRangeFilter.checkFromErrorMessageIsDisplayed('The date is beyond the maximum date.');
|
||||
});
|
||||
|
||||
it('[C277108] Should display a warning message when user doesn\'t set the date range at all', async () => {
|
||||
await dateRangeFilter.checkFromFieldIsDisplayed();
|
||||
await dateRangeFilter.putFromDate('Wrong Format');
|
||||
await dateRangeFilter.clickToField();
|
||||
await dateRangeFilter.checkFromErrorMessageIsDisplayed('Invalid date. The date must be in the format \'DD-MMM-YY\'');
|
||||
await dateRangeFilter.putFromDate('01-May-18');
|
||||
await dateRangeFilter.checkFromErrorMessageIsNotDisplayed();
|
||||
});
|
||||
|
||||
describe('configuration change', () => {
|
||||
it('[C277117] Should be able to change date format', async () => {
|
||||
await navigationBar.navigateToContentServices();
|
||||
|
||||
const jsonFile= SearchConfiguration.getConfiguration();
|
||||
jsonFile.categories[4].component.settings.dateFormat = 'MM-DD-YY';
|
||||
|
||||
await LocalStorageUtil.setConfigField('search', JSON.stringify(jsonFile));
|
||||
|
||||
await searchBarPage.clickOnSearchIcon();
|
||||
await searchBarPage.enterTextAndPressEnter('*');
|
||||
await searchResults.dataTable.waitTillContentLoaded();
|
||||
|
||||
await searchFilters.checkCreatedRangeFilterIsDisplayed();
|
||||
await searchFilters.clickCreatedRangeFilterHeader();
|
||||
await searchFilters.checkCreatedRangeFilterIsExpanded();
|
||||
await dateRangeFilter.checkFromFieldIsDisplayed();
|
||||
await dateRangeFilter.openFromDatePicker();
|
||||
|
||||
const todayDate = DateUtil.formatDate('MM-DD-YY');
|
||||
await datePicker.selectTodayDate();
|
||||
|
||||
await expect(await dateRangeFilter.getFromDate()).toEqual(todayDate);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user