-
Notifications
You must be signed in to change notification settings - Fork 2
fix(pdf): Improve printable event form #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
2421f37
08cdc0c
1185119
df35db9
57794f3
5dddc17
1839202
205c227
42ac8b1
e954dcd
3bc178c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| import React from 'react'; | ||
| import { render } from '@testing-library/react'; | ||
| import { IntlProvider } from 'react-intl'; | ||
| import { vi } from 'vitest'; | ||
|
|
||
| import EventForm from '../EventForm'; | ||
|
|
||
| vi.mock('../../../store/hooks', () => ({ | ||
| useAppSelector: (selector: unknown) => { | ||
| if (typeof selector === 'function') { | ||
| return selector({ | ||
| geo: { | ||
| addressCoordinates: null, | ||
| selectedAddress: null, | ||
| selectedContractZone: { id: 1 }, | ||
| unavailableDates: [], | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| return undefined; | ||
| }, | ||
| })); | ||
|
|
||
| vi.mock('../fields/Input', () => ({ | ||
| default: (props: Record<string, unknown>) => ( | ||
| <div data-testid={String(props.id)} /> | ||
| ), | ||
| })); | ||
|
|
||
| vi.mock('../fields/NumericInput', () => ({ | ||
| default: (props: Record<string, unknown>) => ( | ||
| <div data-testid={String(props.id)} /> | ||
| ), | ||
| })); | ||
|
|
||
| vi.mock('../partitions/DateRange', () => ({ | ||
| default: () => <div data-testid="date-range" />, | ||
| })); | ||
|
|
||
| vi.mock('../partitions/Location', () => ({ | ||
| default: () => <div data-testid="location" />, | ||
| })); | ||
|
|
||
| const renderComponent = (additionalInformation: string) => | ||
| render( | ||
| <IntlProvider | ||
| locale="fi" | ||
| messages={{ | ||
| 'form.event.title.name_and_description': 'Tapahtuman perustiedot', | ||
| 'form.event.title.time': 'Aika', | ||
| 'form.event.title.contact_person': 'Yhteyshenkilö', | ||
| 'form.event.title.tools_and_suplies': 'Työkalut ja tarvikkeet', | ||
| 'form.event.subtitle.time': | ||
| 'Tapahtuman alkamispäivä voi olla tästä päivästä viikko eteenpäin.', | ||
| 'form.event.subtitle.contact_person': | ||
| 'Järjestäjän yhteystiedot tarvitaan urakoitsijoita varten.', | ||
| 'form.event.subtitle.tools_and_suplies': | ||
| 'Ilmoita tarvittavat työkalut. Urakoitsijat hoitavat oikean määrän tarvikkeita paikan päälle.', | ||
| }} | ||
| > | ||
| <EventForm | ||
| errors={{} as never} | ||
| handleBlur={vi.fn()} | ||
| handleChange={vi.fn()} | ||
| handleSubmit={vi.fn()} | ||
| touched={{} as never} | ||
| values={ | ||
| { | ||
| name: '', | ||
| description: '', | ||
| estimated_attendee_count: undefined, | ||
| targets: '', | ||
| location: undefined, | ||
| organizer_first_name: '', | ||
| organizer_last_name: '', | ||
| organizer_email: '', | ||
| organizer_phone: '', | ||
| large_trash_bag_count: undefined, | ||
| small_trash_bag_count: undefined, | ||
| trash_picker_count: undefined, | ||
| maintenance_location: '', | ||
| additional_information: additionalInformation, | ||
| start_time: '', | ||
| end_time: '', | ||
| } as never | ||
| } | ||
| /> | ||
| </IntlProvider> | ||
| ); | ||
|
|
||
| describe('<EventForm />', () => { | ||
| it('renders additional information as a printable field when populated', () => { | ||
| const { container } = renderComponent('Muita lisätietoja toimitukselle'); | ||
|
|
||
| const additionalInformation = container.querySelector( | ||
| '[data-testid="additional_information"]' | ||
| ); | ||
|
|
||
| expect(additionalInformation).toBeInTheDocument(); | ||
| expect( | ||
| additionalInformation?.closest('.event-form-print-note') | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| additionalInformation?.closest('.event-form-print-skip') | ||
| ).not.toBeInTheDocument(); | ||
| expect( | ||
| additionalInformation?.closest('.event-form-print-note--empty') | ||
| ).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('hides empty additional information from the printable layout', () => { | ||
| const { container } = renderComponent(''); | ||
|
|
||
| expect( | ||
| container.querySelector('[data-testid="additional_information"]') | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| container.querySelector('.event-form-print-note--empty') | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,6 +169,11 @@ const Location: React.FC<Props> = ({ | |
| </Row> | ||
| <Row> | ||
| <Col sm="12" md={{ size: 8, offset: 1 }} lg={{ size: 8, offset: 1 }}> | ||
| <p className="print-only"> | ||
| {formatMessage({ | ||
| id: 'form.event.field.trash_location.placeholder', | ||
| })} | ||
| </p> | ||
|
Comment on lines
+172
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The Suggested FixReplace the static placeholder in the Prompt for AI Agent |
||
| <Label htmlFor="maintenance_location" srOnly> | ||
| {formatMessage({ | ||
| id: 'form.event.field.trash_location.placeholder', | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.