|
|
@@ -6,6 +6,7 @@ let testUser0;
|
|
|
let testUser1;
|
|
|
let testUser2;
|
|
|
let testGroup0;
|
|
|
+let parentPage;
|
|
|
|
|
|
describe('Page', () => {
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
@@ -61,6 +62,12 @@ describe('Page', () => {
|
|
|
grantedUsers: [testUser0],
|
|
|
creator: testUser0,
|
|
|
},
|
|
|
+ {
|
|
|
+ path: '/grant',
|
|
|
+ grant: Page.GRANT_PUBLIC,
|
|
|
+ grantedUsers: [testUser0],
|
|
|
+ creator: testUser0,
|
|
|
+ },
|
|
|
{
|
|
|
path: '/grant/public',
|
|
|
grant: Page.GRANT_PUBLIC,
|
|
|
@@ -115,6 +122,8 @@ describe('Page', () => {
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
+ parentPage = await Page.findOne({ path: '/grant' });
|
|
|
+
|
|
|
done();
|
|
|
});
|
|
|
|
|
|
@@ -374,4 +383,54 @@ describe('Page', () => {
|
|
|
expect(pagePaths).toContainEqual('/page2');
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('.findListWithDescendants', () => {
|
|
|
+ test('can retrieve all pages with testUser0', async() => {
|
|
|
+ const result = await Page.findListWithDescendants('/grant', testUser0);
|
|
|
+ const { pages } = result;
|
|
|
+
|
|
|
+ // assert totalCount
|
|
|
+ expect(pages.length).toEqual(5);
|
|
|
+
|
|
|
+ // assert paths
|
|
|
+ const pagePaths = await pages.map((page) => { return page.path });
|
|
|
+ expect(pagePaths).toContainEqual('/grant/groupacl');
|
|
|
+ expect(pagePaths).toContainEqual('/grant/specified');
|
|
|
+ expect(pagePaths).toContainEqual('/grant/owner');
|
|
|
+ expect(pagePaths).toContainEqual('/grant/public');
|
|
|
+ expect(pagePaths).toContainEqual('/grant');
|
|
|
+ });
|
|
|
+
|
|
|
+ test('can retrieve all pages with testUser1', async() => {
|
|
|
+ const result = await Page.findListWithDescendants('/grant', testUser1);
|
|
|
+ const { pages } = result;
|
|
|
+
|
|
|
+ // assert totalCount
|
|
|
+ expect(pages.length).toEqual(5);
|
|
|
+
|
|
|
+ // assert paths
|
|
|
+ const pagePaths = await pages.map((page) => { return page.path });
|
|
|
+ expect(pagePaths).toContainEqual('/grant/groupacl');
|
|
|
+ expect(pagePaths).toContainEqual('/grant/specified');
|
|
|
+ expect(pagePaths).toContainEqual('/grant/owner');
|
|
|
+ expect(pagePaths).toContainEqual('/grant/public');
|
|
|
+ expect(pagePaths).toContainEqual('/grant');
|
|
|
+ });
|
|
|
+
|
|
|
+ test('can retrieve all pages with testUser0', async() => {
|
|
|
+ const result = await Page.findListWithDescendants('/grant', testUser1);
|
|
|
+ const { pages } = result;
|
|
|
+
|
|
|
+ // assert totalCount
|
|
|
+ expect(pages.length).toEqual(5);
|
|
|
+
|
|
|
+ // assert paths
|
|
|
+ const pagePaths = await pages.map((page) => { return page.path });
|
|
|
+ expect(pagePaths).toContainEqual('/grant/groupacl');
|
|
|
+ expect(pagePaths).toContainEqual('/grant/specified');
|
|
|
+ expect(pagePaths).toContainEqual('/grant/owner');
|
|
|
+ expect(pagePaths).toContainEqual('/grant/public');
|
|
|
+ expect(pagePaths).toContainEqual('/grant');
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|