This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/website/test/sidebarIntegrations.mjs
Jens Langhammer b225f6f3ff
website: add sidebar item tests, bump node version to latest LTS
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
2023-02-09 22:06:07 +01:00

56 lines
2 KiB
JavaScript

import test from "node:test";
import assert from "node:assert";
import sidebar from "../sidebarsIntegrations.js";
import glob from "glob";
const getSidebarItems = () => {
const allItems = [];
const mapper = (category) => {
category.items.forEach((item) => {
if (item.constructor === String) {
allItems.push(item);
} else {
mapper(item);
}
});
};
sidebar.integrations.forEach(mapper);
return allItems.sort();
};
test("ensure all services have a sidebar entry", (t) => {
// All services in the sidebar
const services = getSidebarItems()
.filter((entry) => entry.startsWith("services/"))
.map((entry) => entry.replace("/index", ""))
.map((entry) => entry.replace("services/", ""));
const servicesFiles = glob
.sync("integrations/**/*.+(md|mdx)")
.filter((entry) => entry.startsWith("integrations/services/"))
.map((entry) => entry.replace("integrations/services/", ""))
.map((entry) => entry.replace(/\/index\.mdx?/, ""))
.filter((entry) => entry !== "index.mdx")
.sort();
servicesFiles.forEach((file, idx) => {
assert.strictEqual(file, services[idx]);
});
});
test("ensure all sources have a sidebar entry", (t) => {
// All sources in the sidebar
const sources = getSidebarItems()
.filter((entry) => entry.startsWith("sources/"))
.map((entry) => entry.replace("/index", ""))
.map((entry) => entry.replace("sources/", ""));
const sourceFiles = glob
.sync("integrations/**/*.+(md|mdx)")
.filter((entry) => entry.startsWith("integrations/sources/"))
.map((entry) => entry.replace("integrations/sources/", ""))
.map((entry) => entry.replace(/\/index\.mdx?/, ""))
.map((entry) => entry.replace(".md", ""))
.sort();
sourceFiles.forEach((file, idx) => {
assert.strictEqual(file, sources[idx]);
});
});