Show free disk capacity with the same bar and caption as RAM
Rust development slice / linux (push) Failing after 10s

This commit is contained in:
2026-11-20 08:31:15 +01:00
parent 0b0790de71
commit 9057808d16
5 changed files with 28 additions and 34 deletions
+19 -20
View File
@@ -20,7 +20,7 @@ test.beforeAll(async () => {
test.afterAll(async () => { await server?.close(); });
test('draws the free RAM share accurately on desktop and mobile', async ({ page }) => {
test('draws free disk and RAM shares accurately on desktop and mobile', async ({ page }) => {
const customer = { tenant_id: '11111111-1111-4111-8111-111111111111', name: 'RAM-Test' };
const gib = 2 ** 30;
const readings = [
@@ -48,33 +48,33 @@ test('draws the free RAM share accurately on desktop and mobile', async ({ page
json: listing(readings.map(([hostname, free, total]) => ({
tenant_id: customer.tenant_id, customer_name: customer.name, asset_id: hostname, agent_id: hostname,
lifecycle: 'current', status: 'online', hostname, ram_available_bytes: free, ram_total_bytes: total,
disk_free_bytes: 12 * gib, disk_total_bytes: 16 * gib
disk_free_bytes: free, disk_total_bytes: total
})))
});
return route.fulfill({ status: 404 });
});
await page.goto(`${origin}/#geraete`);
const row = (host: string) => page.getByRole('row').filter({ has: page.getByRole('button', { name: host, exact: true }) });
const ram = (host: string) => row(host).locator('[data-label="RAM frei / gesamt"]');
await expect(ram('mostly-free')).toContainText('12 / 16 GiB');
await expect(ram('mostly-free').locator('.capacity-caption')).toHaveText('75 % frei');
await expect(row('mostly-free').locator('[data-label="Speicher frei / gesamt"] .capacity-track i'))
.toHaveAttribute('style', 'width: 25%;');
for (const width of [1280, 900, 390]) {
await page.setViewportSize({ width, height: 844 });
for (const [host, free] of [['mostly-free', 75], ['all-used', 0], ['all-free', 100]] as const) {
const bar = ram(host).getByRole('img', { name: `${free} % frei, ${100 - free} % belegt` });
await expect(bar).toBeVisible();
const [track = 0, freeWidth = 0, usedWidth = 0] = await bar.evaluate(el => [el, ...Array.from(el.children)]
.map(part => part.getBoundingClientRect().width));
expect(track).toBeGreaterThan(0);
expect(freeWidth / track).toBeCloseTo(free / 100, 2);
expect(usedWidth / track).toBeCloseTo((100 - free) / 100, 2);
for (const label of ['RAM', 'Speicher']) {
const cell = (host: string) => row(host).locator(`[data-label="${label} frei / gesamt"]`);
await expect(cell('mostly-free')).toContainText('12 / 16 GiB');
for (const [host, free] of [['mostly-free', 75], ['all-used', 0], ['all-free', 100]] as const) {
await expect(cell(host).locator('.capacity-caption')).toHaveText(`${free} % frei`);
const bar = cell(host).getByRole('img', { name: `${free} % frei, ${100 - free} % belegt` });
await expect(bar).toBeVisible();
const [track = 0, freeWidth = 0, usedWidth = 0] = await bar.evaluate(el => [el, ...Array.from(el.children)]
.map(part => part.getBoundingClientRect().width));
expect(track).toBeGreaterThan(0);
expect(freeWidth / track).toBeCloseTo(free / 100, 2);
expect(usedWidth / track).toBeCloseTo((100 - free) / 100, 2);
}
for (const host of ['missing-available', 'invalid-range', 'invalid-total']) {
await expect(cell(host).locator('.capacity-track')).toHaveCount(0);
}
}
}
for (const host of ['missing-available', 'invalid-range', 'invalid-total']) {
await expect(ram(host).locator('.capacity-track')).toHaveCount(0);
}
});
test('creates and renames a customer, opens its inventory, and hides editing for a reader', async ({ page }) => {
@@ -171,8 +171,7 @@ test('creates and renames a customer, opens its inventory, and hides editing for
await expect(memory).toContainText('6 / 16 GiB');
await expect(memory.getByRole('img', { name: '37,5 % frei, 62,5 % belegt' })).toBeVisible();
await expect(memory.locator('.capacity-free')).toHaveAttribute('style', 'width: 37.5%;');
await expect(device.locator('[data-label="Speicher frei / gesamt"] .capacity-track i'))
.toHaveAttribute('style', 'width: 25%;');
await expect(device.locator('[data-label="Speicher frei / gesamt"]').getByRole('img', { name: '75 % frei, 25 % belegt' })).toBeVisible();
await expect(device.getByText('Auslastung 0 %', { exact: true })).toBeVisible();
const navigation = page.getByRole('navigation', { name: 'Hauptnavigation' });
await navigation.getByRole('link', { name: 'Aufträge', exact: true }).click();