The links menu moves into @hive/shared and takes its links as a prop. The swarm UI feeds it /api/links as before; the dashboard feeds it stats, API docs and the swarm, and mounts it next to the profile menu in place of its own hamburger on the left. A link opens in a new tab unless its entry says it is a page of the same site.
23 lines
792 B
JavaScript
23 lines
792 B
JavaScript
// How a link in the links menu opens. Run by `npm test`, which Node runs with
|
|
// its built-in test runner and type stripping.
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { linkAttrs } from "../../shared/src/links-menu/links.ts";
|
|
|
|
test("a link the menu was handed opens in a new tab, without a referrer", () => {
|
|
assert.deepEqual(linkAttrs({ label: "forge", url: "https://forge.x" }), {
|
|
target: "_blank",
|
|
rel: "noreferrer",
|
|
});
|
|
assert.deepEqual(
|
|
linkAttrs({ label: "forge", url: "https://forge.x", external: true }),
|
|
{ target: "_blank", rel: "noreferrer" },
|
|
);
|
|
});
|
|
|
|
test("a page of the same site opens in place", () => {
|
|
assert.deepEqual(
|
|
linkAttrs({ label: "stats", url: "/stats.html", external: false }),
|
|
{},
|
|
);
|
|
});
|