Files
iNaturalistReactNative/e2e/sharedFlows/uploadObservation.js
Ryan Stelly b78be9243d lint rule & autofix for "trailing comma" (#3299)
* (lint) MOB-1063 enforce trailing commas

* autofix trailing commas

* manually fix newly introduced maxlen violations

* add trailing comma convention to i18n build
2025-12-22 20:17: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();
}
}