feat(devices): Scan Now + Manual Add (IP option, MAC colon-mask) → 2.1.4
'Scan Now' triggers POST /api/devices/scan from the band header. '+ Add by MAC' renamed '+ Manual Add' with an optional IP field (addBody/addManual accept ip) and a MAC input that auto-inserts colons as you type. Frontend test 4/4; DB-backed api/repo tests written (run with the suite — skipped locally to avoid colliding with a concurrent test run on void_test). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -53,15 +53,28 @@ describe('devices band', () => {
|
||||
expect.objectContaining({ name: 'Orbi RBS50', grp: 'Network' }));
|
||||
});
|
||||
|
||||
it('manual add-by-MAC reveals a form and POSTs the new device', async () => {
|
||||
it('Manual Add reveals a form (with IP) and POSTs the new device; MAC field auto-inserts colons', async () => {
|
||||
const host = document.getElementById('h');
|
||||
await renderDevicesBand(host);
|
||||
await new Promise(r => setTimeout(r, 0));
|
||||
expect(host.querySelector('.dv-addtoggle').textContent).toBe('+ Manual Add');
|
||||
host.querySelector('.dv-addtoggle').click(); // reveal the form
|
||||
const macI = host.querySelector('.dv-addform .dv-edit-name');
|
||||
macI.value = 'aa:bb:cc:dd:ee:ff';
|
||||
const [macI, ipI] = host.querySelectorAll('.dv-addform .dv-edit-name');
|
||||
macI.value = 'aabbccddeeff';
|
||||
macI.dispatchEvent(new window.Event('input')); // colon-mask
|
||||
expect(macI.value).toBe('aa:bb:cc:dd:ee:ff');
|
||||
ipI.value = '192.168.1.50';
|
||||
host.querySelector('.dv-addform .dv-add').click();
|
||||
await new Promise(r => setTimeout(r, 0));
|
||||
expect(api.post).toHaveBeenCalledWith('/api/devices', expect.objectContaining({ mac: 'aa:bb:cc:dd:ee:ff' }));
|
||||
expect(api.post).toHaveBeenCalledWith('/api/devices', expect.objectContaining({ mac: 'aa:bb:cc:dd:ee:ff', ip: '192.168.1.50' }));
|
||||
});
|
||||
|
||||
it('Scan Now triggers the scheduled scan', async () => {
|
||||
const host = document.getElementById('h');
|
||||
await renderDevicesBand(host);
|
||||
await new Promise(r => setTimeout(r, 0));
|
||||
host.querySelector('.dv-scanbtn').click();
|
||||
await new Promise(r => setTimeout(r, 0));
|
||||
expect(api.post).toHaveBeenCalledWith('/api/devices/scan');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user