mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-01-07 21:39:06 -05:00
* Use fixed header on ObsDetails advanced mode * Remove test for removed component - using react navigation header instead * Remove tests related to ObsDetails header icon; using react navigation * Add testID to react navigation level back button and fix e2e * Terminate app after every e2e test and maybe help flakiness * Rework termination of app --------- Co-authored-by: Johannes Klein <johannes.t.klein@gmail.com>
84 lines
3.3 KiB
JavaScript
84 lines
3.3 KiB
JavaScript
import {
|
|
by, device, element, waitFor
|
|
} from "detox";
|
|
|
|
import { iNatE2eAfterEach, iNatE2eBeforeAll, iNatE2eBeforeEach } from "./helpers";
|
|
import closeOnboarding from "./sharedFlows/closeOnboarding";
|
|
import deleteObservation from "./sharedFlows/deleteObservation";
|
|
import signIn from "./sharedFlows/signIn";
|
|
import uploadObservation from "./sharedFlows/uploadObservation";
|
|
|
|
const TIMEOUT = 10_000;
|
|
|
|
describe( "AICamera", () => {
|
|
beforeAll( async () => iNatE2eBeforeAll( device ) );
|
|
beforeEach( async () => iNatE2eBeforeEach( device ) );
|
|
afterEach( async () => iNatE2eAfterEach( device ) );
|
|
|
|
it(
|
|
"should open the ai camera, take photo, select a suggestion, upload and delete observation",
|
|
async () => {
|
|
await closeOnboarding( );
|
|
/*
|
|
/ 1. Sign in
|
|
*/
|
|
const username = await signIn();
|
|
|
|
/*
|
|
/ 2. Take photo with AI Camera, select a suggestion, upload and delete observation
|
|
*/
|
|
// Tap to open AICamera
|
|
const addObsButton = element( by.id( "add-obs-button" ) );
|
|
await waitFor( addObsButton ).toBeVisible().withTimeout( TIMEOUT );
|
|
await addObsButton.tap();
|
|
const aiCameraButton = element( by.id( "aicamera-button" ) );
|
|
await waitFor( aiCameraButton ).toBeVisible().withTimeout( TIMEOUT );
|
|
await aiCameraButton.tap();
|
|
|
|
// Check that the camera screen is visible
|
|
const cameraContainer = element( by.id( "CameraWithDevice" ) );
|
|
await waitFor( cameraContainer ).toBeVisible().withTimeout( TIMEOUT );
|
|
// Check that the mocked cv suggestion is visible
|
|
const taxonResult = element( by.id( "AICamera.taxa.51779" ) );
|
|
await waitFor( taxonResult ).toBeVisible().withTimeout( TIMEOUT );
|
|
// Tap the take photo button
|
|
const takePhotoButton = element( by.id( "take-photo-button" ) );
|
|
await waitFor( takePhotoButton ).toBeVisible().withTimeout( TIMEOUT );
|
|
await takePhotoButton.tap();
|
|
|
|
// On suggestions find the first element in the suggestions list
|
|
const otherSuggestionsTitle = element( by.text( "OTHER SUGGESTIONS" ) );
|
|
await waitFor( otherSuggestionsTitle ).toBeVisible( ).withTimeout( 30_000 );
|
|
const firstSuggestion = element( by.id( /SuggestionsList\.taxa\..*/ ) ).atIndex(
|
|
0
|
|
);
|
|
await waitFor( firstSuggestion ).toBeVisible().withTimeout( TIMEOUT );
|
|
const suggestionAttributes = await firstSuggestion.getAttributes();
|
|
const taxonID = suggestionAttributes.elements
|
|
? suggestionAttributes.elements[0].identifier.split( "." ).pop()
|
|
: suggestionAttributes.identifier.split( "." ).pop();
|
|
await firstSuggestion.tap();
|
|
|
|
// On Taxon Detail
|
|
const selectTaxonButon = element( by.id( "TaxonDetails.SelectButton" ) );
|
|
await waitFor( selectTaxonButon ).toBeVisible().withTimeout( TIMEOUT );
|
|
await selectTaxonButon.tap();
|
|
|
|
await uploadObservation( { upload: true } );
|
|
|
|
// Check that the display taxon name is visible
|
|
const displayTaxonName = element( by.id( `display-taxon-name.${taxonID}` ) ).atIndex(
|
|
0
|
|
);
|
|
await waitFor( displayTaxonName ).toBeVisible().withTimeout( TIMEOUT );
|
|
await displayTaxonName.tap();
|
|
|
|
// Delete the observation
|
|
await deleteObservation( { uploaded: true } );
|
|
|
|
// Make sure we're back on MyObservations
|
|
await waitFor( username ).toBeVisible().withTimeout( TIMEOUT );
|
|
}
|
|
);
|
|
} );
|