ESLint: cleanup await expect from protractor tests (#9630)

This commit is contained in:
Denys Vuika
2024-04-30 08:07:10 -04:00
committed by GitHub
parent 4109f272ea
commit f401b8c13e
114 changed files with 2096 additions and 1908 deletions

View File

@@ -32,7 +32,6 @@
"accessibility": "explicit"
}
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-require-imports": "off",
"@typescript-eslint/no-var-requires": "error",

View File

@@ -25,7 +25,6 @@ import { BrowserActions } from '../../../core/utils/browser-actions';
import { BrowserVisibility } from '../../../core/utils/browser-visibility';
export class SearchCategoriesPage {
static checkListFiltersPage(filter: ElementFinder): SearchCheckListPage {
return new SearchCheckListPage(filter);
}
@@ -59,14 +58,13 @@ export class SearchCategoriesPage {
await BrowserActions.click(fileSizeFilterHeader);
}
async checkFilterIsCollapsed(filter: ElementFinder): Promise<void> {
async checkFilterIsCollapsed(filter: ElementFinder) {
const elementClass = await BrowserActions.getAttribute(filter, 'class');
await expect(elementClass).not.toContain('mat-expanded');
expect(elementClass).not.toContain('mat-expanded');
}
async checkFilterIsExpanded(filter: ElementFinder): Promise<void> {
async checkFilterIsExpanded(filter: ElementFinder) {
const elementClass = await BrowserActions.getAttribute(filter, 'class');
await expect(elementClass).toContain('mat-expanded');
expect(elementClass).toContain('mat-expanded');
}
}

View File

@@ -66,7 +66,7 @@ export class DynamicTableWidgetPage {
const dataTableInput = $(`#${id}`);
await BrowserVisibility.waitUntilElementIsVisible(dataTableInput);
await BrowserActions.clearSendKeys(dataTableInput, text);
}
}
async getTableRowText(rowNumber): Promise<string> {
const tableRowByIndex = this.getTableRowByIndex(rowNumber);
@@ -121,7 +121,7 @@ export class DynamicTableWidgetPage {
async checkItemIsPresent(item): Promise<void> {
const row = element(by.cssContainingText('table tbody tr td span', item));
const present = await BrowserVisibility.waitUntilElementIsVisible(row);
await expect(present).toBe(true);
expect(present).toBe(true);
}
private getTableRowByIndex = (idx: string) => $(`#dynamictable-row-${idx}`);

View File

@@ -21,7 +21,6 @@ import { BrowserVisibility, BrowserActions } from '../../../utils/public-api';
import { materialLocators } from '../../public-api';
export class GroupWidgetPage {
groupField = $('input[data-automation-id="adf-group-search-input"]');
firstResult = $('#adf-group-widget-user-0');
formFields = new FormFields();
@@ -39,7 +38,7 @@ export class GroupWidgetPage {
return this.formFields.getFieldText(fieldId);
}
insertGroup(fieldId, value): Promise<void> {
insertGroup(fieldId: string, value: string): Promise<void> {
return this.formFields.setValueInInputById(fieldId, value);
}
@@ -52,13 +51,13 @@ export class GroupWidgetPage {
await BrowserVisibility.waitUntilElementIsVisible(groupElement);
}
async getDropDownList(): Promise<any[]> {
async getDropDownList(): Promise<string[]> {
const user: Locator = by.css('[id="adf-group-label-name"]');
await BrowserVisibility.waitUntilElementIsVisible(element(user));
return element.all(user).map((elementFinder) => elementFinder.getText());
}
async selectGroupFromDropDown(groupName): Promise<void> {
async selectGroupFromDropDown(groupName: string): Promise<void> {
const group = element(by.cssContainingText('[id="adf-group-label-name"]', groupName));
await BrowserActions.click(group);
}

View File

@@ -40,10 +40,10 @@ export class DatePickerCalendarPage {
const afterCalendar = $(`td[class*="${materialLocators.Calendar.body.cell.root}"][aria-label="${afterDate}"]`);
if (await afterCalendar.isPresent()) {
const aria = await BrowserActions.getAttribute(afterCalendar, 'aria-disabled');
await expect(aria).toBe('true');
expect(aria).toBe('true');
}
const isEnabled = await this.nextMonthButton.isEnabled();
await expect(isEnabled).toBe(false);
expect(isEnabled).toBe(false);
}
async checkDatesBeforeDateAreDisabled(date: Date): Promise<void> {
@@ -51,10 +51,10 @@ export class DatePickerCalendarPage {
const beforeCalendar = $(`td[class*="${materialLocators.Calendar.body.cell.root}"][aria-label="${beforeDate}"]`);
if (await beforeCalendar.isPresent()) {
const aria = await BrowserActions.getAttribute(beforeCalendar, 'aria-disabled');
await expect(aria).toBe('true');
expect(aria).toBe('true');
}
const isEnabled = await this.previousMonthButton.isEnabled();
await expect(isEnabled).toBe(false);
expect(isEnabled).toBe(false);
}
async selectTodayDate(): Promise<void> {

View File

@@ -21,7 +21,6 @@ import { BrowserVisibility } from '../../utils/browser-visibility';
import { materialLocators } from './material-locators';
export class TabsPage {
tabs = $$(`div[id*='${materialLocators.Tab.label.root}']`);
async clickTabByTitle(tabTitle): Promise<void> {
@@ -31,8 +30,8 @@ export class TabsPage {
async checkTabIsSelectedByTitle(tabTitle): Promise<void> {
const tab = element(by.cssContainingText(`div[id*='${materialLocators.Tab.label.root}']`, tabTitle));
const result = await BrowserActions.getAttribute(tab, 'aria-selected');
await expect(result).toBe('true');
const result: string = await BrowserActions.getAttribute(tab, 'aria-selected');
expect(result).toBe('true');
}
async getNoOfTabs(): Promise<number> {

View File

@@ -115,7 +115,7 @@ export class ViewerPage {
async checkAllThumbnailsDisplayed(nbPages): Promise<void> {
const defaultThumbnailHeight = 143;
await expect(await BrowserActions.getAttribute(this.thumbnailsContent, 'style')).toEqual(
expect(await BrowserActions.getAttribute(this.thumbnailsContent, 'style')).toEqual(
'height: ' + nbPages * defaultThumbnailHeight + 'px; transform: translate(-50%, 0px);'
);
}
@@ -124,7 +124,7 @@ export class ViewerPage {
const selectedThumbnail = $('adf-pdf-thumb.adf-pdf-thumbnails__thumb.adf-pdf-thumbnails__thumb--selected > img');
const pageNumber = await BrowserActions.getInputValue(this.pageSelectorInput);
await expect('Page ' + pageNumber).toEqual(await BrowserActions.getAttribute(selectedThumbnail, 'title'));
expect('Page ' + pageNumber).toEqual(await BrowserActions.getAttribute(selectedThumbnail, 'title'));
}
async checkThumbnailsCloseIsDisplayed(): Promise<void> {
@@ -193,7 +193,7 @@ export class ViewerPage {
}
async checkPageSelectorInputIsDisplayed(checkNumber: string): Promise<void> {
await expect(await BrowserActions.getInputValue(this.pageSelectorInput)).toEqual(checkNumber);
expect(await BrowserActions.getInputValue(this.pageSelectorInput)).toEqual(checkNumber);
}
async checkImgContainerIsDisplayed(): Promise<void> {
@@ -225,11 +225,11 @@ export class ViewerPage {
}
async checkZoomedIn(zoom): Promise<void> {
await expect(await BrowserActions.getText(this.percentage)).toBeGreaterThan(zoom);
expect(await BrowserActions.getText(this.percentage)).toBeGreaterThan(zoom);
}
async checkZoomedOut(zoom): Promise<void> {
await expect(await BrowserActions.getText(this.percentage)).toBeLessThan(zoom);
expect(await BrowserActions.getText(this.percentage)).toBeLessThan(zoom);
}
async checkScaleImgButtonIsDisplayed(): Promise<void> {
@@ -254,9 +254,7 @@ export class ViewerPage {
async checkTabIsActive(tabName: string): Promise<void> {
const materialLocatorPart = `div${materialLocators.Tab.labels.class} div${materialLocators.Tab.label.active.class} ${materialLocators.Tab.label.content.class}`;
const tab = element(
by.cssContainingText(`.adf-info-drawer-layout-content ${materialLocatorPart}`, tabName)
);
const tab = element(by.cssContainingText(`.adf-info-drawer-layout-content ${materialLocatorPart}`, tabName));
await BrowserVisibility.waitUntilElementIsVisible(tab);
}
@@ -330,7 +328,7 @@ export class ViewerPage {
}
async expectUrlToContain(text: string): Promise<void> {
await expect(browser.getCurrentUrl()).toContain(text);
expect(browser.getCurrentUrl()).toContain(text);
}
private async isSpinnerPresent(): Promise<boolean> {

View File

@@ -20,14 +20,15 @@ import * as fs from 'fs';
import { browser } from 'protractor';
export class FileBrowserUtil {
static async isFileDownloaded(fileName: string): Promise<boolean> {
const DEFAULT_ROOT_PATH = browser.params.testConfig ? browser.params.testConfig.main.rootPath : __dirname;
const file = await browser.driver.wait(() => fs.existsSync(path.join(DEFAULT_ROOT_PATH, 'downloads', fileName)), 30000,`${fileName} not downloaded`);
await expect(file).toBe(true, `${fileName} not downloaded`);
const file: boolean = await browser.driver.wait(
() => fs.existsSync(path.join(DEFAULT_ROOT_PATH, 'downloads', fileName)),
30000,
`${fileName} not downloaded`
);
expect(file).toBe(true);
return !!file;
}
}

View File

@@ -24,7 +24,6 @@ import { Logger } from '../../core/utils/logger';
import { materialLocators } from '../../public-api';
export class StartProcessPage {
defaultProcessName = $('input[id="processName"]');
processNameInput = $('#processName');
disabledSelectProcessDropdown = $('input[id="processDefinitionName"][disabled]');
@@ -82,7 +81,6 @@ export class StartProcessPage {
} catch (error) {
Logger.log(`No start form on process`);
}
}
async selectFromApplicationDropdown(name): Promise<void> {
@@ -138,7 +136,7 @@ export class StartProcessPage {
}
async checkStartProcessButtonIsDisabled() {
await expect(await this.startProcessButton.isEnabled()).toBe(false);
expect(await this.startProcessButton.isEnabled()).toBe(false);
}
async clickStartProcessButton(): Promise<void> {