Fix server history with tapAndWaitFor
This commit is contained in:
parent
b2204619e8
commit
6ea3e70ad2
|
@ -180,7 +180,6 @@ async function tryTapping(theElement: Detox.IndexableNativeElement, timeout: num
|
|||
}
|
||||
} catch (e) {
|
||||
if (timeout <= 0) {
|
||||
// TODO: Maths. How closely has the timeout been honoured here?
|
||||
throw e;
|
||||
}
|
||||
await sleep(100);
|
||||
|
@ -188,6 +187,23 @@ async function tryTapping(theElement: Detox.IndexableNativeElement, timeout: num
|
|||
}
|
||||
}
|
||||
|
||||
async function tapAndWaitFor(
|
||||
elementToTap: Detox.IndexableNativeElement,
|
||||
elementToWaitFor: Detox.IndexableNativeElement,
|
||||
timeout: number
|
||||
) {
|
||||
try {
|
||||
await elementToTap.tap();
|
||||
await waitFor(elementToWaitFor).toBeVisible().withTimeout(200);
|
||||
} catch (e) {
|
||||
if (timeout <= 0) {
|
||||
throw e;
|
||||
}
|
||||
await sleep(100);
|
||||
await tapAndWaitFor(elementToTap, elementToWaitFor, timeout - 100);
|
||||
}
|
||||
}
|
||||
|
||||
const checkServer = async (server: string) => {
|
||||
const label = `Connected to ${server}`;
|
||||
await element(by.id('rooms-list-view-sidebar')).tap();
|
||||
|
@ -206,18 +222,6 @@ const checkServer = async (server: string) => {
|
|||
.withTimeout(10000);
|
||||
};
|
||||
|
||||
function runCommand(command: string) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
exec(command, (error, _stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(new Error(`exec error: ${stderr}`));
|
||||
return;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
navigateToWorkspace,
|
||||
navigateToLogin,
|
||||
|
@ -232,6 +236,7 @@ export {
|
|||
sleep,
|
||||
searchRoom,
|
||||
tryTapping,
|
||||
tapAndWaitFor,
|
||||
checkServer,
|
||||
platformTypes
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import { login, navigateToLogin, logout, tapBack } from '../../helpers/app';
|
||||
import { login, navigateToLogin, logout, tapBack, tryTapping, tapAndWaitFor } from '../../helpers/app';
|
||||
import data from '../../data';
|
||||
|
||||
describe('Server history', () => {
|
||||
|
@ -42,10 +42,7 @@ describe('Server history', () => {
|
|||
await waitFor(element(by.id('new-server-view')))
|
||||
.toBeVisible()
|
||||
.withTimeout(2000);
|
||||
await element(by.id('new-server-view-input')).tap();
|
||||
await waitFor(element(by.id(`server-history-${data.server}`)))
|
||||
.toBeVisible()
|
||||
.withTimeout(2000);
|
||||
await tapAndWaitFor(element(by.id('new-server-view-input')), element(by.id(`server-history-${data.server}`)), 2000);
|
||||
await element(by.id(`server-history-delete-${data.server}`)).tap();
|
||||
await element(by.id('new-server-view-input')).tap();
|
||||
await waitFor(element(by.id(`server-history-${data.server}`)))
|
||||
|
|
Loading…
Reference in New Issue