Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/community/user-groups/public-sector/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Public Sector
sidebar_position: 1
sidebar_position: 2
description: Cloud native collaboration for public-sector end users.
slug: /community/user-groups/public-sector
---
Expand Down
2 changes: 1 addition & 1 deletion docs/community/user-groups/research/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Research
sidebar_position: 4
sidebar_position: 3
description: Research cloud native collaboration for scientific workloads.
slug: /community/user-groups/research
---
Expand Down
2 changes: 1 addition & 1 deletion docs/community/user-groups/telecom/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Telecom
sidebar_position: 2
sidebar_position: 4
description: Cloud native collaboration for telecom end users.
slug: /community/user-groups/telecom
---
Expand Down
54 changes: 54 additions & 0 deletions tests/community-group-coverage.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,57 @@ test('each status entry names the repository its page links', () => {
);
}
});

function hubOrder() {
const hub = readFileSync(join(pagesDir, 'index.md'), 'utf8');
return [...hub.matchAll(/\]\(\/community\/user-groups\/([a-z0-9-]+)\)/g)].map(
(match) => match[1],
);
}

function sidebarOrder() {
return pages()
.map((page) => ({
slug: page.slug,
position: Number(
/^sidebar_position:\s*(\d+)\s*$/m.exec(page.body)?.[1] ?? NaN,
),
}))
.sort((a, b) => a.position - b.position || a.slug.localeCompare(b.slug))
.map((entry) => entry.slug);
}

test('every User Group page declares a numeric sidebar_position', () => {
const missing = pages()
.filter((page) => !/^sidebar_position:\s*\d+\s*$/m.test(page.body))
.map((page) => page.file);

assert.deepEqual(
missing,
[],
`${missing.join(', ')} needs a numeric frontmatter sidebar_position; without one Docusaurus appends the page after the ordered ones`,
);
});

test('no two User Group pages share a sidebar_position', () => {
const positions = pages().map((page) =>
Number(/^sidebar_position:\s*(\d+)\s*$/m.exec(page.body)?.[1] ?? NaN),
);
const duplicated = positions.filter(
(position, index) => positions.indexOf(position) !== index,
);

assert.deepEqual(
duplicated,
[],
`sidebar_position ${duplicated.join(', ')} is declared by more than one page under docs/community/user-groups/; ties fall back to the source path, so the menu order stops being the one the frontmatter states`,
);
});

test('the sidebar orders the User Groups the way the hub page lists them', () => {
assert.deepEqual(
sidebarOrder(),
hubOrder(),
'the sidebar_position values under docs/community/user-groups/ order the groups differently from the list on docs/community/user-groups/index.md; readers see one order in the menu and another on the page',
);
});
Loading