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() { async waitForSearchInputToBeInteractive() {
waitForClickable(this.searchControl); await waitForClickable(this.searchControl);
} }
async isSearchContainerDisplayed() { async isSearchContainerDisplayed() {

View File

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

View File

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

View File

@@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * 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 { Logger } from '@alfresco/adf-testing';
import { BROWSER_WAIT_TIMEOUT, E2E_ROOT_PATH } from '../configs'; import { BROWSER_WAIT_TIMEOUT, E2E_ROOT_PATH } from '../configs';
@@ -31,21 +31,21 @@ const path = require('path');
const fs = require('fs'); const fs = require('fs');
const StreamZip = require('node-stream-zip'); 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.clear();
await element.sendKeys(text); await element.sendKeys(text);
} }
export async function clearTextWithBackspace(element: ElementFinder) { export async function clearTextWithBackspace(element: ElementFinder): Promise<void> {
await element.clear(); await element.clear();
await element.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE); 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( return browser.wait(
until.elementLocated(by.css(css)), until.elementLocated(by.css(css)),
BROWSER_WAIT_TIMEOUT, BROWSER_WAIT_TIMEOUT,
errorMessage || 'Timeout waiting for element' errorMessage || `Timeout waiting for element: ${css}`
); );
} }
@@ -53,10 +53,10 @@ export async function waitForClickable(
element: ElementFinder, element: ElementFinder,
errorMessage?: string errorMessage?: string
): Promise<void> { ): Promise<void> {
return browser.wait( await browser.wait(
EC.elementToBeClickable(element), EC.elementToBeClickable(element),
BROWSER_WAIT_TIMEOUT, 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, element: ElementFinder,
errorMessage?: string errorMessage?: string
): Promise<void> { ): Promise<void> {
return browser.wait( await browser.wait(
EC.visibilityOf(element), EC.visibilityOf(element),
BROWSER_WAIT_TIMEOUT, 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, element: ElementFinder,
errorMessage?: string errorMessage?: string
): Promise<void> { ): Promise<void> {
return browser.wait( await browser.wait(
EC.invisibilityOf(element), EC.invisibilityOf(element),
BROWSER_WAIT_TIMEOUT, 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, element: ElementFinder,
errorMessage?: string errorMessage?: string
): Promise<void> { ): Promise<void> {
return browser.wait( await browser.wait(
EC.presenceOf(element), EC.presenceOf(element),
BROWSER_WAIT_TIMEOUT, 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, element: ElementFinder,
errorMessage?: string errorMessage?: string
): Promise<void> { ): Promise<void> {
return browser.wait( await browser.wait(
EC.stalenessOf(element), EC.stalenessOf(element),
BROWSER_WAIT_TIMEOUT, 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; let tries = 15;
return new Promise(function(resolve) { return new Promise(function (resolve) {
const checkExist = setInterval(() => { const checkExist = setInterval(() => {
fs.access(filePath, function(error) { fs.access(filePath, function (error) {
tries--; tries--;
if (error && tries === 0) { if (error && tries === 0) {

View File

@@ -9,9 +9,9 @@ const fs = require('fs');
const projectRoot = path.resolve(__dirname); const projectRoot = path.resolve(__dirname);
const downloadFolder = `${projectRoot}/e2e-downloads`; const downloadFolder = `${projectRoot}/e2e-downloads`;
const E2E_HOST = process.env.E2E_HOST || 'http://localhost', const E2E_HOST = process.env.E2E_HOST || 'http://localhost';
E2E_PORT = process.env.E2E_PORT || 4200, const E2E_PORT = process.env.E2E_PORT || 4200;
BROWSER_RUN = process.env.BROWSER_RUN; const BROWSER_RUN = process.env.BROWSER_RUN;
const width = 1366; const width = 1366;
const height = 768; const height = 768;