mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
[ACS-7334] [E2E] Search filters - date - tests migrated to Playwright (#3770)
* [ACS-7334] [E2E] Search filters - date - tests migrated to Playwright * [ACS-7334] sonar cloud fix 1 * [ACS-7334] review fix 1 * [ACS-7334] review fix 2
This commit is contained in:
@@ -26,6 +26,7 @@ const crypto = require('crypto');
|
||||
import * as path from 'path';
|
||||
import { LoginPage, MyLibrariesPage, PersonalFilesPage, FavoritesLibrariesPage, SearchPage, SharedPage, TrashPage } from '../';
|
||||
import { NodesApi, TrashcanApi, SitesApi } from '@alfresco/playwright-shared';
|
||||
import { format, subDays, subMonths, endOfMonth } from 'date-fns';
|
||||
|
||||
export class Utils {
|
||||
static string257Long = 'x'.repeat(257);
|
||||
@@ -105,9 +106,9 @@ export class Utils {
|
||||
errorMessage = 'reloadPageIfRowNotVisible Error '
|
||||
): Promise<void> {
|
||||
try {
|
||||
if (!await pageContext.dataTable.getRowByName(nodeName).isVisible()) {
|
||||
if (!(await pageContext.dataTable.getRowByName(nodeName).isVisible())) {
|
||||
await pageContext.page.reload({ waitUntil: 'load' });
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`${errorMessage}: ${error}`);
|
||||
}
|
||||
@@ -118,11 +119,31 @@ export class Utils {
|
||||
errorMessage = 'reloadPageIfDatatableEmpty Error '
|
||||
): Promise<void> {
|
||||
try {
|
||||
if (await pageContext.dataTable.getEmptyFolderLocator.isVisible() || await pageContext.dataTable.emptyListTitle.isVisible()) {
|
||||
if ((await pageContext.dataTable.getEmptyFolderLocator.isVisible()) || (await pageContext.dataTable.emptyListTitle.isVisible())) {
|
||||
await pageContext.page.reload({ waitUntil: 'load' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`${errorMessage}: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
static getCurrentAndPreviousDay(currentDate = new Date()): { currentDate: string; previousDate: string } {
|
||||
let formattedDate: string;
|
||||
let formattedDate2: string;
|
||||
|
||||
const formatDate = (date: Date): string => {
|
||||
return format(date, 'dd-MMM-yy').toUpperCase();
|
||||
};
|
||||
|
||||
if (currentDate.getDate() === 1) {
|
||||
const lastDayOfPreviousMonth: Date = endOfMonth(subMonths(currentDate, 1));
|
||||
formattedDate = formatDate(lastDayOfPreviousMonth);
|
||||
formattedDate2 = formatDate(subDays(lastDayOfPreviousMonth, 1));
|
||||
} else {
|
||||
formattedDate = formatDate(currentDate);
|
||||
formattedDate2 = formatDate(subDays(currentDate, 1));
|
||||
}
|
||||
|
||||
return { currentDate: formattedDate, previousDate: formattedDate2 };
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user