From 839e888e3a7e348b200cb6eeda68b782a12e782c Mon Sep 17 00:00:00 2001 From: Isabel Tomb Date: Mon, 8 Jul 2024 13:44:01 -0500 Subject: [PATCH] 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 --- .../src/stages/generate/helpers.test.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plugins/techdocs-node/src/stages/generate/helpers.test.ts b/plugins/techdocs-node/src/stages/generate/helpers.test.ts index 3589b71c60..a40239c595 100644 --- a/plugins/techdocs-node/src/stages/generate/helpers.test.ts +++ b/plugins/techdocs-node/src/stages/generate/helpers.test.ts @@ -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',