mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
fix(permalink): exclude edit mode from dashboard permalink (#35889)
This commit is contained in:
committed by
GitHub
parent
21d585d586
commit
e2e831e322
@@ -17,7 +17,12 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { isUrlExternal, parseUrl, toQueryString } from './urlUtils';
|
||||
import {
|
||||
isUrlExternal,
|
||||
parseUrl,
|
||||
toQueryString,
|
||||
getDashboardUrlParams,
|
||||
} from './urlUtils';
|
||||
|
||||
test('isUrlExternal', () => {
|
||||
expect(isUrlExternal('http://google.com')).toBeTruthy();
|
||||
@@ -95,3 +100,48 @@ test('toQueryString should handle special characters in keys and values', () =>
|
||||
'?user%40domain=me%26you',
|
||||
);
|
||||
});
|
||||
|
||||
test('getDashboardUrlParams should exclude edit parameter by default', () => {
|
||||
// Mock window.location.search to include edit parameter
|
||||
const originalLocation = window.location;
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: {
|
||||
...originalLocation,
|
||||
search: '?edit=true&standalone=false&expand_filters=1',
|
||||
},
|
||||
writable: true,
|
||||
});
|
||||
|
||||
const urlParams = getDashboardUrlParams(['edit']);
|
||||
const paramNames = urlParams.map(([key]) => key);
|
||||
|
||||
expect(paramNames).not.toContain('edit');
|
||||
expect(paramNames).toContain('standalone');
|
||||
expect(paramNames).toContain('expand_filters');
|
||||
|
||||
// Restore original location
|
||||
window.location = originalLocation;
|
||||
});
|
||||
|
||||
test('getDashboardUrlParams should exclude multiple parameters when provided', () => {
|
||||
// Mock window.location.search with multiple parameters
|
||||
const originalLocation = window.location;
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: {
|
||||
...originalLocation,
|
||||
search: '?edit=true&standalone=false&debug=true&test=value',
|
||||
},
|
||||
writable: true,
|
||||
});
|
||||
|
||||
const urlParams = getDashboardUrlParams(['edit', 'debug']);
|
||||
const paramNames = urlParams.map(([key]) => key);
|
||||
|
||||
expect(paramNames).not.toContain('edit');
|
||||
expect(paramNames).not.toContain('debug');
|
||||
expect(paramNames).toContain('standalone');
|
||||
expect(paramNames).toContain('test');
|
||||
|
||||
// Restore original location
|
||||
window.location = originalLocation;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user