Skip to content

Commit ee8a27d

Browse files
committed
refactor(e2e,audit,docs): relocate tests, json from embedded links
* build, github action for auditing * docs.json, move embedded links into json * docs.embedded, fallback links in the event the json fails to load * audit, links valid check * e2e, relocate tests to allow for audit tests
1 parent 4c52846 commit ee8a27d

23 files changed

Lines changed: 3334 additions & 12 deletions

.github/workflows/audit.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Data Audit
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'src/docs.json'
7+
- 'tests/audit/**'
8+
schedule:
9+
- cron: '0 0 * * *' # Daily at midnight
10+
workflow_dispatch:
11+
12+
jobs:
13+
audit-links:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v6
19+
with:
20+
node-version: 22.x
21+
cache: npm
22+
- name: Install dependencies
23+
run: npm ci
24+
- name: Run documentation audit
25+
run: npm run test:audit
26+
env:
27+
# Higher limit for scheduled runs (0 = no limit), lower for PRs
28+
DOCS_AUDIT_MAX_TOTAL: ${{ github.event_name == 'schedule' && '0' || '50' }}
29+
continue-on-error: ${{ github.event_name == 'pull_request' }}

jest.config.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,19 @@ export default {
4747
},
4848
{
4949
displayName: 'e2e',
50-
roots: ['tests'],
51-
testMatch: ['<rootDir>/tests/**/*.test.ts'],
52-
setupFilesAfterEnv: ['<rootDir>/tests/jest.setupTests.ts'],
50+
roots: ['tests/e2e'],
51+
testMatch: ['<rootDir>/tests/e2e/**/*.test.ts'],
52+
setupFilesAfterEnv: ['<rootDir>/tests/e2e/jest.setupTests.ts'],
5353
transformIgnorePatterns: [
5454
'<rootDir>/dist/'
5555
],
5656
...baseConfig
57+
},
58+
{
59+
displayName: 'audit',
60+
roots: ['tests/audit'],
61+
testMatch: ['<rootDir>/tests/audit/**/*.test.ts'],
62+
...baseConfig
5763
}
5864
]
5965
};

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "dist/index.js",
66
"type": "module",
77
"imports": {
8+
"~docsCatalog": "./src/docs.json",
89
"#toolsHost": "./dist/server.toolsHost.js"
910
},
1011
"exports": {
@@ -33,8 +34,9 @@
3334
"start:dev": "tsx watch src/cli.ts --verbose --log-stderr",
3435
"test": "npm run test:spell && npm run test:spell-docs && npm run test:lint && npm run test:types && jest --selectProjects unit --roots=src/",
3536
"test:dev": "npm test -- --watchAll",
36-
"test:integration": "npm run build && NODE_OPTIONS='--experimental-vm-modules' jest --selectProjects e2e --roots=tests/",
37+
"test:integration": "npm run build && NODE_OPTIONS='--experimental-vm-modules' jest --selectProjects e2e --roots=tests/e2e/",
3738
"test:integration-dev": "npm run test:integration -- --watchAll",
39+
"test:audit": "jest --selectProjects audit --roots=tests/audit/",
3840
"test:lint": "eslint .",
3941
"test:lint-fix": "eslint . --fix",
4042
"test:spell-docs": "cspell './README.md' './CONTRIBUTING.md' './docs/**/*.md' './guidelines/**/*.md' './docs/**/*.ts' './docs/**/*.js' --config ./cspell.config.json --fail-fast",
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`EMBEDDED_DOCS should export the expected embedded docs structure: docs 1`] = `
4+
{
5+
"docs": {
6+
"React": [
7+
{
8+
"category": "react",
9+
"description": "Direct source for PatternFly React component examples.",
10+
"displayName": "PatternFly React Docs",
11+
"path": "https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/README.md",
12+
"pathSlug": "patternfly-react",
13+
"section": "components",
14+
"source": "github",
15+
"version": "v6",
16+
},
17+
{
18+
"category": "react",
19+
"description": "AI guidance for PatternFly React development rules.",
20+
"displayName": "React Development Rules",
21+
"path": "https://raw.githubusercontent.com/patternfly/ai-helpers/refs/heads/main/docs/README.md",
22+
"pathSlug": "react-development",
23+
"section": "guidelines",
24+
"source": "github",
25+
"version": "v6",
26+
},
27+
],
28+
"patternfly": [
29+
{
30+
"category": "reference",
31+
"description": "Official PatternFly design system website.",
32+
"displayName": "PatternFly Home",
33+
"path": "https://www.patternfly.org",
34+
"pathSlug": "patternfly-home",
35+
"section": "home",
36+
"source": "website",
37+
"version": "v6",
38+
},
39+
{
40+
"category": "reference",
41+
"description": "PatternFly organization on GitHub (Core & React).",
42+
"displayName": "PatternFly GitHub",
43+
"path": "https://github.com/patternfly",
44+
"pathSlug": "patternfly-github",
45+
"section": "github",
46+
"source": "github",
47+
"version": "v6",
48+
},
49+
{
50+
"category": "reference",
51+
"description": "Direct source for PatternFly documentation and guidelines.",
52+
"displayName": "PatternFly Org",
53+
"path": "https://github.com/patternfly/patternfly-org",
54+
"pathSlug": "patternfly-org",
55+
"section": "github",
56+
"source": "github",
57+
"version": "v6",
58+
},
59+
],
60+
},
61+
"meta": {
62+
"source": "patternfly-mcp-fallback",
63+
"totalDocs": 5,
64+
"totalEntries": 2,
65+
},
66+
}
67+
`;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { EMBEDDED_DOCS } from '../docs.embedded';
2+
3+
describe('EMBEDDED_DOCS', () => {
4+
it('should export the expected embedded docs structure', () => {
5+
expect(EMBEDDED_DOCS).toMatchSnapshot('docs');
6+
});
7+
8+
it('should contain valid high-level metadata and entry points', () => {
9+
const { docs, meta } = EMBEDDED_DOCS;
10+
11+
expect(meta.source).toBe('patternfly-mcp-fallback');
12+
expect(docs).toHaveProperty('patternfly');
13+
expect(docs).toHaveProperty('React');
14+
15+
const allDocs = Object.values(docs).flat();
16+
17+
expect(allDocs.length).toBeGreaterThanOrEqual(5);
18+
});
19+
});

src/docs.embedded.ts

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/**
2+
* PatternFly JSON catalog doc
3+
*/
4+
type PatternFlyMcpDocsCatalogDoc = {
5+
displayName: string;
6+
description: string;
7+
pathSlug: string;
8+
section: string;
9+
category: string;
10+
source: string;
11+
path: string;
12+
version: string;
13+
};
14+
15+
/**
16+
* PatternFly JSON catalog documentation entries.
17+
*/
18+
type PatternFlyMcpDocsCatalogEntry = {
19+
[key: string]: PatternFlyMcpDocsCatalogDoc[]
20+
};
21+
22+
/**
23+
* PatternFly documentation catalog.
24+
*
25+
* @interface PatternFlyMcpDocsCatalog
26+
*
27+
* @property [version] - Version of the catalog.
28+
* @property [generated] - Date when the catalog was generated.
29+
* @property {PatternFlyMcpDocsCatalogEntry} docs - PatternFly documentation entries.
30+
*/
31+
interface PatternFlyMcpDocsCatalog {
32+
version?: string;
33+
generated?: string;
34+
meta: {
35+
totalEntries: number;
36+
totalDocs: number;
37+
source: string;
38+
};
39+
docs: PatternFlyMcpDocsCatalogEntry
40+
}
41+
42+
/**
43+
* Fallback documentation for when the catalog is unavailable.
44+
* Points to the high-level entry points for PatternFly.
45+
*/
46+
const EMBEDDED_DOCS: PatternFlyMcpDocsCatalog = {
47+
meta: {
48+
totalEntries: 2,
49+
totalDocs: 5,
50+
source: 'patternfly-mcp-fallback'
51+
},
52+
docs: {
53+
patternfly: [
54+
{
55+
displayName: 'PatternFly Home',
56+
description: 'Official PatternFly design system website.',
57+
pathSlug: 'patternfly-home',
58+
section: 'home',
59+
category: 'reference',
60+
source: 'website',
61+
path: 'https://www.patternfly.org',
62+
version: 'v6'
63+
},
64+
{
65+
displayName: 'PatternFly GitHub',
66+
description: 'PatternFly organization on GitHub (Core & React).',
67+
pathSlug: 'patternfly-github',
68+
section: 'github',
69+
category: 'reference',
70+
source: 'github',
71+
path: 'https://github.com/patternfly',
72+
version: 'v6'
73+
},
74+
{
75+
displayName: 'PatternFly Org',
76+
description: 'Direct source for PatternFly documentation and guidelines.',
77+
pathSlug: 'patternfly-org',
78+
section: 'github',
79+
category: 'reference',
80+
source: 'github',
81+
path: 'https://github.com/patternfly/patternfly-org',
82+
version: 'v6'
83+
}
84+
],
85+
React: [
86+
{
87+
displayName: 'PatternFly React Docs',
88+
description: 'Direct source for PatternFly React component examples.',
89+
pathSlug: 'patternfly-react',
90+
section: 'components',
91+
category: 'react',
92+
source: 'github',
93+
path: 'https://raw.githubusercontent.com/patternfly/patternfly-react/refs/heads/main/README.md',
94+
version: 'v6'
95+
},
96+
{
97+
displayName: 'React Development Rules',
98+
description: 'AI guidance for PatternFly React development rules.',
99+
pathSlug: 'react-development',
100+
section: 'guidelines',
101+
category: 'react',
102+
source: 'github',
103+
path: 'https://raw.githubusercontent.com/patternfly/ai-helpers/refs/heads/main/docs/README.md',
104+
version: 'v6'
105+
}
106+
]
107+
}
108+
};
109+
110+
export {
111+
EMBEDDED_DOCS,
112+
type PatternFlyMcpDocsCatalog,
113+
type PatternFlyMcpDocsCatalogEntry,
114+
type PatternFlyMcpDocsCatalogDoc
115+
};

0 commit comments

Comments
 (0)