Skip to content

Commit

Permalink
feat: only allow png file type (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinan029 authored Sep 25, 2024
1 parent 932b456 commit 5ebe94b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/settings/SettingsAppearanceTab/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const SettingsAppearanceTab = ({
}}
maxSize={512000}
accept={{
'image/*': ['.png'],
'image/png': ['.png'],
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ describe('Portal Appearance Tab', () => {
expect(spy).toHaveBeenCalled();
});
});
test('drops invalid image file type into dropzone', async () => {
render(
<IntlProvider locale="en">
<Provider store={store}>
<SettingsAppearanceTab
enterpriseId={enterpriseId}
enterpriseBranding={enterpriseBranding}
updatePortalConfiguration={mockPortalUpdate}
/>
</Provider>
</IntlProvider>,
);
const fakeFile = new File(['hello'], 'hello.jpg', { type: 'image/jpg' });
const dropzone = screen.getByRole('presentation', { hidden: true });
userEvent.upload(dropzone.firstChild, fakeFile);
await waitFor(() => {
expect(screen.getByText('Invalid file type, only png images allowed.')).toBeInTheDocument();
});
});
test('renders curated theme cards', async () => {
render(
<IntlProvider locale="en">
Expand Down

0 comments on commit 5ebe94b

Please sign in to comment.