Files
iNaturalistReactNative/e2e/aiCamera.e2e.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

73 lines
2.8 KiB
JavaScript

import {
by, device, element, waitFor,
} from "detox";
import { iNatE2eAfterEach, iNatE2eBeforeAll, iNatE2eBeforeEach } from "./helpers";
import closeOnboarding from "./sharedFlows/closeOnboarding";
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
*/
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 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 );
},
);
} );