Files
iNaturalistReactNative/e2e/sharedFlows/uploadObservation.js
Johannes Klein 3c04df39a3 Enable New Architecture (#3111)
* Update gradle.properties

* Update Podfile

* Update react-native-mmkv

* Update Podfile.lock

* Delete useObservationsUpdatesWhenFocused.test.js

* Update closeOnboarding.js

* Fix failing button tap in e2e tests

* Create react-native-sensitive-info+6.0.0-alpha.9.patch

* Update bottom-sheets

* Refactor e2e timeout to file-wide const

* Remove check that fails

* Check for entire list item instead of comments count

* Longer delay to wait for observation deletion to make UI disappear
2025-09-27 08:28:13 -06:00

33 lines
1.2 KiB
JavaScript

import {
by, element, expect, waitFor
} from "detox";
// This needs to be a relative path for the e2e-mock version to be used
import { CHUCKS_PAD } from "../../src/appConstants/e2e";
const TIMEOUT = 10_000;
// Upload or save an observation
export default async function uploadObservation( options = { upload: false } ) {
// Start this on ObsEdit
// Check that the new observation screen is visible
const newObservationText = element( by.id( "new-observation-text" ) );
await waitFor( newObservationText ).toBeVisible().withTimeout( TIMEOUT );
// 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 )}.*` );
const locationText = element( by.text( pattern ) );
await waitFor( locationText ).toBeVisible().withTimeout( TIMEOUT );
if ( options.upload ) {
// Press Upload now button
const uploadNowButton = element( by.id( "ObsEdit.uploadButton" ) );
await expect( uploadNowButton ).toBeVisible();
await uploadNowButton.tap();
} else {
// Press Save button
const saveButton = element( by.id( "ObsEdit.saveButton" ) );
await expect( saveButton ).toBeVisible();
await saveButton.tap();
}
}