-
Notifications
You must be signed in to change notification settings - Fork 13
feat: enable basename for multi cluster version #2153
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a7ee12d
feat: enable basename for multi cluster version
artemmufazalov 19750fd
review: fix copilot comments
artemmufazalov 0cd9ff9
add getUrlData tests
artemmufazalov b8e023e
review: fix copilot comment
artemmufazalov 02a66ea
review: add comment and tests
artemmufazalov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import {getUrlData} from '../getUrlData'; | ||
|
||
describe('getUrlData', () => { | ||
const windowSpy = jest.spyOn(window, 'window', 'get'); | ||
|
||
afterEach(() => { | ||
windowSpy.mockClear(); | ||
}); | ||
afterAll(() => { | ||
windowSpy.mockRestore(); | ||
}); | ||
|
||
describe('multi-cluster version', () => { | ||
test('should parse pathname with folder', () => { | ||
windowSpy.mockImplementation(() => { | ||
return { | ||
location: { | ||
href: 'http://ydb-ui/ui/cluster?clusterName=my_cluster&backend=http://my-node:8765', | ||
pathname: '/ui/cluster?clusterName=my_cluster&backend=http://my-node:8765', | ||
}, | ||
} as Window & typeof globalThis; | ||
}); | ||
const result = getUrlData({singleClusterMode: false, customBackend: undefined}); | ||
expect(result).toEqual({ | ||
basename: '/ui', | ||
backend: 'http://my-node:8765', | ||
clusterName: 'my_cluster', | ||
}); | ||
}); | ||
test('should parse pathname with folder and some prefix', () => { | ||
windowSpy.mockImplementation(() => { | ||
return { | ||
location: { | ||
href: 'http://ydb-ui/monitoring/ui/cluster?clusterName=my_cluster&backend=http://my-node:8765', | ||
pathname: | ||
'/monitoring/ui/cluster?clusterName=my_cluster&backend=http://my-node:8765', | ||
}, | ||
} as Window & typeof globalThis; | ||
}); | ||
const result = getUrlData({singleClusterMode: false, customBackend: undefined}); | ||
expect(result).toEqual({ | ||
basename: '/monitoring/ui', | ||
backend: 'http://my-node:8765', | ||
clusterName: 'my_cluster', | ||
}); | ||
}); | ||
test('should parse pathname with folder and some prefix', () => { | ||
windowSpy.mockImplementation(() => { | ||
return { | ||
location: { | ||
href: 'http://ydb-ui/cluster?clusterName=my_cluster&backend=http://my-node:8765', | ||
pathname: '/cluster?clusterName=my_cluster&backend=http://my-node:8765', | ||
}, | ||
} as Window & typeof globalThis; | ||
}); | ||
const result = getUrlData({singleClusterMode: false, customBackend: undefined}); | ||
expect(result).toEqual({ | ||
basename: '', | ||
backend: 'http://my-node:8765', | ||
clusterName: 'my_cluster', | ||
}); | ||
}); | ||
}); | ||
describe('single-cluster version with custom backend', () => { | ||
test('should parse correclty parse pathname', () => { | ||
windowSpy.mockImplementation(() => { | ||
return { | ||
location: { | ||
href: 'http://localhost:3000/cluster', | ||
pathname: '/cluster', | ||
}, | ||
} as Window & typeof globalThis; | ||
}); | ||
const result = getUrlData({ | ||
singleClusterMode: true, | ||
customBackend: 'http://my-node:8765', | ||
}); | ||
expect(result).toEqual({ | ||
basename: '', | ||
backend: 'http://my-node:8765', | ||
}); | ||
}); | ||
}); | ||
describe('single-cluster embedded version', () => { | ||
test('should parse pathname with folder', () => { | ||
windowSpy.mockImplementation(() => { | ||
return { | ||
location: { | ||
href: 'http://my-node:8765/monitoring/cluster', | ||
pathname: '/monitoring/cluster', | ||
}, | ||
} as Window & typeof globalThis; | ||
}); | ||
const result = getUrlData({singleClusterMode: true, customBackend: undefined}); | ||
expect(result).toEqual({ | ||
basename: '/monitoring', | ||
backend: '', | ||
}); | ||
}); | ||
test('should parse pathname with folder and some prefix', () => { | ||
windowSpy.mockImplementation(() => { | ||
return { | ||
location: { | ||
href: 'http://my-node:8765/node/12/monitoring/cluster', | ||
pathname: '/node/12/monitoring/cluster', | ||
}, | ||
} as Window & typeof globalThis; | ||
}); | ||
const result = getUrlData({singleClusterMode: true, customBackend: undefined}); | ||
expect(result).toEqual({ | ||
basename: '/node/12/monitoring', | ||
backend: '/node/12', | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {normalizePathSlashes} from '../'; | ||
|
||
describe('normalizePathSlashes', () => { | ||
test('should handle empty strings', () => { | ||
expect(normalizePathSlashes('')).toBe(''); | ||
}); | ||
test('should handle strings without slashes', () => { | ||
expect(normalizePathSlashes('path')).toBe('path'); | ||
}); | ||
test('should handle paths with single slash', () => { | ||
expect(normalizePathSlashes('/path')).toBe('/path'); | ||
}); | ||
test('should handle paths with trailing slash', () => { | ||
expect(normalizePathSlashes('path/')).toBe('path/'); | ||
}); | ||
test('should handle paths with multiple trailing slashes', () => { | ||
expect(normalizePathSlashes('path////')).toBe('path/'); | ||
}); | ||
test('should handle full paths with normal slashes', () => { | ||
expect(normalizePathSlashes('http://example.com/path/to/resource')).toBe( | ||
'http://example.com/path/to/resource', | ||
); | ||
}); | ||
test('should replace multiple slashes with a single slash', () => { | ||
expect(normalizePathSlashes('http://example.com//path//to////resource')).toBe( | ||
'http://example.com/path/to/resource', | ||
); | ||
}); | ||
test('should replace slashes more than two slashes after a colon', () => { | ||
expect(normalizePathSlashes('http://///example.com/path/to/resource')).toBe( | ||
'http://example.com/path/to/resource', | ||
); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build embedded multi-cluster version - app host is used as meta backend