Add a test for new repo_url edit_uri scenario

Add a test that checks that an edit_uri will be generated as expected
if the mkdocs.yml contains a `repo_url` value but no `edit_uri` vlaue.

Signed-off-by: Isabel Tomb <isabelgtomb@gmail.com>
This commit is contained in:
Isabel Tomb
2024-07-08 13:44:01 -05:00
parent 949083ddb4
commit 839e888e3a
@@ -299,6 +299,31 @@ describe('helpers', () => {
);
});
it('should add edit_uri to mkdocs.yml with existing repo_url', async () => {
const parsedLocationAnnotation: ParsedLocationAnnotation = {
type: 'url',
target: 'https://github.com/neworg/newrepo/tree/main/',
};
await patchMkdocsYmlPreBuild(
mockDir.resolve('mkdocs_with_repo_url.yml'),
mockLogger,
parsedLocationAnnotation,
scmIntegrations,
);
const updatedMkdocsYml = await fs.readFile(
mockDir.resolve('mkdocs_with_repo_url.yml'),
);
expect(updatedMkdocsYml.toString()).toContain(
'edit_uri: https://github.com/neworg/newrepo/edit/main/docs',
);
expect(updatedMkdocsYml.toString()).toContain(
'repo_url: https://github.com/backstage/backstage',
);
});
it('should not update mkdocs.yml if nothing should be changed', async () => {
const parsedLocationAnnotation: ParsedLocationAnnotation = {
type: 'dir',