Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Write test for bad pattern: .md/# #23609

Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ jobs:
- name: Lint fenced code blocks
run: yarn -s doc-fence-check

- name: Lint website docs
run: yarn -s lint-website-docs
- name: Lint documentation
run: yarn -s lint-documentation

lint-other:
needs: [setup]
Expand Down
3 changes: 0 additions & 3 deletions lib/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,6 @@ export interface RenovateOptionBase {
| 'postUpgradeTasks'
| 'regexManagers';

// used by tests
relatedOptions?: string[];

stage?: RenovateConfigStage;

experimental?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"debug": "cross-env NODE_OPTIONS=--inspect-brk ts-node lib/renovate.ts",
"doc-fix": "run-s markdown-lint-fix prettier-fix",
"doc-fence-check": "node tools/check-fenced-code.mjs",
"lint-website-docs": "jest --coverage false test/website-docs.spec.ts",
"lint-documentation": "jest --coverage false test/documentation.spec.ts",
"eslint": "eslint . --cache --cache-location .cache/eslint --report-unused-disable-directives",
"eslint-fix": "eslint --cache --cache-location .cache/eslint --fix . --report-unused-disable-directives",
"eslint-ci": "eslint . --cache --cache-strategy content --cache-location .cache/eslint --format gha",
Expand Down
88 changes: 88 additions & 0 deletions test/documentation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import fs from 'fs-extra';
import { glob } from 'glob';
import { getOptions } from '../lib/config/options';
import { regEx } from '../lib/util/regex';

const options = getOptions();
const markdownGlob = '{docs,lib}/**/*.md';

describe('documentation', () => {
it('has no invalid links', async () => {
const markdownFiles = await glob(markdownGlob);

await Promise.all(
markdownFiles.map(async (markdownFile) => {
const markdownText = await fs.readFile(markdownFile, 'utf8');
expect(markdownText).not.toMatch(regEx(/\.md\/#/));
})
);
});

describe('website-documentation', () => {
describe('configuration-options', () => {
const doc = fs.readFileSync(
'docs/usage/configuration-options.md',
'utf8'
);

const headers = doc
.match(/\n## (.*?)\n/g)
?.map((match) => match.substring(4, match.length - 1));

const expectedOptions = options
.filter((option) => !option.globalOnly)
.filter((option) => !option.parent)
.filter((option) => !option.autogenerated)
.map((option) => option.name)
.sort();

it('has doc headers sorted alphabetically', () => {
expect(headers).toEqual([...headers!].sort());
});

it('has headers for every required option', () => {
expect(headers).toEqual(expectedOptions);
});

const subHeaders = doc
.match(/\n### (.*?)\n/g)
?.map((match) => match.substring(5, match.length - 1));
subHeaders!.sort();
const expectedSubOptions = options
.filter((option) => option.stage !== 'global')
.filter((option) => !option.globalOnly)
.filter((option) => option.parent)
.map((option) => option.name)
.sort();
expectedSubOptions.sort();

it('has headers for every required sub-option', () => {
expect(subHeaders).toEqual(expectedSubOptions);
});
});

describe('self-hosted-configuration', () => {
const doc = fs.readFileSync(
'docs/usage/self-hosted-configuration.md',
'utf8'
);

const headers = doc
.match(/\n## (.*?)\n/g)
?.map((match) => match.substring(4, match.length - 1));

const expectedOptions = options
.filter((option) => !!option.globalOnly)
.map((option) => option.name)
.sort();

it('has headers sorted alphabetically', () => {
expect(headers).toEqual([...headers!].sort());
});

it('has headers for every required option', () => {
expect(headers).toEqual(expectedOptions);
});
});
});
});
117 changes: 0 additions & 117 deletions test/website-docs.spec.ts

This file was deleted.