Skip to content

Commit

Permalink
[APPS-2108] date-fns adapter for datetime pickers, many datetime pars…
Browse files Browse the repository at this point in the history
…ing and validation fixes (#8992)

* migrate cloud date widget to date-fns, fix test bugs

* [ci:force] update docs

* [ci:force] remove commented out code

* [APPS-2232] date cell validator, unit tests

* improved moment adapter, code cleanup

* datetime adapter, many code fixes

* code review fixes

* code cleanup

* cleanup

* fix max datetime validation, update tests

* remove e2e already covered by unit tests

* fix search date range

* remove fake demo shell e2e for search

* remove fake demo shell e2e for search page

* cleanup e2e

* migrate dynamic table to date-fns

* fix e2e formatting

* migrate protractor to unit tests

* cleanup e2e
  • Loading branch information
DenysVuika authored Oct 15, 2023
1 parent c637f3e commit 2f36da5
Show file tree
Hide file tree
Showing 37 changed files with 881 additions and 1,059 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
LoginPage,
TasksService,
IdentityService,
GroupIdentityService
GroupIdentityService,
EditTaskFilterDialogPage
} from '@alfresco/adf-testing';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
import { TasksCloudDemoPage } from './../pages/tasks-cloud-demo.page';
Expand All @@ -38,6 +39,7 @@ describe('Edit task filters cloud', () => {
const tasksCloudDemoPage = new TasksCloudDemoPage();
const editTaskFilter = tasksCloudDemoPage.editTaskFilterCloud;
const taskFilter = tasksCloudDemoPage.taskFilterCloudComponent;
const editTaskFilterDialog = new EditTaskFilterDialogPage();

const apiService = createApiService();
const identityService = new IdentityService(apiService);
Expand All @@ -49,10 +51,18 @@ describe('Edit task filters cloud', () => {
const completedTaskName = StringUtil.generateRandomString();
const assignedTaskName = StringUtil.generateRandomString();

/**
* Click on the specified task filter
*
* @param name filter name
*/
async function clickTaskFilter(name: string) {
await taskFilter.clickTaskFilter(name);
}

/**
* Wait till the datatable component is loaded
*/
async function waitTillContentLoaded() {
await tasksCloudDemoPage.taskListCloudComponent().getDataTable().waitTillContentLoaded();
}
Expand Down Expand Up @@ -187,7 +197,6 @@ describe('Edit task filters cloud', () => {

await editTaskFilter.clickSaveAsButton();

const editTaskFilterDialog = editTaskFilter.editTaskFilterDialog();
await editTaskFilterDialog.setFilterName('New');
await editTaskFilterDialog.clickOnSaveButton();

Expand All @@ -197,8 +206,8 @@ describe('Edit task filters cloud', () => {
await expect(await editTaskFilter.getSortFilterDropDownValue()).toEqual('id');
await editTaskFilter.setSortFilterDropDown('priority');
await editTaskFilter.clickSaveAsButton();
await editTaskFilter.editTaskFilterDialog().setFilterName('New');
await editTaskFilter.editTaskFilterDialog().clickOnSaveButton();
await editTaskFilterDialog.setFilterName('New');
await editTaskFilterDialog.clickOnSaveButton();

await expect(await taskFilter.getActiveFilterName()).toBe('New');
await editTaskFilter.openFilter();
Expand All @@ -224,7 +233,6 @@ describe('Edit task filters cloud', () => {

await editTaskFilter.clickSaveAsButton();

const editTaskFilterDialog = await editTaskFilter.editTaskFilterDialog();
await editTaskFilterDialog.setFilterName('New');
await editTaskFilterDialog.clickOnSaveButton();

Expand Down Expand Up @@ -252,7 +260,6 @@ describe('Edit task filters cloud', () => {

await editTaskFilter.clickSaveAsButton();

const editTaskFilterDialog = await editTaskFilter.editTaskFilterDialog();
await editTaskFilterDialog.setFilterName('New');
await editTaskFilterDialog.clickOnSaveButton();

Expand All @@ -275,12 +282,10 @@ describe('Edit task filters cloud', () => {
await expect(await editTaskFilter.getSortFilterDropDownValue()).toEqual('priority');
await editTaskFilter.clickSaveAsButton();

const dialog = editTaskFilter.editTaskFilterDialog();

await expect(await dialog.getFilterName()).toEqual('My Tasks');
await dialog.setFilterName('Cancel');
await expect(await dialog.getFilterName()).toEqual('Cancel');
await dialog.clickOnCancelButton();
await expect(await editTaskFilterDialog.getFilterName()).toEqual('My Tasks');
await editTaskFilterDialog.setFilterName('Cancel');
await expect(await editTaskFilterDialog.getFilterName()).toEqual('Cancel');
await editTaskFilterDialog.clickOnCancelButton();

await taskFilter.checkTaskFilterNotDisplayed('Cancel');
await expect(await taskFilter.getActiveFilterName()).toEqual('My Tasks');
Expand All @@ -307,14 +312,12 @@ describe('Edit task filters cloud', () => {
await expect(await editTaskFilter.getSortFilterDropDownValue()).toEqual('id');
await editTaskFilter.clickSaveAsButton();

const dialog = editTaskFilter.editTaskFilterDialog();

await expect(await dialog.getFilterName()).toEqual('My Tasks');
await dialog.clearFilterName();
await expect(await dialog.getFilterName()).toEqual('');
await expect(await dialog.checkSaveButtonIsEnabled()).toEqual(false);
await expect(await dialog.checkCancelButtonIsEnabled()).toEqual(true);
await dialog.clickOnCancelButton();
await expect(await editTaskFilterDialog.getFilterName()).toEqual('My Tasks');
await editTaskFilterDialog.clearFilterName();
await expect(await editTaskFilterDialog.getFilterName()).toEqual('');
await expect(await editTaskFilterDialog.checkSaveButtonIsEnabled()).toEqual(false);
await expect(await editTaskFilterDialog.checkCancelButtonIsEnabled()).toEqual(true);
await editTaskFilterDialog.clickOnCancelButton();
});

it('[C291799] Task filter dialog is displayed when clicking on Save As button', async () => {
Expand All @@ -326,15 +329,18 @@ describe('Edit task filters cloud', () => {
await expect(await editTaskFilter.getSortFilterDropDownValue()).toEqual('id');
await editTaskFilter.clickSaveAsButton();

const dialog = editTaskFilter.editTaskFilterDialog();

await expect(await dialog.checkSaveButtonIsEnabled()).toEqual(true);
await expect(await dialog.checkCancelButtonIsEnabled()).toEqual(true);
await expect(await dialog.getTitle()).toEqual('Save filter as');
await expect(await dialog.getFilterName()).toEqual('My Tasks');
await dialog.clickOnCancelButton();
await expect(await editTaskFilterDialog.checkSaveButtonIsEnabled()).toEqual(true);
await expect(await editTaskFilterDialog.checkCancelButtonIsEnabled()).toEqual(true);
await expect(await editTaskFilterDialog.getTitle()).toEqual('Save filter as');
await expect(await editTaskFilterDialog.getFilterName()).toEqual('My Tasks');
await editTaskFilterDialog.clickOnCancelButton();
});

/**
* Creates new custom filter
*
* @param name Filter name
*/
async function createNewCustomFilter(name: string): Promise<void> {
await clickTaskFilter('my-tasks');
await waitTillContentLoaded();
Expand All @@ -347,8 +353,7 @@ describe('Edit task filters cloud', () => {

await editTaskFilter.clickSaveAsButton();

const dialog = editTaskFilter.editTaskFilterDialog();
await dialog.setFilterName(name);
await dialog.clickOnSaveButton();
await editTaskFilterDialog.setFilterName(name);
await editTaskFilterDialog.clickOnSaveButton();
}
});
85 changes: 1 addition & 84 deletions e2e/process-services/form/dynamic-table-date-picker.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,7 @@
* limitations under the License.
*/

import {
createApiService,
ApplicationsUtil,
DatePickerCalendarPage,
DateUtil,
LoginPage,
ModelsActions,
UsersActions,
Widget,
UserModel
} from '@alfresco/adf-testing';
import { createApiService, ApplicationsUtil, LoginPage, ModelsActions, UsersActions, Widget, UserModel } from '@alfresco/adf-testing';
import { ProcessFiltersPage } from '../pages/process-filters.page';
import { ProcessServiceTabBarPage } from '../pages/process-service-tab-bar.page';
import { NavigationBarPage } from '../../core/pages/navigation-bar.page';
Expand All @@ -35,7 +25,6 @@ describe('Dynamic Table', () => {
const loginPage = new LoginPage();
const processFiltersPage = new ProcessFiltersPage();
const processServiceTabBarPage = new ProcessServiceTabBarPage();
const datePicker = new DatePickerCalendarPage();
const navigationBarPage = new NavigationBarPage();
const widget = new Widget();

Expand All @@ -58,78 +47,6 @@ describe('Dynamic Table', () => {
await usersActions.deleteTenant(tenantId);
});

describe('Date Picker', () => {
const app = browser.params.resources.Files.DYNAMIC_TABLE_APP;

const randomText = {
date: '12/12/2012',
wrongDate: 'HELLO WORLD',
wrongDateTime: 'Test',
dateTime: '15/07/2019 23:55',
error: `Invalid 'columnDate' format.`,
requiredError: `Field 'columnDate' is required.`
};
const currentDate = DateUtil.formatDate('DD-MM-YYYY');
const rowPosition = 0;

beforeAll(async () => {
await apiService.login(user.username, user.password);
const applicationsService = new ApplicationsUtil(apiService);
const importedApp = await applicationsService.importPublishDeployApp(app.file_path);
appId = importedApp.id;
await loginPage.login(user.username, user.password);
});

afterAll(async () => {
await apiService.login(user.username, user.password);
await modelsActions.deleteModel(appId);
await navigationBarPage.clickLogoutButton();
});

beforeEach(async () => {
await (await (await navigationBarPage.navigateToProcessServicesPage()).goToTaskApp()).clickProcessButton();
await processServiceTabBarPage.clickProcessButton();

await processFiltersPage.clickCreateProcessButton();
await processFiltersPage.clickNewProcessDropdown();
});

it('[C286277] Should have a datepicker and a mask for DateTime field', async () => {
await widget.dynamicTable().clickAddRow();
await widget.dynamicTable().clickColumnDateTime();

await expect(await widget.dynamicTable().addRandomStringOnDateTime(randomText.wrongDateTime)).toBe('');
});

it('[C286279] Should be able to save row with Date field', async () => {
await widget.dynamicTable().clickAddRow();
await widget.dynamicTable().addRandomStringOnDate(randomText.wrongDate);
await widget.dynamicTable().clickSaveButton();
await expect(await widget.dynamicTable().checkErrorMessage()).toBe(randomText.error);

await widget.dynamicTable().clickDateWidget();
await datePicker.selectTodayDate();
await datePicker.checkDatePickerIsNotDisplayed();
await widget.dynamicTable().clickSaveButton();
await widget.dynamicTable().getTableRow(rowPosition);
await expect(await widget.dynamicTable().getTableCellText(rowPosition, 1)).toBe(currentDate);
});

it('[C311456] Should be able to delete date that is not mandatory and save the Dynamic Table', async () => {
await widget.dynamicTable().clickAddRow();
await widget.dynamicTable().clickSaveButton();
await expect(await widget.dynamicTable().checkErrorMessage()).toBe(randomText.requiredError);

await widget.dynamicTable().clickDateWidget();
await datePicker.selectTodayDate();
await datePicker.checkDatePickerIsNotDisplayed();
await widget.dynamicTable().clickSaveButton();
await widget.dynamicTable().getTableRow(rowPosition);
await expect(await widget.dynamicTable().getTableCellText(rowPosition, 1)).toBe(currentDate);
await expect(await widget.dynamicTable().getTableCellText(rowPosition, 2)).toBe('');
});
});

describe('Required Dropdown', () => {
const app = browser.params.resources.Files.APP_DYNAMIC_TABLE_DROPDOWN;
const dropdown = widget.dropdown();
Expand Down
104 changes: 0 additions & 104 deletions e2e/process-services/widgets/date-time-widget.e2e.ts

This file was deleted.

8 changes: 1 addition & 7 deletions e2e/protractor.excludes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
"C272819": "https://alfresco.atlassian.net/browse/ADF-5385",
"C362241": "https://alfresco.atlassian.net/browse/ADF-5385",
"C246534": "https://alfresco.atlassian.net/browse/ACS-4468",
"C268151": "https://alfresco.atlassian.net/browse/ACS-4467",
"C260377": "https://alfresco.atlassian.net/browse/ACS-4467",
"C260375": "https://alfresco.atlassian.net/browse/ACS-4467",
"C286290": "https://alfresco.atlassian.net/browse/ACS-4467",
"C286472": "https://alfresco.atlassian.net/browse/ACS-4467",
"C260387": "https://alfresco.atlassian.net/browse/ACS-4595",
"C216430": "https://alfresco.atlassian.net/browse/ACS-4595",
"C280063": "https://alfresco.atlassian.net/browse/ACS-4595",
"C280064": "https://alfresco.atlassian.net/browse/ACS-4595",
"C280407": "https://alfresco.atlassian.net/browse/ACS-4595",
"C277288": "https://alfresco.atlassian.net/browse/AAE-15475"
"C313200": "https://alfresco.atlassian.net/browse/APPS-2234"
}
Loading

0 comments on commit 2f36da5

Please sign in to comment.