diff --git a/plugins/shortcuts/src/ShortcutForm.test.tsx b/plugins/shortcuts/src/ShortcutForm.test.tsx
index 56309b4a64..388c072725 100644
--- a/plugins/shortcuts/src/ShortcutForm.test.tsx
+++ b/plugins/shortcuts/src/ShortcutForm.test.tsx
@@ -53,15 +53,40 @@ describe('ShortcutForm', () => {
expect(
screen.getByText('Must be at least 2 characters'),
).toBeInTheDocument();
- expect(
- screen.queryByText('A shortcut with this title already exists'),
- ).not.toBeInTheDocument();
- expect(
- screen.queryByText('A shortcut with this url already exists'),
- ).not.toBeInTheDocument();
});
});
+ it('displays duplicate validation messages for title and URL', async () => {
+ const mockShortcutApi = new DefaultShortcutsApi(MockStorageApi.create());
+ mockShortcutApi.add({ title: 'Existing Title', url: '/existing-url' });
+
+ await renderInTestApp(
+
+
+ ,
+ );
+
+ const urlInput = screen.getByPlaceholderText('Enter a URL');
+ const titleInput = screen.getByPlaceholderText('Enter a display name');
+
+ fireEvent.change(urlInput, { target: { value: '/existing-url' } });
+ fireEvent.change(titleInput, { target: { value: 'Existing Title' } });
+
+ fireEvent.click(screen.getByText('Save'));
+
+ await waitFor(() => {
+ expect(
+ screen.getByText('A shortcut with this title already exists'),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByText('A shortcut with this url already exists'),
+ ).toBeInTheDocument();
+ });
+
+ expect(props.onSave).not.toHaveBeenCalled();
+ expect(props.onClose).not.toHaveBeenCalled();
+ });
+
it('allows external links', async () => {
await renderInTestApp(