Files
iNaturalistReactNative/tests/integration/navigation/StandardCamera.test.js
Ken-ichi f45108036f Sound recording (#1164)
* 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
2024-02-22 22:02:25 -08:00

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( );
} );
} );
} );