|
|
@@ -434,9 +434,9 @@ describe('Page', () => {
|
|
|
describe('Changing grant from RESTRICTED to PUBLIC of', () => {
|
|
|
test('a page will create ancestors if they do not exist', async() => {
|
|
|
const pathT = '/mup16_top';
|
|
|
- const path3 = '/mup16_top/mup9_pub/mup10_pub/mup11_awl';
|
|
|
const path1 = '/mup16_top/mup9_pub';
|
|
|
const path2 = '/mup16_top/mup9_pub/mup10_pub';
|
|
|
+ const path3 = '/mup16_top/mup9_pub/mup10_pub/mup11_awl';
|
|
|
const top = await Page.findOne({ path: pathT });
|
|
|
const page1 = await Page.findOne({ path: path1 });
|
|
|
const page2 = await Page.findOne({ path: path2 });
|
|
|
@@ -461,28 +461,32 @@ describe('Page', () => {
|
|
|
expect(_pageT.descendantCount).toBe(1);
|
|
|
});
|
|
|
test('a page will replace an empty page with the same path if any', async() => {
|
|
|
- const top = await Page.findOne({ path: '/mup17_top', descendantCount: 1 });
|
|
|
- const page1 = await Page.findOne({ path: '/mup17_top/mup12_emp', isEmpty: true });
|
|
|
- const page2 = await Page.findOne({ path: '/mup17_top/mup12_emp', grant: Page.GRANT_RESTRICTED, isEmpty: false });
|
|
|
- const page3 = await Page.findOne({ path: '/mup17_top/mup12_emp/mup18_pub' });
|
|
|
- expect(top).toBeTruthy();
|
|
|
+ const pathT = '/mup17_top';
|
|
|
+ const path1 = '/mup17_top/mup12_emp';
|
|
|
+ const path2 = '/mup17_top/mup12_emp/mup18_pub';
|
|
|
+ const pageT = await Page.findOne({ path: pathT, descendantCount: 1 });
|
|
|
+ const page1 = await Page.findOne({ path: path1, isEmpty: true });
|
|
|
+ const page2 = await Page.findOne({ path: path1, grant: Page.GRANT_RESTRICTED, isEmpty: false });
|
|
|
+ const page3 = await Page.findOne({ path: path2 });
|
|
|
+ expect(pageT).toBeTruthy();
|
|
|
expect(page1).toBeTruthy();
|
|
|
expect(page2).toBeTruthy();
|
|
|
expect(page3).toBeTruthy();
|
|
|
|
|
|
await Page.updatePage(page2, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_PUBLIC });
|
|
|
|
|
|
- const topAF = await Page.findOne({ _id: top._id });
|
|
|
- const page1AF = await Page.findOne({ _id: page1._id });
|
|
|
- const page2AF = await Page.findOne({ _id: page2._id });
|
|
|
- const page3AF = await Page.findOne({ _id: page3._id });
|
|
|
- expect(page1AF).toBeNull();
|
|
|
- expect(page2AF).toBeTruthy();
|
|
|
- expect(page3AF).toBeTruthy();
|
|
|
- expect(page2AF.grant).toBe(Page.GRANT_PUBLIC);
|
|
|
- expect(page2AF.parent).toStrictEqual(topAF._id);
|
|
|
- expect(page3AF.parent).toStrictEqual(page2AF._id);
|
|
|
- expect(topAF.descendantCount).toBe(2);
|
|
|
+ const _pageT = await Page.findOne({ path: pathT });
|
|
|
+ const _page1 = await Page.findOne({ path: path1, isEmpty: true }); // should be replaced
|
|
|
+ const _page2 = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC });
|
|
|
+ const _page3 = await Page.findOne({ path: path2 });
|
|
|
+ expect(_pageT).toBeTruthy();
|
|
|
+ expect(_page1).toBeNull();
|
|
|
+ expect(_page2).toBeTruthy();
|
|
|
+ expect(_page3).toBeTruthy();
|
|
|
+ expect(_page2.grant).toBe(Page.GRANT_PUBLIC);
|
|
|
+ expect(_page2.parent).toStrictEqual(_pageT._id);
|
|
|
+ expect(_page3.parent).toStrictEqual(_page2._id);
|
|
|
+ expect(_pageT.descendantCount).toBe(2);
|
|
|
});
|
|
|
});
|
|
|
|