Retain user mode (advanced/default) after login (#2742)

* Retain user mode (advanced/default) after login

* Switch to power mode before login & hide announcements e2e

* Remove repetitive signin test from e2e
This commit is contained in:
Amanda Bullington
2025-03-12 02:22:39 -07:00
committed by GitHub
parent 8ca3664ba9
commit 1347ca3488
7 changed files with 47 additions and 25 deletions

View File

@@ -6,7 +6,6 @@ import { iNatE2eBeforeAll, iNatE2eBeforeEach } from "./helpers";
import closeOnboarding from "./sharedFlows/closeOnboarding";
import deleteObservation from "./sharedFlows/deleteObservation";
import signIn from "./sharedFlows/signIn";
import switchPowerMode from "./sharedFlows/switchPowerMode";
import uploadObservation from "./sharedFlows/uploadObservation";
const TIMEOUT = 10_000;
@@ -25,12 +24,7 @@ describe( "AICamera", () => {
const username = await signIn();
/*
/ 2. Switch UI to power user mode
*/
await switchPowerMode();
/*
/ 3. Take photo with AI Camera, select a suggestion, upload and delete observation
/ 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" ) );

View File

@@ -0,0 +1,18 @@
import {
by, element, waitFor
} from "detox";
export default async function dismissAnnouncements() {
try {
// wait briefly to see if the announcement appears
await waitFor(
element( by.id( "announcements-container" ) )
).toBeVisible().withTimeout( 1000 );
// if we get here, the announcement is visible, so dismiss it
await element( by.id( "announcements-dismiss" ) ).tap();
} catch ( error ) {
// if timeout occurs, the element isn't visible, so continue with test
console.log( "No announcement present, continuing with test" );
}
}

View File

@@ -3,7 +3,14 @@ import {
} from "detox";
import Config from "react-native-config-node";
import dismissAnnouncements from "./dismissAnnouncements";
import switchPowerMode from "./switchPowerMode";
export default async function signIn() {
/*
Switch UI to power user mode
*/
await switchPowerMode();
// Find the Menu item from tabs
const openDrawerMenuItem = element( by.id( "OPEN_DRAWER" ) );
await waitFor( openDrawerMenuItem ).toBeVisible().withTimeout( 10000 );
@@ -32,5 +39,10 @@ export default async function signIn() {
const username = element( by.text( `${Config.E2E_TEST_USERNAME}` ) ).atIndex( 1 );
await waitFor( username ).toBeVisible().withTimeout( 10000 );
await expect( username ).toBeVisible();
/*
Dismiss announcements if they're blocking the UI
*/
await dismissAnnouncements();
return username;
}

View File

@@ -1,3 +1,7 @@
// we don't need this or switchPowerMode.e2e.js.js since they're repetititve
// with what we're already doing in the signedIn and aiCamera tests
// and we would see any failures there
import { device } from "detox";
import { iNatE2eBeforeAll, iNatE2eBeforeEach } from "./helpers";

View File

@@ -6,7 +6,6 @@ import { iNatE2eBeforeAll, iNatE2eBeforeEach } from "./helpers";
import closeOnboarding from "./sharedFlows/closeOnboarding";
import deleteObservation from "./sharedFlows/deleteObservation";
import signIn from "./sharedFlows/signIn";
import switchPowerMode from "./sharedFlows/switchPowerMode";
import uploadObservation from "./sharedFlows/uploadObservation";
describe( "Signed in user", () => {
@@ -70,12 +69,7 @@ describe( "Signed in user", () => {
await listToggle.tap();
/*
/ 2. Switch UI to power user mode
*/
await switchPowerMode();
/*
/ 3. Create two observations without evidence
/ 2. Create two observations without evidence
*/
const uuid = await createAndUploadObservation( { upload: true } );
// Create a second b/c later we want to test that the deleted status text
@@ -84,7 +78,7 @@ describe( "Signed in user", () => {
await createAndUploadObservation( );
/*
/ 4. Update the observation by adding a comment
/ 3. Update the observation by adding a comment
*/
const obsListItem = element( by.id( `MyObservations.obsListItem.${uuid}` ) );
await obsListItem.tap();
@@ -111,7 +105,7 @@ describe( "Signed in user", () => {
await waitFor( username ).toBeVisible( ).withTimeout( 10000 );
/*
/ 5. Delete the two observations without evidence
/ 4. Delete the two observations without evidence
*/
await deleteObservationByUUID( uuid, username, { uploaded: true } );
// It would be nice to test for the "1 observation deleted" status text in