feat(health): tile opens local/remote URL with one-click alt + LAN-only marker
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
27
tests/frontend/service_tile.test.js
Normal file
27
tests/frontend/service_tile.test.js
Normal file
@@ -0,0 +1,27 @@
|
||||
// @vitest-environment jsdom
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { serviceTile } from '../../public/components/service_tile.js';
|
||||
|
||||
const base = { id: 'gramps', name: 'Gramps', host: 'ct109', icon: 'gramps', status: 'ok',
|
||||
url: 'http://192.168.1.99', external: 'https://gramps.hynesy.com' };
|
||||
|
||||
describe('serviceTile', () => {
|
||||
it('local: primary link is the LAN url, alt link is the domain', () => {
|
||||
const t = serviceTile(base, false);
|
||||
expect(t.querySelector('.tile-link').getAttribute('href')).toBe('http://192.168.1.99/');
|
||||
expect(t.querySelector('.tile-alt').getAttribute('href')).toBe('https://gramps.hynesy.com/');
|
||||
expect(t.querySelectorAll('a').length).toBe(2);
|
||||
});
|
||||
it('remote: primary is the domain, alt is the LAN url', () => {
|
||||
const t = serviceTile(base, true);
|
||||
expect(t.querySelector('.tile-link').getAttribute('href')).toBe('https://gramps.hynesy.com/');
|
||||
expect(t.querySelector('.tile-alt').getAttribute('href')).toBe('http://192.168.1.99/');
|
||||
expect(t.classList.contains('lan-only')).toBe(false);
|
||||
});
|
||||
it('remote + no external: lan-only, no alt, badge present', () => {
|
||||
const t = serviceTile({ ...base, external: undefined }, true);
|
||||
expect(t.classList.contains('lan-only')).toBe(true);
|
||||
expect(t.querySelector('.tile-alt')).toBeNull();
|
||||
expect(t.querySelector('.tile-lan')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user