[APPS-2136] migrate search-datetime-range to date-fns (#9004)

* 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
This commit is contained in:
Denys Vuika
2023-10-18 07:56:10 +01:00
committed by GitHub
parent af24aceb65
commit 7d5fbecf3f
22 changed files with 350 additions and 428 deletions

View File

@@ -16,13 +16,12 @@
*/
import { element, by, $ } from 'protractor';
import { DateUtil } from '../../utils/date-util';
import { BrowserVisibility } from '../../utils/browser-visibility';
import { BrowserActions } from '../../utils/browser-actions';
import { TestElement } from '../../test-element';
import { addDays, format, subDays } from 'date-fns';
export class DatePickerCalendarPage {
datePicker = $('mat-calendar[id*="mat-datepicker"]');
nextMonthButton = $('button[class*="mat-calendar-next-button"]');
previousMonthButton = $('button[class*="mat-calendar-previous-button"]');
@@ -33,8 +32,8 @@ export class DatePickerCalendarPage {
return BrowserActions.getAttribute($('button[class*="mat-calendar-body-active"]'), 'aria-label');
}
async checkDatesAfterDateAreDisabled(date): Promise<void> {
const afterDate = DateUtil.formatDate('DD-MM-YY', date, 1);
async checkDatesAfterDateAreDisabled(date: Date): Promise<void> {
const afterDate = format(addDays(date, 1), 'dd-MM-yy');
const afterCalendar = $(`td[class*="mat-calendar-body-cell"][aria-label="${afterDate}"]`);
if (await afterCalendar.isPresent()) {
const aria = await BrowserActions.getAttribute(afterCalendar, 'aria-disabled');
@@ -44,8 +43,8 @@ export class DatePickerCalendarPage {
await expect(isEnabled).toBe(false);
}
async checkDatesBeforeDateAreDisabled(date): Promise<void> {
const beforeDate = DateUtil.formatDate('DD-MM-YY', date, -1);
async checkDatesBeforeDateAreDisabled(date: Date): Promise<void> {
const beforeDate = format(subDays(date, 1), 'dd-MM-yy');
const beforeCalendar = $(`td[class*="mat-calendar-body-cell"][aria-label="${beforeDate}"]`);
if (await beforeCalendar.isPresent()) {
const aria = await BrowserActions.getAttribute(beforeCalendar, 'aria-disabled');

View File

@@ -1,29 +0,0 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 * as moment from 'moment';
export class DateUtil {
static formatDate(dateFormat: string, date: Date = new Date(), days: number | string = 0): string {
return moment(date).add(days, 'days').format(dateFormat);
}
static parse(date: string, dateFormat: string = 'DD-MM-YY'): Date {
return moment(date, dateFormat).toDate();
}
}

View File

@@ -22,6 +22,5 @@ export * from './protractor.util';
export * from './local-storage.util';
export * from './file-browser.util';
export * from './form.util';
export * from './date-util';
export * from './wait-actions';
export * from './logger';