mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-28 09:24:24 +01:00
(bug) update plan prices
This commit is contained in:
parent
4d7f10758e
commit
c1159b2aed
@ -1,5 +1,7 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Fix a bug: updating plan prices
|
||||
|
||||
## v5.6.6 2023 January 23
|
||||
|
||||
- Add more context data to sentry reports
|
||||
|
@ -73,7 +73,7 @@ export const PlanPricingForm = <TContext extends object>({ register, control, fo
|
||||
(price.priceable_type === 'Space' && spaces?.find(s => s.id === price.priceable_id));
|
||||
if (!item?.disabled) {
|
||||
return (
|
||||
<div key={index}>
|
||||
<div key={price.id}>
|
||||
<FormInput register={register}
|
||||
id={`prices_attributes.${index}.id`}
|
||||
formState={formState}
|
||||
|
@ -5,6 +5,7 @@ import { Plan } from 'models/plan';
|
||||
import selectEvent from 'react-select-event';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import plans from '../../__fixtures__/plans';
|
||||
import machines from '../../__fixtures__/machines';
|
||||
import { tiptapEvent } from '../../__lib__/tiptap';
|
||||
|
||||
describe('PlanForm', () => {
|
||||
@ -152,4 +153,29 @@ describe('PlanForm', () => {
|
||||
expect(screen.getByText(/app.admin.plan_form.alert_partner_notification/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
test('update plan prices', async () => {
|
||||
const plan = plans[1];
|
||||
const machine = machines[1];
|
||||
render(<PlanForm action="update" plan={plan} onError={onError} onSuccess={onSuccess} beforeSubmit={beforeSubmit} />);
|
||||
await waitFor(() => screen.getByRole('combobox', { name: /app.admin.plan_pricing_form.copy_prices_from/ }));
|
||||
// update machine price
|
||||
fireEvent.change(screen.getByLabelText(new RegExp(machine.name)), { target: { value: 42.42 } });
|
||||
// send the form
|
||||
fireEvent.click(screen.getByRole('button', { name: /app.admin.plan_form.ACTION_plan/ }));
|
||||
await waitFor(() => {
|
||||
const expected = {
|
||||
prices_attributes: expect.arrayContaining([{
|
||||
amount: 42.42,
|
||||
duration: 60,
|
||||
group_id: plan.group_id,
|
||||
id: expect.any(Number),
|
||||
plan_id: plan.id,
|
||||
priceable_id: machine.id,
|
||||
priceable_type: 'Machine'
|
||||
}])
|
||||
};
|
||||
expect(beforeSubmit).toHaveBeenCalledWith(expect.objectContaining(expected));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user