integration: add some failing tests for defaultScmResolveUrl
Discovered some cases with SCM URL resolution that don't appear to work as intended. This commit adds some new failing unit tests to demonstrate the problem, as well as a few new cases that pass to round out the area of the suite. Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
@@ -116,6 +116,82 @@ describe('defaultScmResolveUrl', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('works for the root path', () => {
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
url: '/',
|
||||
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder',
|
||||
}),
|
||||
).toBe(
|
||||
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/',
|
||||
);
|
||||
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
url: '/',
|
||||
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/',
|
||||
}),
|
||||
).toBe(
|
||||
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/',
|
||||
);
|
||||
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
url: '/',
|
||||
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/a.yaml',
|
||||
}),
|
||||
).toBe(
|
||||
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/',
|
||||
);
|
||||
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
url: '/',
|
||||
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/a.yaml?at=master',
|
||||
}),
|
||||
).toBe(
|
||||
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/?at=master',
|
||||
);
|
||||
});
|
||||
|
||||
it('works for files in the repo root', () => {
|
||||
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/b.yaml',
|
||||
);
|
||||
|
||||
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/b.yaml',
|
||||
);
|
||||
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
url: '/b.yaml',
|
||||
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/a.yaml',
|
||||
}),
|
||||
).toBe(
|
||||
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/b.yaml',
|
||||
);
|
||||
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
url: '/b.yaml',
|
||||
base: 'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/folder/a.yaml?at=master',
|
||||
}),
|
||||
).toBe(
|
||||
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/b.yaml?at=master',
|
||||
);
|
||||
});
|
||||
|
||||
it('works for absolute paths and retains query params', () => {
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
@@ -126,6 +202,24 @@ describe('defaultScmResolveUrl', () => {
|
||||
'https://gitlab.com/groupA/teams/teamA/subgroupA/repoA/-/blob/branch/other/b.yaml',
|
||||
);
|
||||
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
url: '/other/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/other/b.yaml',
|
||||
);
|
||||
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
url: '/other/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/other/b.yaml',
|
||||
);
|
||||
|
||||
expect(
|
||||
defaultScmResolveUrl({
|
||||
url: '/other/b.yaml',
|
||||
|
||||
Reference in New Issue
Block a user