mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-10-30 19:52:03 +01:00
- Add IconRss component and feedHref prop to ListToolbar - Wire feed links on Nodes, Advertisements, and Messages pages - Messages feed link respects channel filter, defaults to idx 17 - Simplify advert/node feed item bodies, link adverts to packet hashes - Add unit tests, page tests, and e2e specs for feed link behavior
101 lines
3.8 KiB
TypeScript
101 lines
3.8 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { countApiCalls, expectListLoaded, openFilters } from "../utils/helpers";
|
|
|
|
test.describe("messages", () => {
|
|
test("filter options work", async ({ page }) => {
|
|
await page.goto("/messages");
|
|
await expectListLoaded(page);
|
|
const table = page.locator("table");
|
|
await expect(page.getByTestId("list-row")).toHaveCount(4);
|
|
|
|
await openFilters(page);
|
|
await page.locator('select[name="message_type"]').selectOption("channel");
|
|
await page.getByRole("button", { name: "Filter" }).click();
|
|
await expect(page).toHaveURL(/message_type=channel/);
|
|
await expect(page.getByTestId("list-row")).toHaveCount(3);
|
|
|
|
// The channel select auto-submits on change.
|
|
await openFilters(page);
|
|
await page
|
|
.locator('select[name="channel_idx"]')
|
|
.selectOption({ label: "E2E General" });
|
|
await expect(page).toHaveURL(/channel_idx=\d+/);
|
|
await expect(page.getByTestId("list-row")).toHaveCount(1);
|
|
await expect(table.getByText("Ops channel traffic")).toBeVisible();
|
|
|
|
await page.goto("/messages");
|
|
await expectListLoaded(page);
|
|
await expect(page.getByTestId("list-row")).toHaveCount(4);
|
|
});
|
|
|
|
test("feed link respects the channel filter", async ({ page }) => {
|
|
await page.goto("/messages");
|
|
await expectListLoaded(page);
|
|
// No channel filter: defaults to the built-in public channel (idx 17).
|
|
const feedLink = page.getByTestId("feed-link");
|
|
await expect(feedLink).toHaveAttribute("href", "/feeds/channels/17.xml");
|
|
|
|
await feedLink.click();
|
|
await expect(page).toHaveURL(/\/feeds\/channels\/17\.xml$/);
|
|
const xml17 = await page.locator("pre").innerText();
|
|
expect(xml17).toContain("Hello from the e2e mesh");
|
|
|
|
// Selecting a community channel repoints the feed at that channel.
|
|
await page.goto("/messages");
|
|
await expectListLoaded(page);
|
|
await openFilters(page);
|
|
await page
|
|
.locator('select[name="channel_idx"]')
|
|
.selectOption({ label: "E2E General" });
|
|
await expect(page).toHaveURL(/channel_idx=\d+/);
|
|
const customLink = page.getByTestId("feed-link");
|
|
const href = await customLink.getAttribute("href");
|
|
expect(href).toMatch(/^\/feeds\/channels\/\d+\.xml$/);
|
|
expect(href).not.toBe("/feeds/channels/17.xml");
|
|
|
|
await customLink.click();
|
|
await expect(page).toHaveURL(/\/feeds\/channels\/\d+\.xml$/);
|
|
const xmlCustom = await page.locator("pre").innerText();
|
|
expect(xmlCustom).toContain("Ops channel traffic");
|
|
});
|
|
|
|
test("auto-refresh works and can be paused", async ({ page }) => {
|
|
await page.goto("/messages");
|
|
await expectListLoaded(page);
|
|
|
|
const toggle = page.getByTestId("auto-refresh-toggle");
|
|
await expect(toggle).toBeChecked();
|
|
|
|
const active = await countApiCalls(page, "/api/v1/messages?", 5000);
|
|
expect(active).toBeGreaterThanOrEqual(2);
|
|
|
|
await toggle.click();
|
|
await expect(toggle).not.toBeChecked();
|
|
const paused = await countApiCalls(page, "/api/v1/messages?", 4500);
|
|
expect(paused).toBe(0);
|
|
});
|
|
|
|
test("table row actions and observer toggle work", async ({ page }) => {
|
|
await page.goto("/messages");
|
|
await expectListLoaded(page);
|
|
const table = page.locator("table");
|
|
|
|
await expect(table.locator("span.observer-badge").first()).toBeVisible();
|
|
|
|
// Click a plain-text cell (Time) so the row handler navigates.
|
|
await page.getByTestId("list-row").first().locator("td").nth(1).click();
|
|
await expect(page).toHaveURL(/\/packets\/hash\//);
|
|
|
|
await page.goto("/messages");
|
|
await expectListLoaded(page);
|
|
await expect(page.getByTestId("list-row")).toHaveCount(4);
|
|
|
|
const north = page
|
|
.locator('[data-testid="observer-area"][data-area="North"]')
|
|
.first();
|
|
await north.click();
|
|
await expect(north).toHaveClass(/badge-ghost/);
|
|
await expect(page.getByTestId("list-row")).toHaveCount(2);
|
|
});
|
|
});
|