fix flaky tests (#1461)

This commit is contained in:
Adina Parpalita
2020-05-09 03:36:28 -07:00
committed by GitHub
parent 0e7eed3cd5
commit 03a1a5c0e9
5 changed files with 32 additions and 25 deletions

View File

@@ -47,7 +47,7 @@ export class SearchInput extends Component {
}
async waitForSearchInputToBeInteractive() {
waitForClickable(this.searchControl);
await waitForClickable(this.searchControl);
}
async isSearchContainerDisplayed() {

View File

@@ -108,14 +108,17 @@ describe('Edit folder', () => {
await Promise.all([
apis.admin.sites.deleteSite(sitePrivate),
apis.user.sites.deleteSite(siteName),
apis.user.nodes.deleteNodesById([ parentId, folderFavoriteToEditId, folderFavoriteDuplicateId, folderSearchToEditId ])
apis.user.nodes.deleteNodesById([parentId, folderFavoriteToEditId, folderFavoriteDuplicateId, folderSearchToEditId])
]);
done();
});
afterEach(async (done) => {
beforeEach(async () => {
await Utils.pressEscape();
done();
});
afterEach(async () => {
await page.closeOpenDialogs();
});
it('[C216331] dialog UI defaults', async () => {
@@ -167,7 +170,7 @@ describe('Edit folder', () => {
});
it('[C216333] with name with special characters', async () => {
const namesWithSpecialChars = [ 'a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ];
const namesWithSpecialChars = ['a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a'];
await dataTable.selectItem(folderName);
await toolbar.openMoreMenu();

View File

@@ -87,6 +87,10 @@ describe('Library actions', () => {
done();
});
beforeEach(async () => {
await Utils.pressEscape();
});
afterEach(async (done) => {
await Utils.pressEscape();
await page.header.expandSideNav();

View File

@@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, protractor, ElementFinder, ExpectedConditions as EC, by, logging, until } from 'protractor';
import { browser, protractor, ElementFinder, ExpectedConditions as EC, by, logging, until, WebElement } from 'protractor';
import { Logger } from '@alfresco/adf-testing';
import { BROWSER_WAIT_TIMEOUT, E2E_ROOT_PATH } from '../configs';
@@ -31,21 +31,21 @@ const path = require('path');
const fs = require('fs');
const StreamZip = require('node-stream-zip');
export async function typeText(element: ElementFinder, text: string) {
export async function typeText(element: ElementFinder, text: string): Promise<void> {
await element.clear();
await element.sendKeys(text);
}
export async function clearTextWithBackspace(element: ElementFinder) {
export async function clearTextWithBackspace(element: ElementFinder): Promise<void> {
await element.clear();
await element.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE);
}
export async function waitElement(css: string, errorMessage?: string): Promise<any> {
export async function waitElement(css: string, errorMessage?: string): Promise<WebElement> {
return browser.wait(
until.elementLocated(by.css(css)),
BROWSER_WAIT_TIMEOUT,
errorMessage || 'Timeout waiting for element'
errorMessage || `Timeout waiting for element: ${css}`
);
}
@@ -53,10 +53,10 @@ export async function waitForClickable(
element: ElementFinder,
errorMessage?: string
): Promise<void> {
return browser.wait(
await browser.wait(
EC.elementToBeClickable(element),
BROWSER_WAIT_TIMEOUT,
errorMessage || 'Timeout waiting for element to be clickable'
errorMessage || `Timeout waiting for element to be clickable: ${element.locator()}`
);
}
@@ -64,10 +64,10 @@ export async function waitForVisibility(
element: ElementFinder,
errorMessage?: string
): Promise<void> {
return browser.wait(
await browser.wait(
EC.visibilityOf(element),
BROWSER_WAIT_TIMEOUT,
errorMessage || 'Timeout waiting for element visibility'
errorMessage || `Timeout waiting for element visibility: ${element.locator()}`
);
}
@@ -75,10 +75,10 @@ export async function waitForInvisibility(
element: ElementFinder,
errorMessage?: string
): Promise<void> {
return browser.wait(
await browser.wait(
EC.invisibilityOf(element),
BROWSER_WAIT_TIMEOUT,
errorMessage || 'Timeout waiting for element visibility'
errorMessage || `Timeout waiting for element visibility: ${element.locator()}`
);
}
@@ -86,10 +86,10 @@ export async function waitForPresence(
element: ElementFinder,
errorMessage?: string
): Promise<void> {
return browser.wait(
await browser.wait(
EC.presenceOf(element),
BROWSER_WAIT_TIMEOUT,
errorMessage || 'Timeout waiting for element presence'
errorMessage || `Timeout waiting for element presence: ${element.locator()}`
);
}
@@ -97,10 +97,10 @@ export async function waitForStaleness(
element: ElementFinder,
errorMessage?: string
): Promise<void> {
return browser.wait(
await browser.wait(
EC.stalenessOf(element),
BROWSER_WAIT_TIMEOUT,
errorMessage || 'Timeout waiting element staleness'
errorMessage || `Timeout waiting element staleness: ${element.locator()}`
);
}
@@ -171,9 +171,9 @@ export class Utils {
let tries = 15;
return new Promise(function(resolve) {
return new Promise(function (resolve) {
const checkExist = setInterval(() => {
fs.access(filePath, function(error) {
fs.access(filePath, function (error) {
tries--;
if (error && tries === 0) {