Skip to content

Commit

Permalink
Merge pull request #284 from HelsinkiUniCollab/pathing_w/o_geoloc
Browse files Browse the repository at this point in the history
Move mapping function to pathcomponent
  • Loading branch information
smannist committed Aug 19, 2023
2 parents 7b914ca + 0fb4453 commit f5aee92
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion recommender-front/cypress/e2e/recommender.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('User location and routing feature', () => {
});

it('should locate the user, open a POI and set a destination, draw the polyline', () => {
cy.get('[data-testid="locate-button"]').should('be.visible');
cy.get('[data-testid="locate-button"]').should('be.visible').click();
cy.get('.leaflet-marker-icon').eq(1).click();
cy.get('.leaflet-popup-content');
cy.intercept('GET', '**/path?start=*&end=*', { body: mockROUTE }).as('getRoute');
Expand Down
2 changes: 1 addition & 1 deletion recommender-front/src/components/map/MapComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function MapComponent({
handleSetDestination={handleSetDestination}
/>
{routeCoordinates && (
<Polyline data-testid="map-polyline" positions={routeCoordinates.map((coord) => [coord[1], coord[0]])} />
<Polyline data-testid="map-polyline" positions={routeCoordinates} />
)}
</MapContainer>
</div>
Expand Down
3 changes: 2 additions & 1 deletion recommender-front/src/utils/PathComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function PathUtil({ origin, destination, setRouteCoordinates }) {
end: destination.join(','),
},
});
setRouteCoordinates(response.data);
const coords = response.data.map((coord) => [coord[1], coord[0]]);
await setRouteCoordinates(coords);
console.log('Success!');
} catch (error) {
console.error('Error sending coordinates:', error);
Expand Down
3 changes: 2 additions & 1 deletion recommender-front/src/utils/PathComponent.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ describe('PathUtil', () => {
const mockSetRouteCoordinates = jest.fn();
const origin = [60.2049, 24.9649];
const destination = [60.35, 25.355];
const mockData = [[60.2049, 24.9649], [60.35, 25.355]];

axios.get.mockResolvedValue({ data: 'mockData' });
axios.get.mockResolvedValue({ data: mockData });

render(
<PathUtil
Expand Down

0 comments on commit f5aee92

Please sign in to comment.