Fixing e2e - changing toggles

This commit is contained in:
Vito Albano
2023-12-08 13:43:55 +00:00
committed by VitoAlbano
parent 9acc61d7a3
commit 17687c364b
2 changed files with 26 additions and 9 deletions

View File

@@ -33,6 +33,7 @@ export class DataTableComponentPage {
selectedRowNumber: ElementFinder; selectedRowNumber: ElementFinder;
allSelectedRows: ElementArrayFinder; allSelectedRows: ElementArrayFinder;
selectAll: ElementFinder; selectAll: ElementFinder;
selectAllChecked: ElementFinder;
emptyList: ElementFinder; emptyList: ElementFinder;
emptyListTitle: ElementFinder; emptyListTitle: ElementFinder;
emptyListSubtitle: ElementFinder; emptyListSubtitle: ElementFinder;
@@ -67,12 +68,12 @@ export class DataTableComponentPage {
async checkAllRows(): Promise<void> { async checkAllRows(): Promise<void> {
await BrowserActions.click(this.selectAll); await BrowserActions.click(this.selectAll);
await BrowserVisibility.waitUntilElementIsVisible(this.selectAll.$('input[aria-checked="true"]')); await BrowserVisibility.waitUntilElementIsVisible(this.selectAllChecked);
} }
async uncheckAllRows(): Promise<void> { async uncheckAllRows(): Promise<void> {
await BrowserActions.click(this.selectAll); await BrowserActions.click(this.selectAll);
await BrowserVisibility.waitUntilElementIsNotVisible(this.selectAll.$('input[aria-checked="true"]')); await BrowserVisibility.waitUntilElementIsNotVisible(this.selectAll.$('.mat-mdc-checkbox-checked'));
} }
async clickCheckbox(columnName: string, columnValue: string): Promise<void> { async clickCheckbox(columnName: string, columnValue: string): Promise<void> {
@@ -81,18 +82,23 @@ export class DataTableComponentPage {
} }
async checkRowIsNotChecked(columnName: string, columnValue: string): Promise<void> { async checkRowIsNotChecked(columnName: string, columnValue: string): Promise<void> {
await BrowserVisibility.waitUntilElementIsNotVisible(this.getRowCheckbox(columnName, columnValue).$('input[aria-checked="true"]')); const rowSelector = this.getRowCheckboxChecked(columnName, columnValue);
await BrowserVisibility.waitUntilElementIsNotVisible(rowSelector);
} }
async checkRowIsChecked(columnName: string, columnValue: string): Promise<void> { async checkRowIsChecked(columnName: string, columnValue: string): Promise<void> {
const rowCheckbox = this.getRowCheckbox(columnName, columnValue); const rowCheckbox = this.getRowCheckboxChecked(columnName, columnValue);
await BrowserVisibility.waitUntilElementIsVisible(rowCheckbox.$('input[aria-checked="true"]')); await BrowserVisibility.waitUntilElementIsVisible(rowCheckbox);
} }
getRowCheckbox(columnName: string, columnValue: string): ElementFinder { getRowCheckbox(columnName: string, columnValue: string): ElementFinder {
return this.getRow(columnName, columnValue).$(materialLocators.Checkbox.root); return this.getRow(columnName, columnValue).$(materialLocators.Checkbox.root);
} }
getRowCheckboxChecked(columnName: string, columnValue: string): ElementFinder {
return this.getRow(columnName, columnValue).$('mat-checkbox.mat-mdc-checkbox-checked');
}
async checkNoRowIsSelected(): Promise<void> { async checkNoRowIsSelected(): Promise<void> {
await BrowserVisibility.waitUntilElementIsNotVisible(this.selectedRowNumber); await BrowserVisibility.waitUntilElementIsNotVisible(this.selectedRowNumber);
} }

View File

@@ -68,6 +68,7 @@ export class SettingsPage {
await this.setIdentityHost(identityHost); await this.setIdentityHost(identityHost);
await this.setSilentLogin(silentLogin); await this.setSilentLogin(silentLogin);
await this.setImplicitFlow(implicitFlow); await this.setImplicitFlow(implicitFlow);
await this.setCodeFlow(true);
await this.setClientId(clientId); await this.setClientId(clientId);
await this.setLogoutUrl(logoutUrl); await this.setLogoutUrl(logoutUrl);
await this.clickApply(); await this.clickApply();
@@ -100,22 +101,32 @@ export class SettingsPage {
} }
async setSilentLogin(enableToggle) { async setSilentLogin(enableToggle) {
await BrowserVisibility.waitUntilElementIsVisible(this.silentLoginToggleElement); await BrowserVisibility.waitUntilElementIsVisible(this.silentLoginToggleButton);
const isChecked = (await BrowserActions.getAttribute(this.silentLoginToggleElement, 'class')).includes(materialLocators.Checked.root); const isChecked = (await BrowserActions.getAttribute(this.silentLoginToggleElement, 'class')).includes(materialLocators.Checked.root);
if (isChecked && !enableToggle || !isChecked && enableToggle) { if (isChecked && !enableToggle || !isChecked && enableToggle) {
await BrowserActions.click(this.silentLoginToggleLabel); await BrowserActions.click(this.silentLoginToggleButton);
} }
} }
async setImplicitFlow(enableToggle) { async setImplicitFlow(enableToggle) {
await BrowserVisibility.waitUntilElementIsVisible(this.implicitFlowElement); await BrowserVisibility.waitUntilElementIsVisible(this.implicitFlowButton);
const isChecked = (await BrowserActions.getAttribute(this.implicitFlowElement, 'class')).includes(materialLocators.Checked.root); const isChecked = (await BrowserActions.getAttribute(this.implicitFlowElement, 'class')).includes(materialLocators.Checked.root);
if (isChecked && !enableToggle || !isChecked && enableToggle) { if (isChecked && !enableToggle || !isChecked && enableToggle) {
await BrowserActions.click(this.implicitFlowLabel); await BrowserActions.click(this.implicitFlowButton);
}
}
async setCodeFlow(enableToggle) {
await BrowserVisibility.waitUntilElementIsVisible(this.codeFlowButton);
const isChecked = (await BrowserActions.getAttribute(this.codeFlowButton, 'aria-checked')) === 'true';
if (isChecked && !enableToggle || !isChecked && enableToggle) {
await BrowserActions.click(this.codeFlowButton);
} }
} }
} }