mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-19 14:28:02 -04:00
* Added basic navigation test for StandardCamera & SoundRecorder * Abstracted camera nav buttons and used in SoundRecorder * Show sounds in the MediaViewer * Added sounds to ObsEdit, w/ MediaViewer support * Ensure sounds get both uploaded and added to observations * Local sound deletion * Remote sound deletion * Rudimentary and deeply unperformative sound visualization Closes #869
58 lines
1.9 KiB
JavaScript
58 lines
1.9 KiB
JavaScript
import {
|
|
screen,
|
|
userEvent,
|
|
within
|
|
} from "@testing-library/react-native";
|
|
import initI18next from "i18n/initI18next";
|
|
import { renderApp } from "tests/helpers/render";
|
|
import setupUniqueRealm from "tests/helpers/uniqueRealm";
|
|
|
|
// We're explicitly testing navigation here so we want react-navigation
|
|
// working normally
|
|
jest.unmock( "@react-navigation/native" );
|
|
|
|
// UNIQUE REALM SETUP
|
|
const mockRealmIdentifier = __filename;
|
|
const { mockRealmModelsIndex, uniqueRealmBeforeAll, uniqueRealmAfterAll } = setupUniqueRealm(
|
|
mockRealmIdentifier
|
|
);
|
|
jest.mock( "realmModels/index", ( ) => mockRealmModelsIndex );
|
|
jest.mock( "providers/contexts", ( ) => {
|
|
const originalModule = jest.requireActual( "providers/contexts" );
|
|
return {
|
|
__esModule: true,
|
|
...originalModule,
|
|
RealmContext: {
|
|
...originalModule.RealmContext,
|
|
useRealm: ( ) => global.mockRealms[mockRealmIdentifier]
|
|
}
|
|
};
|
|
} );
|
|
beforeAll( uniqueRealmBeforeAll );
|
|
afterAll( uniqueRealmAfterAll );
|
|
// /UNIQUE REALM SETUP
|
|
|
|
beforeAll( async () => {
|
|
await initI18next();
|
|
jest.useFakeTimers( );
|
|
} );
|
|
|
|
describe( "StandardCamera navigation", ( ) => {
|
|
const actor = userEvent.setup( );
|
|
|
|
describe( "from MyObs", ( ) => {
|
|
it( "should return to MyObs when close button tapped", async ( ) => {
|
|
renderApp( );
|
|
expect( await screen.findByText( /Log in to contribute/ ) ).toBeVisible( );
|
|
const addObsButton = await screen.findByLabelText( "Add observations" );
|
|
await actor.press( addObsButton );
|
|
const cameraButton = await screen.findByLabelText( "Camera" );
|
|
await actor.press( cameraButton );
|
|
const cameraNavButtons = await screen.findByTestId( "CameraNavButtons" );
|
|
const closeButton = await within( cameraNavButtons ).findByLabelText( "Close" );
|
|
await actor.press( closeButton );
|
|
expect( await screen.findByText( /Log in to contribute/ ) ).toBeVisible( );
|
|
} );
|
|
} );
|
|
} );
|