Skip to content

Commit

Permalink
✅ [open-formulieren/open-forms#2177] Expanding and fixing storybook s…
Browse files Browse the repository at this point in the history
…tories for map component
  • Loading branch information
robinmolen committed Jan 7, 2025
1 parent 9d0ed64 commit 2c8cf65
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions src/components/Map/Map.stories.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {expect, fn, userEvent, within} from '@storybook/test';
import {expect, fn, userEvent, waitFor, within} from '@storybook/test';
import {useState} from 'react';

import {ConfigDecorator} from 'story-utils/decorators';
Expand Down Expand Up @@ -53,17 +53,35 @@ export default {
export const Map = {};

export const MapWithAddressSearch = {
play: async ({canvasElement}) => {
args: {
onGeoJsonFeatureSet: fn(),
},
play: async ({canvasElement, args}) => {
const canvas = within(canvasElement);
const button = await canvas.findByLabelText('Zoeken');
await userEvent.click(button);

await waitFor(async () => {
const button = await canvas.findByLabelText('Zoeken');
await userEvent.click(button);
expect(await canvas.findByPlaceholderText('Zoek adres')).toBeVisible();
});

const searchField = await canvas.findByPlaceholderText('Zoek adres');
const searchBox = within(searchField.parentNode);
await userEvent.type(searchField, 'Gemeente Utrecht');
const searchResult = await searchBox.findByText('Utrecht, Utrecht, Utrecht');

await userEvent.click(searchResult);
await waitFor(async () => {
// A marker is placed on the search result
expect(args.onGeoJsonFeatureSet).toBeCalledWith({
type: 'Feature',
properties: {},
geometry: {
type: 'Point',
coordinates: [5.074754, 52.091138],
},
});
});
},
};

Expand All @@ -84,13 +102,11 @@ export const MapWithAerialPhotoBackground = {

export const MapWithInteractions = {
args: {
geoJsonFeature: undefined,
interactions: {
polygon: true,
polyline: true,
marker: true,
},
defaultCenter: [52.1326332, 5.291266],
onGeoJsonFeatureSet: fn(),
},
parameters: {
Expand Down Expand Up @@ -120,7 +136,7 @@ export const MapWithInteractions = {
properties: {},
geometry: {
type: 'Point',
coordinates: [5.287384, 52.134262],
coordinates: [5.287385, 52.134126],
},
});
});
Expand Down

0 comments on commit 2c8cf65

Please sign in to comment.