projects
/
arvados-workbench2.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'origin/main' into 18692-frozen-projects-workbench-support
[arvados-workbench2.git]
/
src
/
common
/
redirect-to.test.ts
diff --git
a/src/common/redirect-to.test.ts
b/src/common/redirect-to.test.ts
index d1426c2916b75bc62c2eb3c4c3f11683fe3effe1..0168fd803f327f484be2f848e805d4df503352b3 100644
(file)
--- a/
src/common/redirect-to.test.ts
+++ b/
src/common/redirect-to.test.ts
@@
-6,7
+6,11
@@
import { storeRedirects, handleRedirects } from './redirect-to';
describe('redirect-to', () => {
const { location } = window;
describe('redirect-to', () => {
const { location } = window;
- const redirectTo = 'http://localhost/test123';
+ const config: any = {
+ keepWebServiceUrl: 'http://localhost',
+ keepWebServiceInlineUrl: 'http://localhost-inline'
+ };
+ const redirectTo = '/test123';
const locationTemplate = {
hash: '',
hostname: '',
const locationTemplate = {
hash: '',
hostname: '',
@@
-16,10
+20,10
@@
describe('redirect-to', () => {
port: '80',
protocol: 'http',
search: '',
port: '80',
protocol: 'http',
search: '',
- reload: () => {},
- replace: () => {},
- assign: () => {},
- ancestorOrigins:
new DOMStringList()
,
+ reload: () => {
},
+ replace: () => {
},
+ assign: () => {
},
+ ancestorOrigins:
[]
,
href: '',
};
href: '',
};
@@
-32,9
+36,9
@@
describe('redirect-to', () => {
delete window.location;
window.location = {
...locationTemplate,
delete window.location;
window.location = {
...locationTemplate,
- href: `${location.href}?redirectTo=${redirectTo}`,
- };
- Object.defineProperty(window, '
session
Storage', {
+ href: `${location.href}?redirectTo
Download
=${redirectTo}`,
+ }
as any
;
+ Object.defineProperty(window, '
local
Storage', {
value: {
setItem: jest.fn(),
},
value: {
setItem: jest.fn(),
},
@@
-47,7
+51,7
@@
describe('redirect-to', () => {
storeRedirects();
// then
storeRedirects();
// then
- expect(window.
sessionStorage.setItem).toHaveBeenCalledWith('redirectTo
', redirectTo);
+ expect(window.
localStorage.setItem).toHaveBeenCalledWith('redirectToDownload
', redirectTo);
});
});
});
});
@@
-56,9
+60,9
@@
describe('redirect-to', () => {
delete window.location;
window.location = {
...locationTemplate,
delete window.location;
window.location = {
...locationTemplate,
- href: `${location.href}?redirectTo=${redirectTo}`,
- };
- Object.defineProperty(window, '
session
Storage', {
+ href: `${location.href}?redirectTo
Download
=${redirectTo}`,
+ }
as any;
;
+ Object.defineProperty(window, '
local
Storage', {
value: {
getItem: () => redirectTo,
removeItem: jest.fn(),
value: {
getItem: () => redirectTo,
removeItem: jest.fn(),
@@
-68,14
+72,11
@@
describe('redirect-to', () => {
});
it('should redirect to page when it is present in session storage', () => {
});
it('should redirect to page when it is present in session storage', () => {
- // given
- const token = 'testToken';
-
// when
// when
- handleRedirects(
token
);
+ handleRedirects(
"abcxyz", config
);
// then
// then
- expect(window.location.href).toBe(`${
redirectTo}?api_token=${token}
`);
+ expect(window.location.href).toBe(`${
config.keepWebServiceUrl}${redirectTo}?api_token=abcxyz
`);
});
});
});
});
-});
\ No newline at end of file
+});