Support interactive customer transfers for enrolled devices
Rust development slice / linux (push) Failing after 8s
Rust development slice / linux (push) Failing after 8s
This commit is contained in:
@@ -218,3 +218,77 @@ test('removes the confirmed historical installation and keeps its successor', as
|
||||
await expect(page.getByText('Gerät verwalten', { exact: true })).toHaveCount(0);
|
||||
expect(attempts).toBe(2);
|
||||
});
|
||||
|
||||
test('moves an existing pairing through the WebUI and waits for target inventory', async ({ page }) => {
|
||||
const source = { tenant_id: '11111111-1111-4111-8111-111111111111', name: 'Nord GmbH' };
|
||||
const target = { tenant_id: '22222222-2222-4222-8222-222222222222', name: 'Süd GmbH' };
|
||||
const device = { tenant_id: source.tenant_id, customer_name: source.name,
|
||||
asset_id: 'existing-asset', agent_id: 'existing-agent', hostname: 'NORD-PC', os: 'Linux',
|
||||
capabilities: ['device.customer_transfer/1'], lifecycle: 'current', status: 'online',
|
||||
recent_jobs: [], volumes: [] };
|
||||
const path = '/api/v1/tenants/' + source.tenant_id + '/devices/' + device.asset_id;
|
||||
const move = path + '/customer-transfer';
|
||||
const transfer = { transfer_id: 'move-fixture', target_tenant_id: target.tenant_id,
|
||||
target_asset_id: 'new-asset', target_agent_id: 'new-agent', target_hostname: 'NORD-PC' };
|
||||
let state = '';
|
||||
let canEnroll = false;
|
||||
const listing = (items: unknown[]) => ({ items, next_cursor: null, truncated: false,
|
||||
completeness: 'complete', as_of: new Date().toISOString() });
|
||||
await page.route(origin + '/auth/config', r => r.fulfill({ json: {
|
||||
local_login_enabled: true, oidc_configured: false, oidc_login_url: null, dev_login_enabled: false
|
||||
} }));
|
||||
await page.route(origin + '/auth/session', r => {
|
||||
const selected = r.request().headers()['x-rmm-tenant'] ?? source.tenant_id;
|
||||
return r.fulfill({ json: { principal: 'fixture-operator', tenant_id: selected,
|
||||
csrf_token: 'move-csrf', testsimulation: false,
|
||||
permissions: ['inventory:read', ...(selected === source.tenant_id ? ['devices:revoke'] :
|
||||
canEnroll ? ['devices:enroll'] : [])] } });
|
||||
});
|
||||
await page.route(origin + '/api/v1/**', async r => {
|
||||
const req = r.request(), url = new URL(req.url());
|
||||
if (url.pathname === '/api/v1/tenants') return r.fulfill({ json: listing([source, target]) });
|
||||
if (url.pathname === path) return r.fulfill({ json: {
|
||||
...device, lifecycle: state === 'completed' ? 'revoked' : 'current'
|
||||
} });
|
||||
if (url.pathname === move && req.method() === 'GET') {
|
||||
return r.fulfill({ json: { transfer: state ? { ...transfer, state } : null } });
|
||||
}
|
||||
if (req.method() === 'POST') {
|
||||
expect(req.headers()['x-csrf-token']).toBe('move-csrf');
|
||||
expect(req.headers()['x-rmm-tenant']).toBe(source.tenant_id);
|
||||
expect(url.searchParams.get('agent_id')).toBe(device.agent_id);
|
||||
if (url.pathname === move) {
|
||||
expect(req.postDataJSON()).toEqual({ target_tenant_id: target.tenant_id });
|
||||
state = 'pending';
|
||||
} else {
|
||||
expect(url.pathname).toBe(move + '/move-fixture/complete');
|
||||
expect(state).toBe('ready');
|
||||
state = 'completed';
|
||||
}
|
||||
return r.fulfill({ json: { state } });
|
||||
}
|
||||
return r.fulfill({ status: 404, json: { code: 'NOT_FOUND' } });
|
||||
});
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await page.goto(origin + '/#geraete/' + [source.tenant_id, device.asset_id, device.agent_id].join('/'));
|
||||
await page.getByText('Gerät verwalten', { exact: true }).click();
|
||||
await page.getByText('Kunden wechseln', { exact: true }).click();
|
||||
await page.getByRole('combobox', { name: 'Zielkunde', exact: true }).selectOption(target.tenant_id);
|
||||
await expect(page.getByText('Für diesen Zielkunden fehlt das Recht', { exact: false })).toBeVisible();
|
||||
const prepare = page.getByRole('button', { name: 'Kundenwechsel vormerken' });
|
||||
await expect(prepare).toBeDisabled();
|
||||
await page.getByRole('combobox', { name: 'Zielkunde', exact: true }).selectOption('');
|
||||
canEnroll = true;
|
||||
await page.getByRole('combobox', { name: 'Zielkunde', exact: true }).selectOption(target.tenant_id);
|
||||
await prepare.click();
|
||||
await expect(page.getByText('Der Wechsel ist vorgemerkt.', { exact: false })).toBeVisible();
|
||||
const finish = page.getByRole('button', { name: 'Kundenwechsel abschließen' });
|
||||
await expect(finish).toHaveCount(0);
|
||||
state = 'ready';
|
||||
await expect(finish).toBeDisabled({ timeout: 10000 });
|
||||
await page.getByRole('checkbox', { name: 'Ich bestätige den Kundenwechsel für dieses Gerät.' }).check();
|
||||
await finish.click();
|
||||
await expect(page.getByText('Kundenwechsel abgeschlossen.', { exact: false })).toBeVisible();
|
||||
await expect(page.getByRole('link', { name: 'Neue Kopplung öffnen' })).toHaveAttribute('href',
|
||||
'#geraete/' + target.tenant_id + '/new-asset/new-agent');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user