e2e mock for Geolocation.watchPosition to deflake tests (#1842)

This commit is contained in:
Ken-ichi
2024-07-24 20:15:03 -04:00
committed by GitHub
parent 27912676dc
commit 10bbea44c4
8 changed files with 125 additions and 19 deletions

View File

@@ -3,6 +3,8 @@ import {
} from "detox";
import Config from "react-native-config-node";
// This needs to be a relative path for the e2e-mock version to be used
import { CHUCKS_PAD } from "../src/appConstants/e2e";
import { iNatE2eBeforeAll, iNatE2eBeforeEach } from "./helpers";
describe( "Signed in user", () => {
@@ -24,6 +26,12 @@ describe( "Signed in user", () => {
await waitFor( element( by.id( "new-observation-text" ) ) )
.toBeVisible()
.withTimeout( 10000 );
// Ensure the location from the e2e-mock is being used so we don't end up
// with tests flaking out due to time zone issues
const pattern = new RegExp( `.*${CHUCKS_PAD.latitude.toFixed( 4 )}.*` );
await waitFor( element( by.text( pattern ) ) )
.toBeVisible()
.withTimeout( 10000 );
if ( options.upload ) {
// Press Upload now button
const uploadNowButton = element( by.id( "ObsEdit.uploadButton" ) );