Fix issue #90: Add a docs button
All checks were successful
Test / test (push) Successful in 2s
All checks were successful
Test / test (push) Successful in 2s
This commit is contained in:
@@ -327,6 +327,43 @@ test("the main menu points at the documentation", () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Inside a campaign the documentation is reached from the top bar, on the left of the campaign
|
||||
// settings button (Syndria98/dragonroll#90).
|
||||
test("the campaign top bar points at the documentation", () => {
|
||||
const topBar = readRepoFile("frontend", "app", "components", "viewer", "TopBar.vue");
|
||||
const right = /<div class="right">([\s\S]*?)<\/div>/.exec(topBar)?.[1];
|
||||
assert.ok(right, "expected the top bar to have its buttons in a right-hand group");
|
||||
|
||||
assert.match(right, /href="\/docs"/, "the top bar has to link to /docs");
|
||||
assert.match(right, /main-menu\.documentation/, "under the same label the main menu uses");
|
||||
|
||||
// To the left of the settings button: the group is read left to right, so the link has to
|
||||
// come first in it.
|
||||
const docsAt = right.indexOf('href="/docs"');
|
||||
const settingsAt = right.indexOf("OpenCampaignSettings");
|
||||
assert.ok(
|
||||
docsAt !== -1 && settingsAt !== -1 && docsAt < settingsAt,
|
||||
"the documentation button sits on the left of the settings button"
|
||||
);
|
||||
|
||||
// /docs is another page, and the open notes of the campaign live only in memory, so the link
|
||||
// opens it somewhere that does not throw the campaign away.
|
||||
assert.match(right, /target="_blank"/, "the campaign stays as it was behind the documentation");
|
||||
assert.match(right, /rel="[^"]*noopener/, "a tab the app does not control must not be able to reach it");
|
||||
|
||||
// The link is an `<a>` and the buttons are styled by element, so it carries its own look, in
|
||||
// theme colours like everything else.
|
||||
const look = /\.docs-button\s*\{[^}]*\}/.exec(topBar)?.[0];
|
||||
assert.ok(look, "the documentation link has to look like the buttons next to it");
|
||||
for (const declaration of [
|
||||
"background-color: var\\(--color-button-background\\)",
|
||||
"color: var\\(--color-text\\)",
|
||||
"border: solid 1px var\\(--color-border\\)",
|
||||
]) {
|
||||
assert.match(look, new RegExp(declaration), "the link's look uses the theme's colours");
|
||||
}
|
||||
});
|
||||
|
||||
// --- How the documentation is laid out (Syndria98/dragonroll#85) ---
|
||||
|
||||
// The `<style>` of DocsView.vue read as `{ selector, media, declarations }` rules: the block is
|
||||
|
||||
Reference in New Issue
Block a user