Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
refactor: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Jul 4, 2024
1 parent e99ef5d commit ba9c0ad
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 28 deletions.
4 changes: 1 addition & 3 deletions cypress/e2e/item/home/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ const interceptAccessibleItemsSearch = (searchTerm: string) =>
.as('getAccessibleSearch');

describe('Home', () => {
it.only('visit Home on map by default', () => {
cy.stubGeolocationPermission();

it('visit Home on map by default', () => {
cy.setUpApi({
items: generateOwnItems(30),
});
Expand Down
2 changes: 0 additions & 2 deletions cypress/e2e/item/view/viewFolder.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const items = [parentItem, item1, child1, child2];

describe('View Folder', () => {
it('View folder on map by default', () => {
cy.stubGeolocationPermission();

cy.setUpApi({
items,
});
Expand Down
11 changes: 0 additions & 11 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,14 +418,3 @@ Cypress.Commands.add('attachFiles', (selector, filenames, options = {}) => {
);
selector.selectFile(correctFilenames, options);
});

Cypress.Commands.add('stubGeolocationPermission', () => {
cy.stub(window.navigator, 'permissions').callsFake(() => 'denied');

// force Barcelona geolocation
const latitude = 41.38879;
const longitude = 2.15899;
cy.stub(window.navigator.geolocation, 'getCurrentPosition').callsFake((cb) =>
cb({ coords: { latitude, longitude } }),
);
});
2 changes: 0 additions & 2 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ declare global {
item: { name?: string },
options?: { confirm?: boolean },
): void;

stubGeolocationPermission(): void;
}
}
}
20 changes: 10 additions & 10 deletions src/components/item/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ const MapView = ({
)}
</Stack>
<Stack flex={1}>
{(parentId && isLoadingParent) ||
(enableGeolocation && !hasFetchedCurrentLocation) ? (
<Skeleton width="100%" height="100%" />
) : (
<div
id={buildMapViewId(parentId)}
style={{ width: '100%', height: '100%' }}
>
<div
id={buildMapViewId(parentId)}
style={{ width: '100%', height: '100%' }}
>
{(parentId && isLoadingParent) ||
(enableGeolocation && !hasFetchedCurrentLocation) ? (
<Skeleton width="100%" height="100%" />
) : (
<Map
currentPosition={currentPosition}
useDeleteItemGeolocation={mutations.useDeleteItemGeolocation}
Expand All @@ -149,8 +149,8 @@ const MapView = ({
// todo: always use builder modal when it is responsive
handleAddOnClick={isMobile ? undefined : handleAddOnClick}
/>
</div>
)}
)}
</div>
</Stack>
</Stack>
{!isMobile && (
Expand Down

0 comments on commit ba9c0ad

Please sign in to comment.