Add arrow up/down+enter navigation to select relation (#275)

* Add arrow up/down+enter navigation to select relation
This commit is contained in:
Félix Malfait
2023-06-12 17:52:16 +02:00
committed by GitHub
parent be863a22c9
commit 3341539eb2
2 changed files with 133 additions and 1 deletions

View File

@ -151,3 +151,58 @@ export const EditRelation: Story = {
],
},
};
export const SelectRelationWithKeys: Story = {
render,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const thirdRowCompanyCell = await canvas.findByText(
mockedPeopleData[2].company.name,
);
await userEvent.click(thirdRowCompanyCell);
const relationInput = await canvas.findByPlaceholderText('Company');
await userEvent.type(relationInput, 'Air', {
delay: 200,
});
await userEvent.type(relationInput, '{arrowdown}');
await userEvent.type(relationInput, '{arrowdown}');
await userEvent.type(relationInput, '{arrowup}');
await userEvent.type(relationInput, '{arrowdown}');
await userEvent.type(relationInput, '{enter}');
const newThirdRowCompanyCell = await canvas.findByText('Aircall');
await userEvent.click(newThirdRowCompanyCell);
},
parameters: {
actions: {},
msw: [
...graphqlMocks.filter((graphqlMock) => {
return graphqlMock.info.operationName !== 'UpdatePeople';
}),
...[
graphql.mutation('UpdatePeople', (req, res, ctx) => {
return res(
ctx.data({
updateOnePerson: {
...fetchOneFromData(mockedPeopleData, req.variables.id),
...{
company: {
id: req.variables.companyId,
name: 'Aircall',
domainName: 'aircall.io',
__typename: 'Company',
} satisfies GraphqlQueryCompany,
},
},
}),
);
}),
],
],
},
};