Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APPS-2132] migrate components to date-fns #9001

Merged
merged 21 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions e2e/process-services-cloud/process/process-filter-results.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import { createApiService,
AppListCloudPage,
DateUtil,
GroupIdentityService,
IdentityService,
LocalStorageUtil,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -315,43 +323,43 @@ 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();
await editProcessFilter.setProperty('lastModifiedFrom', afterDate);
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();
await editProcessFilter.setProcessName(runningProcessInstance.entry.name);
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 () => {
Expand Down
10 changes: 6 additions & 4 deletions e2e/process-services/process/process-instance-details.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');

Expand Down Expand Up @@ -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);
});
});
5 changes: 4 additions & 1 deletion e2e/protractor.excludes.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
101 changes: 2 additions & 99 deletions e2e/search/components/search-date-range.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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');
Expand All @@ -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);
});
});
});
Loading
Loading