Merge pull request #23443 from backstage/add-defaultScmResolveUrl-test-cases

integration: add some additional test cases for defaultScmResolveUrl
This commit is contained in:
Fredrik Adelöw
2024-03-11 11:51:32 +01:00
committed by GitHub
+36
View File
@@ -88,6 +88,24 @@ describe('isValidHost', () => {
describe('defaultScmResolveUrl', () => {
it('works for relative paths and retains query params', () => {
expect(
defaultScmResolveUrl({
url: './b.yaml',
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/',
}),
).toBe(
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/b.yaml',
);
expect(
defaultScmResolveUrl({
url: './b.yaml',
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/subfolder',
}),
).toBe(
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/b.yaml',
);
expect(
defaultScmResolveUrl({
url: './b.yaml',
@@ -106,6 +124,24 @@ describe('defaultScmResolveUrl', () => {
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/b.yaml?at=master',
);
expect(
defaultScmResolveUrl({
url: 'b.yaml',
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/',
}),
).toBe(
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/b.yaml',
);
expect(
defaultScmResolveUrl({
url: 'b.yaml',
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/subfolder',
}),
).toBe(
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/b.yaml',
);
expect(
defaultScmResolveUrl({
url: 'b.yaml',