mirror of
https://github.com/inventree/InvenTree.git
synced 2026-11-20 06:57:57 +00:00
Fix 12844 notification external link (#12845)
* Fix external notification links * Add notification link regression test * Preserve fallback for empty notification links * Satisfy Biome optional-chain check * Apply Biome formatting * Retrigger CI --------- Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
1 parent
b14a4e7812
commit
13cc62567c
2 files changed
+98
-2
No files matched your search
@@ -0,0 +1,92 @@
|
||||
import { expect, test } from './baseFixtures.js';
|
||||
import { doLogin } from './login.js';
|
||||
|
||||
const notifications = [
|
||||
{
|
||||
pk: 1,
|
||||
target: {
|
||||
model_type: 'pluginconfig',
|
||||
model_id: 1,
|
||||
link: 'https://example.com/path'
|
||||
},
|
||||
source: null,
|
||||
user: 1,
|
||||
category: 'test_external',
|
||||
name: 'External Notification',
|
||||
message: 'External notification link',
|
||||
creation: '2026-09-12 12:00',
|
||||
age: 1,
|
||||
age_human: 'a moment ago',
|
||||
read: false
|
||||
},
|
||||
{
|
||||
pk: 2,
|
||||
target: {
|
||||
model_type: 'pluginconfig',
|
||||
model_id: 1,
|
||||
link: '/settings/admin/'
|
||||
},
|
||||
source: null,
|
||||
user: 1,
|
||||
category: 'test_internal',
|
||||
name: 'Internal Notification',
|
||||
message: 'Internal notification link',
|
||||
creation: '2026-09-12 12:00',
|
||||
age: 1,
|
||||
age_human: 'a moment ago',
|
||||
read: false
|
||||
},
|
||||
{
|
||||
pk: 3,
|
||||
target: {
|
||||
model_type: 'pluginconfig',
|
||||
model_id: 1,
|
||||
link: '/web/settings/admin/'
|
||||
},
|
||||
source: null,
|
||||
user: 1,
|
||||
category: 'test_base',
|
||||
name: 'Base Notification',
|
||||
message: 'Notification link with base path',
|
||||
creation: '2026-09-12 12:00',
|
||||
age: 1,
|
||||
age_human: 'a moment ago',
|
||||
read: false
|
||||
}
|
||||
];
|
||||
|
||||
test('Notifications - link targets', async ({ page }) => {
|
||||
await page.route('**/api/notifications/**', async (route) => {
|
||||
if (route.request().method() !== 'GET') {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
|
||||
await route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({
|
||||
count: notifications.length,
|
||||
next: null,
|
||||
previous: null,
|
||||
results: notifications
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
await doLogin(page);
|
||||
|
||||
await page.getByRole('button', { name: 'open-notifications' }).click();
|
||||
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'External Notification' })
|
||||
).toHaveAttribute('href', 'https://example.com/path');
|
||||
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'Internal Notification' })
|
||||
).toHaveAttribute('href', '/web/settings/admin/');
|
||||
|
||||
await expect(
|
||||
page.getByRole('link', { name: 'Base Notification' })
|
||||
).toHaveAttribute('href', '/web/settings/admin/');
|
||||
});
|
||||
Reference in new issue
Block a user