-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4761 from berkarslan-xo/bugfix/Issue-4760
Issue-4760 - Deleting the parent page while the child page is open doesn't redirect
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
Dnn.AdminExperience/ClientSide/Pages.Web/src/actions/__test__/pageActions.test.js
This file contains 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 @@ | ||
jest.mock('../../services/pageService'); | ||
jest.mock('../../utils'); | ||
import pageActions from '../pageActions'; | ||
import utils from "../../utils"; | ||
import PagesService from "../../services/pageService"; | ||
|
||
describe('Dnn Page Actions', () => { | ||
it('Redirects when parent page is deleted and the child page is the current page', done => { | ||
// Arrange | ||
const pageToDelete = { | ||
tabId: 1, | ||
hasChild: true | ||
}; | ||
const defaultUrl = 'http://localhost'; | ||
const redirectUrl = 'http://localhost/test'; | ||
PagesService.deletePage.mockResolvedValue({}); | ||
PagesService.getPageHierarchy.mockResolvedValue([1, 2]); | ||
utils.getCurrentPageId.mockReturnValue(2); | ||
utils.getDefaultPageUrl.mockReturnValue(redirectUrl); | ||
delete window.top.location; | ||
window.top.location = new URL(defaultUrl); | ||
Object.defineProperty(window.top.location, 'href', { | ||
set: (value) => { | ||
// Assert | ||
expect(value).toBe(redirectUrl) | ||
done(); | ||
} | ||
}); | ||
expect.assertions(1); | ||
|
||
// Act | ||
pageActions.deletePage(pageToDelete, null)(() => {}); | ||
}); | ||
}); |
This file contains 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