Skip to content

Commit

Permalink
✅ [open-formulieren/open-forms#2177] Expanding storybook story for ma…
Browse files Browse the repository at this point in the history
…p address search
  • Loading branch information
robinmolen committed Jan 7, 2025
1 parent 9d0ed64 commit 4b84451
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 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 Down

0 comments on commit 4b84451

Please sign in to comment.