mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-04-19 06:23:12 -04:00
* Add string * Add a state that signifies syncing in progress * Rename state as it no longer only pertains to uploading * Set flag on button press * Fix bug with wrong number of obs to upload shown * Update MyObservations.test.js * Add 1 to param for human readability * Update MyObservations.perf-test.js * Update ToolbarContainer.test.js * Reintroduce number of finished uploads * Update comment * Use animation for gallery loading screen
92 lines
2.2 KiB
JavaScript
92 lines
2.2 KiB
JavaScript
// ComponentUnderTest.perf-test.tsx
|
|
import MyObservations from "components/MyObservations/MyObservations";
|
|
import React from "react";
|
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
import { measurePerformance } from "reassure";
|
|
import factory from "tests/factory";
|
|
import faker from "tests/helpers/faker";
|
|
|
|
jest.setTimeout( 60_000 );
|
|
|
|
const mockUser = factory( "LocalUser" );
|
|
|
|
const mockObservations = [
|
|
factory( "LocalObservation", {
|
|
_synced_at: null,
|
|
observationPhotos: [
|
|
factory( "LocalObservationPhoto", {
|
|
photo: {
|
|
id: faker.number.int( ),
|
|
url: faker.image.url( ),
|
|
position: 0
|
|
}
|
|
} )
|
|
]
|
|
} ),
|
|
factory( "LocalObservation", {
|
|
_synced_at: null,
|
|
observationPhotos: [
|
|
factory( "LocalObservationPhoto", {
|
|
photo: {
|
|
id: faker.number.int( ),
|
|
url: `${faker.image.url( )}/100`,
|
|
position: 0
|
|
}
|
|
} ),
|
|
factory( "LocalObservationPhoto", {
|
|
photo: {
|
|
id: faker.number.int( ),
|
|
url: `${faker.image.url( )}/200`,
|
|
position: 1
|
|
}
|
|
} )
|
|
]
|
|
} )
|
|
];
|
|
|
|
const mockState = {
|
|
uploads: mockObservations,
|
|
error: null,
|
|
numToUpload: 3,
|
|
uploadInProgress: true,
|
|
totalProgressIncrements: 4,
|
|
uploadProgress: 1,
|
|
uploadsComplete: false
|
|
};
|
|
|
|
const mockOnEndReached = jest.fn( );
|
|
|
|
jest.mock( "sharedHooks/useInfiniteObservationsScroll", () => ( {
|
|
__esModule: true,
|
|
default: () => ( {
|
|
data: mockObservations,
|
|
isFetchingNextPage: false,
|
|
fetchNextPage: mockOnEndReached
|
|
} )
|
|
} ) );
|
|
|
|
jest.mock( "sharedHooks/useObservationsUpdates", () => ( {
|
|
__esModule: true,
|
|
default: jest.fn( () => ( {
|
|
refetch: jest.fn()
|
|
} ) )
|
|
} ) );
|
|
|
|
describe( "MyObservations Performance", ( ) => {
|
|
test( "Test list loading time in MyObservations", async () => {
|
|
await measurePerformance( <MyObservations
|
|
observations={mockObservations}
|
|
layout="list"
|
|
toggleLayout={jest.fn( )}
|
|
allObsToUpload={[]}
|
|
showLoginSheet={false}
|
|
setShowLoginSheet={jest.fn( )}
|
|
isFetchingNextPage={false}
|
|
onEndReached={mockOnEndReached}
|
|
currentUser={mockUser}
|
|
isOnline
|
|
uploadState={mockState}
|
|
/> );
|
|
} );
|
|
} );
|