feat(editor): F4.5e a router's connections in the device sheet
SheetRun now clicks through Java's JConnectionsDialog with a router, a computer and a switch cabled in the GUIContainer: a click marks a card, the same click unmarks it, another card swaps the cables or moves the one; "+" adds 192.168.0.10/24 up to eight cards, "-" removes the last card with its cable down to none, and a router without a card keeps no gateway. The document adds, removes and swaps a router's cards (the same cables, the same devices), Java's click logic is one function for the test and the page, and the sheet names the address at a cable's far end. The page "Verbindungen verwalten" shows Java's RJ45 buttons in Java's colours with each card's far end below. Not adopted: the last card stays. A card tab or a mark whose card is undone away falls back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -400,6 +400,102 @@ test("sets up a router's firewall on its own page: the switches, the default, ru
|
||||
await expect(sheet(page).getByRole('heading')).toHaveText('Vermittlungsrechner');
|
||||
});
|
||||
|
||||
test("manages a router's connections on its own page: cables swapped with two taps, cards added and removed, the last kept", async ({ page }) => {
|
||||
await openEditor(page, server.base, 'zwei_rechnernetze_komplett.fls');
|
||||
const id = (await drawing(page)).nodes.find((node) => node.kind === 'router')!.id;
|
||||
await choose(page, id);
|
||||
const joined = async () => ((await sheetOf(page, id)) as RouterSheet).interfaces.map((card) => card.connected?.device ?? '');
|
||||
const values = (await sheetOf(page, id)) as RouterSheet;
|
||||
const [one, two] = await joined();
|
||||
const cables = (await drawing(page)).links.length;
|
||||
await sheet(page).getByRole('button', { name: 'Verbindungen verwalten' }).click();
|
||||
await expect(sheet(page).getByRole('heading', { level: 2 })).toHaveText('Verbindungen verwalten');
|
||||
const items = sheet(page).locator('ol.connections li');
|
||||
const port = (index: number) => items.nth(index).getByRole('button');
|
||||
await expect(items.locator('.connection-local')).toHaveText(values.interfaces.map((card, index) => `NIC ${index + 1}: ${card.ipAddress}`));
|
||||
await expect(items.locator('.connection-remote')).toHaveText([one!, two!]);
|
||||
// Java's colours: green for a plugged card, yellow for the marked one, red for a free one.
|
||||
await expect(port(0)).toHaveCSS('background-color', 'rgb(0, 255, 0)');
|
||||
await port(0).click();
|
||||
await expect(port(0)).toHaveAttribute('aria-pressed', 'true');
|
||||
await expect(port(0)).toHaveCSS('background-color', 'rgb(255, 255, 0)');
|
||||
await port(0).click();
|
||||
await expect(port(0)).toHaveAttribute('aria-pressed', 'false');
|
||||
await port(0).click();
|
||||
await port(1).click();
|
||||
await expect.poll(joined).toEqual([two, one]);
|
||||
await expect(items.nth(0)).toHaveAttribute('data-state', 'plugged');
|
||||
|
||||
await sheet(page).getByRole('button', { name: 'Schnittstelle hinzufügen' }).click();
|
||||
await expect(items).toHaveCount(3);
|
||||
await expect(items.nth(2).locator('.connection-local')).toHaveText('NIC 3: 192.168.0.10');
|
||||
await expect(port(2)).toHaveCSS('background-color', 'rgb(255, 0, 0)');
|
||||
await expect(port(2)).toHaveAccessibleName('NIC 3: 192.168.0.10, Keine Verbindung');
|
||||
// A free card takes the marked card's cable.
|
||||
await port(0).click();
|
||||
await port(2).click();
|
||||
await expect.poll(joined).toEqual(['', one, two]);
|
||||
await sheet(page).getByRole('button', { name: 'Schnittstelle entfernen' }).click();
|
||||
await expect.poll(joined).toEqual(['', one]);
|
||||
expect((await drawing(page)).links).toHaveLength(cables - 1);
|
||||
|
||||
for (let count = 2; count < 8; count++) await sheet(page).getByRole('button', { name: 'Schnittstelle hinzufügen' }).click();
|
||||
await expect(items).toHaveCount(8);
|
||||
await expect(sheet(page).getByRole('button', { name: 'Schnittstelle hinzufügen' })).toBeDisabled();
|
||||
await expect(sheet(page).getByText('Maximal 8 Schnittstellen erlaubt!')).toBeVisible();
|
||||
for (let count = 8; count > 1; count--) await sheet(page).getByRole('button', { name: 'Schnittstelle entfernen' }).click();
|
||||
await expect(items).toHaveCount(1);
|
||||
await expect(sheet(page).getByRole('button', { name: 'Schnittstelle entfernen' })).toBeDisabled();
|
||||
await expect(sheet(page).getByText('Eine Schnittstelle bleibt immer.')).toBeVisible();
|
||||
|
||||
await sheet(page).getByRole('button', { name: 'Zurück' }).click();
|
||||
const tabs = sheet(page).getByRole('tab');
|
||||
await expect(tabs).toHaveText(['Allgemein', values.interfaces[0]!.ipAddress, 'Weiterleitungstabelle']);
|
||||
// Undone, the second card comes back with its cable; a card's tab whose card goes again shows the general tab.
|
||||
await page.keyboard.press('Control+z');
|
||||
await expect(tabs).toHaveCount(4);
|
||||
await tabs.nth(2).click();
|
||||
await expect(sheet(page).locator('.sheet-connected')).toHaveText(`Verbunden mit ${one}`);
|
||||
await page.keyboard.press('Control+Shift+z');
|
||||
await expect(tabs).toHaveCount(3);
|
||||
await expect(tabs.first()).toHaveAttribute('aria-selected', 'true');
|
||||
await expect(field(page, 'name')).toHaveValue(values.name);
|
||||
});
|
||||
|
||||
test("names a router's computer by its address, and lets go of a marked card when cards change", async ({ page }) => {
|
||||
await openEditor(page, server.base, 'internetwork_komplett.fls');
|
||||
const routers = (await drawing(page)).nodes.filter((node) => node.kind === 'router');
|
||||
let id = '';
|
||||
for (const each of routers) if (((await sheetOf(page, each.id)) as RouterSheet).interfaces.some((card) => card.connected?.address)) id = each.id;
|
||||
await choose(page, id);
|
||||
const values = (await sheetOf(page, id)) as RouterSheet;
|
||||
await sheet(page).getByRole('button', { name: 'Verbindungen verwalten' }).click();
|
||||
const items = sheet(page).locator('ol.connections li');
|
||||
const port = (index: number) => items.nth(index).getByRole('button');
|
||||
// Java: a computer's or a router's name with the address of its card, a switch's name alone.
|
||||
await expect(items.locator('.connection-remote')).toHaveText(
|
||||
values.interfaces.flatMap((card) => (card.connected === null ? [] : [card.connected.address === null ? card.connected.device : `${card.connected.device} (${card.connected.address})`])),
|
||||
);
|
||||
expect(values.interfaces.some((card) => card.connected?.address !== null && card.connected?.address !== undefined)).toBe(true);
|
||||
const pressed = () => sheet(page).locator('.connection-port[aria-pressed="true"]');
|
||||
await port(0).click();
|
||||
await sheet(page).getByRole('button', { name: 'Schnittstelle hinzufügen' }).click();
|
||||
await expect(pressed()).toHaveCount(0);
|
||||
await port(0).click();
|
||||
await sheet(page).getByRole('button', { name: 'Schnittstelle entfernen' }).click();
|
||||
await expect(pressed()).toHaveCount(0);
|
||||
// A marked card undone away is marked no more: the next tap marks, it swaps nothing.
|
||||
await sheet(page).getByRole('button', { name: 'Schnittstelle hinzufügen' }).click();
|
||||
const count = values.interfaces.length + 1;
|
||||
await port(count - 1).click();
|
||||
await page.keyboard.press('Control+z');
|
||||
await expect(items).toHaveCount(count - 1);
|
||||
const before = ((await sheetOf(page, id)) as RouterSheet).interfaces.map((card) => card.connected?.link ?? null);
|
||||
await port(0).click();
|
||||
await expect(port(0)).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(((await sheetOf(page, id)) as RouterSheet).interfaces.map((card) => card.connected?.link ?? null)).toEqual(before);
|
||||
});
|
||||
|
||||
test("opens a home router's firewall from its general tab", async ({ page }) => {
|
||||
await openEditor(page, server.base, 'new');
|
||||
await page.locator('[data-palette="gateway"]').click();
|
||||
|
||||
Reference in New Issue
Block a user