E2E: try to fix one weird flaky test (#1401)

This commit is contained in:
Adina Parpalita 2020-04-07 01:53:44 -07:00 committed by GitHub
parent 5a88c8c852
commit 2816e5fe11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 4 deletions

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, until } from 'protractor';
import { ElementFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { GenericDialog } from '../dialog/generic-dialog';
@ -45,6 +45,24 @@ export class PasswordDialog extends GenericDialog {
super(PasswordDialog.selectors.root);
}
async waitForPasswordInputToBeInteractive() {
await browser.wait(EC.elementToBeClickable(this.passwordInput), BROWSER_WAIT_TIMEOUT, '--- timeout wait for passwordInput ---');
}
async waitForDialogToOpen(): Promise<void> {
await super.waitForDialogToOpen();
await this.waitForPasswordInputToBeInteractive();
}
async isDialogOpen(): Promise<boolean> {
try {
await this.waitForDialogToOpen();
return true;
} catch (error) {
return false;
}
}
async isCloseEnabled(): Promise<boolean> {
return this.isButtonEnabled(PasswordDialog.selectors.closeButton);
}
@ -71,8 +89,13 @@ export class PasswordDialog extends GenericDialog {
}
async isErrorDisplayed(): Promise<boolean> {
const elem = await browser.wait(until.elementLocated(by.css(PasswordDialog.selectors.errorMessage)), BROWSER_WAIT_TIMEOUT, '------- timeout waiting for error message to appear')
return (await browser.isElementPresent(elem)) && (await elem.isDisplayed());
try {
await this.waitForDialogToOpen();
return (await this.errorMessage.isPresent()) && (await this.errorMessage.isDisplayed());
} catch (error) {
return false;
}
}
async getErrorMessage(): Promise<string> {

View File

@ -59,6 +59,7 @@ export class Viewer extends Component {
async waitForViewerToOpen() {
try {
await browser.wait(EC.presenceOf(this.viewerContainer), BROWSER_WAIT_TIMEOUT);
await browser.wait(EC.presenceOf(this.viewerLayout), BROWSER_WAIT_TIMEOUT);
} catch (error) {
console.log('\n-----> catch waitForViewerToOpen <-----\n', error)
}

View File

@ -63,7 +63,7 @@ describe('Viewer - password protected file', () => {
await dataTable.waitForHeader();
await dataTable.doubleClickOnRowByName(protectedFile.name);
await viewer.waitForViewerToOpen();
await page.waitForDialog();
await passwordDialog.waitForDialogToOpen();
});
afterEach(async () => {