v5.page.test.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. import mongoose from 'mongoose';
  2. import { getInstance } from '../setup-crowi';
  3. describe('Page', () => {
  4. let crowi;
  5. let Page;
  6. let Revision;
  7. let User;
  8. let PageTagRelation;
  9. let Bookmark;
  10. let Comment;
  11. let ShareLink;
  12. let PageRedirect;
  13. let UserGroup;
  14. let UserGroupRelation;
  15. let xssSpy;
  16. let rootPage;
  17. let dummyUser1;
  18. let pModelUser1;
  19. let pModelUser2;
  20. let pModelUser3;
  21. let groupIdIsolate;
  22. let groupIdA;
  23. let groupIdB;
  24. let groupIdC;
  25. beforeAll(async() => {
  26. crowi = await getInstance();
  27. await crowi.configManager.updateConfigsInTheSameNamespace('crowi', { 'app:isV5Compatible': true });
  28. jest.restoreAllMocks();
  29. User = mongoose.model('User');
  30. Page = mongoose.model('Page');
  31. Revision = mongoose.model('Revision');
  32. PageTagRelation = mongoose.model('PageTagRelation');
  33. Bookmark = mongoose.model('Bookmark');
  34. Comment = mongoose.model('Comment');
  35. ShareLink = mongoose.model('ShareLink');
  36. PageRedirect = mongoose.model('PageRedirect');
  37. UserGroup = mongoose.model('UserGroup');
  38. UserGroupRelation = mongoose.model('UserGroupRelation');
  39. dummyUser1 = await User.findOne({ username: 'v5DummyUser1' });
  40. rootPage = await Page.findOne({ path: '/' });
  41. const pModelUserId1 = new mongoose.Types.ObjectId();
  42. const pModelUserId2 = new mongoose.Types.ObjectId();
  43. const pModelUserId3 = new mongoose.Types.ObjectId();
  44. await User.insertMany([
  45. {
  46. _id: pModelUserId1,
  47. name: 'pmodelUser1',
  48. username: 'pmodelUser1',
  49. email: 'pmodelUser1@example.com',
  50. },
  51. {
  52. _id: pModelUserId2,
  53. name: 'pmodelUser2',
  54. username: 'pmodelUser2',
  55. email: 'pmodelUser2@example.com',
  56. },
  57. {
  58. _id: pModelUserId3,
  59. name: 'pModelUser3',
  60. username: 'pModelUser3',
  61. email: 'pModelUser3@example.com',
  62. },
  63. ]);
  64. pModelUser1 = await User.findOne({ _id: pModelUserId1 });
  65. pModelUser2 = await User.findOne({ _id: pModelUserId2 });
  66. pModelUser3 = await User.findOne({ _id: pModelUserId3 });
  67. groupIdIsolate = new mongoose.Types.ObjectId();
  68. groupIdA = new mongoose.Types.ObjectId();
  69. groupIdB = new mongoose.Types.ObjectId();
  70. groupIdC = new mongoose.Types.ObjectId();
  71. await UserGroup.insertMany([
  72. {
  73. _id: groupIdIsolate,
  74. name: 'pModel_groupIsolate',
  75. },
  76. {
  77. _id: groupIdA,
  78. name: 'pModel_groupA',
  79. },
  80. {
  81. _id: groupIdB,
  82. name: 'pModel_groupB',
  83. parent: groupIdA,
  84. },
  85. {
  86. _id: groupIdC,
  87. name: 'pModel_groupC',
  88. parent: groupIdB,
  89. },
  90. ]);
  91. await UserGroupRelation.insertMany([
  92. {
  93. relatedGroup: groupIdIsolate,
  94. relatedUser: pModelUserId1,
  95. createdAt: new Date(),
  96. },
  97. {
  98. relatedGroup: groupIdIsolate,
  99. relatedUser: pModelUserId2,
  100. createdAt: new Date(),
  101. },
  102. {
  103. relatedGroup: groupIdA,
  104. relatedUser: pModelUserId1,
  105. createdAt: new Date(),
  106. },
  107. {
  108. relatedGroup: groupIdA,
  109. relatedUser: pModelUserId2,
  110. createdAt: new Date(),
  111. },
  112. {
  113. relatedGroup: groupIdA,
  114. relatedUser: pModelUserId3,
  115. createdAt: new Date(),
  116. },
  117. {
  118. relatedGroup: groupIdB,
  119. relatedUser: pModelUserId2,
  120. createdAt: new Date(),
  121. },
  122. {
  123. relatedGroup: groupIdB,
  124. relatedUser: pModelUserId3,
  125. createdAt: new Date(),
  126. },
  127. {
  128. relatedGroup: groupIdC,
  129. relatedUser: pModelUserId3,
  130. createdAt: new Date(),
  131. },
  132. ]);
  133. /**
  134. * update
  135. * mup_ => model update
  136. * emp => empty => page with isEmpty: true
  137. * pub => public => GRANT_PUBLIC
  138. * awl => Anyone with the link => GRANT_RESTRICTED
  139. */
  140. const pageIdUpd1 = new mongoose.Types.ObjectId();
  141. const pageIdUpd2 = new mongoose.Types.ObjectId();
  142. const pageIdUpd3 = new mongoose.Types.ObjectId();
  143. const pageIdUpd4 = new mongoose.Types.ObjectId();
  144. const pageIdUpd5 = new mongoose.Types.ObjectId();
  145. const pageIdUpd6 = new mongoose.Types.ObjectId();
  146. const pageIdUpd7 = new mongoose.Types.ObjectId();
  147. const pageIdUpd8 = new mongoose.Types.ObjectId();
  148. const pageIdUpd9 = new mongoose.Types.ObjectId();
  149. const pageIdUpd10 = new mongoose.Types.ObjectId();
  150. const pageIdUpd11 = new mongoose.Types.ObjectId();
  151. const pageIdUpd12 = new mongoose.Types.ObjectId();
  152. const pageIdUpd13 = new mongoose.Types.ObjectId();
  153. await Page.insertMany([
  154. {
  155. _id: pageIdUpd1,
  156. path: '/mup13_top/mup1_emp',
  157. grant: Page.GRANT_PUBLIC,
  158. parent: pageIdUpd8._id,
  159. isEmpty: true,
  160. },
  161. {
  162. _id: pageIdUpd2,
  163. path: '/mup13_top/mup1_emp/mup2_pub',
  164. grant: Page.GRANT_PUBLIC,
  165. parent: pageIdUpd1._id,
  166. creator: dummyUser1,
  167. lastUpdateUser: dummyUser1._id,
  168. isEmpty: false,
  169. },
  170. {
  171. _id: pageIdUpd3,
  172. path: '/mup14_top/mup6_pub',
  173. grant: Page.GRANT_PUBLIC,
  174. creator: dummyUser1,
  175. lastUpdateUser: dummyUser1._id,
  176. parent: pageIdUpd9,
  177. isEmpty: false,
  178. descendantCount: 1,
  179. },
  180. {
  181. path: '/mup14_top/mup6_pub/mup7_pub',
  182. grant: Page.GRANT_PUBLIC,
  183. creator: dummyUser1,
  184. lastUpdateUser: dummyUser1._id,
  185. parent: pageIdUpd3,
  186. isEmpty: false,
  187. descendantCount: 0,
  188. },
  189. {
  190. _id: pageIdUpd4,
  191. path: '/mup15_top/mup8_pub',
  192. grant: Page.GRANT_PUBLIC,
  193. creator: dummyUser1,
  194. lastUpdateUser: dummyUser1._id,
  195. parent: pageIdUpd10._id,
  196. isEmpty: false,
  197. },
  198. {
  199. _id: pageIdUpd5,
  200. path: '/mup16_top/mup9_pub/mup10_pub/mup11_awl',
  201. grant: Page.GRANT_RESTRICTED,
  202. creator: dummyUser1,
  203. lastUpdateUser: dummyUser1._id,
  204. isEmpty: false,
  205. },
  206. {
  207. _id: pageIdUpd6,
  208. path: '/mup17_top/mup12_emp',
  209. isEmpty: true,
  210. parent: pageIdUpd12._id,
  211. descendantCount: 1,
  212. },
  213. {
  214. _id: pageIdUpd7,
  215. path: '/mup17_top/mup12_emp',
  216. grant: Page.GRANT_RESTRICTED,
  217. creator: dummyUser1,
  218. lastUpdateUser: dummyUser1._id,
  219. isEmpty: false,
  220. },
  221. {
  222. path: '/mup17_top/mup12_emp/mup18_pub',
  223. isEmpty: false,
  224. creator: dummyUser1,
  225. lastUpdateUser: dummyUser1._id,
  226. parent: pageIdUpd6._id,
  227. },
  228. {
  229. _id: pageIdUpd8,
  230. path: '/mup13_top',
  231. grant: Page.GRANT_PUBLIC,
  232. creator: dummyUser1,
  233. lastUpdateUser: dummyUser1._id,
  234. isEmpty: false,
  235. parent: rootPage._id,
  236. descendantCount: 2,
  237. },
  238. {
  239. _id: pageIdUpd9,
  240. path: '/mup14_top',
  241. grant: Page.GRANT_PUBLIC,
  242. creator: dummyUser1,
  243. lastUpdateUser: dummyUser1._id,
  244. isEmpty: false,
  245. parent: rootPage._id,
  246. descendantCount: 2,
  247. },
  248. {
  249. _id: pageIdUpd10,
  250. path: '/mup15_top',
  251. grant: Page.GRANT_PUBLIC,
  252. creator: dummyUser1,
  253. lastUpdateUser: dummyUser1._id,
  254. isEmpty: false,
  255. parent: rootPage._id,
  256. descendantCount: 1,
  257. },
  258. {
  259. _id: pageIdUpd11,
  260. path: '/mup16_top',
  261. grant: Page.GRANT_PUBLIC,
  262. creator: dummyUser1,
  263. lastUpdateUser: dummyUser1._id,
  264. isEmpty: false,
  265. parent: rootPage._id,
  266. descendantCount: 0,
  267. },
  268. {
  269. _id: pageIdUpd12,
  270. path: '/mup17_top',
  271. grant: Page.GRANT_PUBLIC,
  272. creator: dummyUser1,
  273. lastUpdateUser: dummyUser1._id,
  274. isEmpty: false,
  275. parent: rootPage._id,
  276. descendantCount: 1,
  277. },
  278. {
  279. path: '/mup19',
  280. grant: Page.GRANT_PUBLIC,
  281. creator: dummyUser1,
  282. lastUpdateUser: dummyUser1._id,
  283. isEmpty: false,
  284. parent: rootPage._id,
  285. descendantCount: 0,
  286. },
  287. {
  288. path: '/mup20',
  289. grant: Page.GRANT_USER_GROUP,
  290. grantedGroup: groupIdA,
  291. creator: pModelUserId1,
  292. lastUpdateUser: pModelUserId1,
  293. isEmpty: false,
  294. parent: rootPage._id,
  295. descendantCount: 0,
  296. },
  297. {
  298. path: '/mup21',
  299. grant: Page.GRANT_RESTRICTED,
  300. creator: dummyUser1,
  301. lastUpdateUser: dummyUser1._id,
  302. isEmpty: false,
  303. descendantCount: 0,
  304. },
  305. {
  306. _id: pageIdUpd13,
  307. path: '/mup22',
  308. grant: Page.GRANT_PUBLIC,
  309. creator: pModelUser1,
  310. lastUpdateUser: pModelUser1._id,
  311. isEmpty: false,
  312. parent: rootPage._id,
  313. descendantCount: 1,
  314. },
  315. {
  316. path: '/mup22/mup23',
  317. grant: Page.GRANT_USER_GROUP,
  318. grantedGroup: groupIdA,
  319. creator: pModelUserId1,
  320. lastUpdateUser: pModelUserId1,
  321. isEmpty: false,
  322. parent: pageIdUpd13,
  323. descendantCount: 0,
  324. },
  325. {
  326. path: '/mup24',
  327. grant: Page.GRANT_OWNER,
  328. grantedUsers: [dummyUser1._id],
  329. creator: dummyUser1,
  330. lastUpdateUser: dummyUser1._id,
  331. isEmpty: false,
  332. parent: rootPage._id,
  333. descendantCount: 0,
  334. },
  335. ]);
  336. });
  337. describe('update', () => {
  338. const updatePage = async(page, newRevisionBody, oldRevisionBody, user, options = {}) => {
  339. const mockedRenameSubOperation = jest.spyOn(Page, 'emitPageEventUpdate').mockReturnValue(null);
  340. const savedPage = await Page.updatePage(page, newRevisionBody, oldRevisionBody, user, options);
  341. mockedRenameSubOperation.mockRestore();
  342. return savedPage;
  343. };
  344. describe('Changing grant from PUBLIC to RESTRICTED of', () => {
  345. test('an only-child page will delete its empty parent page', async() => {
  346. const pathT = '/mup13_top';
  347. const path1 = '/mup13_top/mup1_emp';
  348. const path2 = '/mup13_top/mup1_emp/mup2_pub';
  349. const pageT = await Page.findOne({ path: pathT, descendantCount: 2 });
  350. const page1 = await Page.findOne({ path: path1, isEmpty: true });
  351. const page2 = await Page.findOne({ path: path2, grant: Page.GRANT_PUBLIC });
  352. expect(pageT).toBeTruthy();
  353. expect(page1).toBeTruthy();
  354. expect(page2).toBeTruthy();
  355. const options = { grant: Page.GRANT_RESTRICTED, grantUserGroupId: null };
  356. await Page.updatePage(page2, 'newRevisionBody', 'oldRevisionBody', dummyUser1, options);
  357. const _pageT = await Page.findOne({ path: pathT });
  358. const _page1 = await Page.findOne({ path: path1 });
  359. const _page2 = await Page.findOne({ path: path2, grant: Page.GRANT_RESTRICTED });
  360. expect(_pageT).toBeTruthy();
  361. expect(_page1).toBeNull();
  362. expect(_page2).toBeTruthy();
  363. expect(_pageT.descendantCount).toBe(1);
  364. });
  365. test('a page that has children will create an empty page with the same path and it becomes a new parent', async() => {
  366. const pathT = '/mup14_top';
  367. const path1 = '/mup14_top/mup6_pub';
  368. const path2 = '/mup14_top/mup6_pub/mup7_pub';
  369. const top = await Page.findOne({ path: pathT, descendantCount: 2 });
  370. const page1 = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC });
  371. const page2 = await Page.findOne({ path: path2, grant: Page.GRANT_PUBLIC });
  372. expect(top).toBeTruthy();
  373. expect(page1).toBeTruthy();
  374. expect(page2).toBeTruthy();
  375. await Page.updatePage(page1, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_RESTRICTED });
  376. const _top = await Page.findOne({ path: pathT });
  377. const _page1 = await Page.findOne({ path: path1, grant: Page.GRANT_RESTRICTED });
  378. const _page2 = await Page.findOne({ path: path2 });
  379. const _pageN = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC });
  380. expect(_page1).toBeTruthy();
  381. expect(_page2).toBeTruthy();
  382. expect(_pageN).toBeTruthy();
  383. expect(_page1.parent).toBeNull();
  384. expect(_page2.parent).toStrictEqual(_pageN._id);
  385. expect(_pageN.parent).toStrictEqual(top._id);
  386. expect(_pageN.isEmpty).toBe(true);
  387. expect(_pageN.descendantCount).toBe(1);
  388. expect(_top.descendantCount).toBe(1);
  389. });
  390. test('of a leaf page will NOT have an empty page with the same path', async() => {
  391. const pathT = '/mup15_top';
  392. const path1 = '/mup15_top/mup8_pub';
  393. const pageT = await Page.findOne({ path: pathT, descendantCount: 1 });
  394. const page1 = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC });
  395. const count = await Page.count({ path: path1 });
  396. expect(pageT).toBeTruthy();
  397. expect(page1).toBeTruthy();
  398. expect(count).toBe(1);
  399. await Page.updatePage(page1, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_RESTRICTED });
  400. const _pageT = await Page.findOne({ path: pathT });
  401. const _page1 = await Page.findOne({ path: path1, grant: Page.GRANT_RESTRICTED });
  402. const _pageNotExist = await Page.findOne({ path: path1, isEmpty: true });
  403. expect(_pageT).toBeTruthy();
  404. expect(_page1).toBeTruthy();
  405. expect(_pageNotExist).toBeNull();
  406. expect(_pageT.descendantCount).toBe(0);
  407. });
  408. });
  409. describe('Changing grant to GRANT_RESTRICTED', () => {
  410. test('successfully change to GRANT_RESTRICTED from GRANT_OWNER', async() => {
  411. const path = '/mup24';
  412. const _page = await Page.findOne({ path, grant: Page.GRANT_OWNER, grantedUsers: [dummyUser1._id] });
  413. expect(_page).toBeTruthy();
  414. await updatePage(_page, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_RESTRICTED });
  415. const page = await Page.findOne({ path });
  416. expect(page).toBeTruthy();
  417. expect(page.grant).toBe(Page.GRANT_RESTRICTED);
  418. expect(page.grantedUsers).toStrictEqual([]);
  419. });
  420. });
  421. describe('Changing grant from RESTRICTED to PUBLIC of', () => {
  422. test('a page will create ancestors if they do not exist', async() => {
  423. const pathT = '/mup16_top';
  424. const path1 = '/mup16_top/mup9_pub';
  425. const path2 = '/mup16_top/mup9_pub/mup10_pub';
  426. const path3 = '/mup16_top/mup9_pub/mup10_pub/mup11_awl';
  427. const top = await Page.findOne({ path: pathT });
  428. const page1 = await Page.findOne({ path: path1 });
  429. const page2 = await Page.findOne({ path: path2 });
  430. const page3 = await Page.findOne({ path: path3, grant: Page.GRANT_RESTRICTED });
  431. expect(top).toBeTruthy();
  432. expect(page3).toBeTruthy();
  433. expect(page1).toBeNull();
  434. expect(page2).toBeNull();
  435. await Page.updatePage(page3, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_PUBLIC });
  436. const _pageT = await Page.findOne({ path: pathT });
  437. const _page1 = await Page.findOne({ path: path1, isEmpty: true });
  438. const _page2 = await Page.findOne({ path: path2, isEmpty: true });
  439. const _page3 = await Page.findOne({ path: path3, grant: Page.GRANT_PUBLIC });
  440. expect(_page1).toBeTruthy();
  441. expect(_page2).toBeTruthy();
  442. expect(_page3).toBeTruthy();
  443. expect(_page1.parent).toStrictEqual(top._id);
  444. expect(_page2.parent).toStrictEqual(_page1._id);
  445. expect(_page3.parent).toStrictEqual(_page2._id);
  446. expect(_pageT.descendantCount).toBe(1);
  447. });
  448. test('a page will replace an empty page with the same path if any', async() => {
  449. const pathT = '/mup17_top';
  450. const path1 = '/mup17_top/mup12_emp';
  451. const path2 = '/mup17_top/mup12_emp/mup18_pub';
  452. const pageT = await Page.findOne({ path: pathT, descendantCount: 1 });
  453. const page1 = await Page.findOne({ path: path1, isEmpty: true });
  454. const page2 = await Page.findOne({ path: path1, grant: Page.GRANT_RESTRICTED, isEmpty: false });
  455. const page3 = await Page.findOne({ path: path2 });
  456. expect(pageT).toBeTruthy();
  457. expect(page1).toBeTruthy();
  458. expect(page2).toBeTruthy();
  459. expect(page3).toBeTruthy();
  460. await Page.updatePage(page2, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_PUBLIC });
  461. const _pageT = await Page.findOne({ path: pathT });
  462. const _page1 = await Page.findOne({ path: path1, isEmpty: true }); // should be replaced
  463. const _page2 = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC });
  464. const _page3 = await Page.findOne({ path: path2 });
  465. expect(_pageT).toBeTruthy();
  466. expect(_page1).toBeNull();
  467. expect(_page2).toBeTruthy();
  468. expect(_page3).toBeTruthy();
  469. expect(_page2.grant).toBe(Page.GRANT_PUBLIC);
  470. expect(_page2.parent).toStrictEqual(_pageT._id);
  471. expect(_page3.parent).toStrictEqual(_page2._id);
  472. expect(_pageT.descendantCount).toBe(2);
  473. });
  474. });
  475. describe('Changing grant to GRANT_OWNER(onlyme)', () => {
  476. test('successfully change to GRANT_OWNER from GRANT_PUBLIC', async() => {
  477. const path = '/mup19';
  478. const _page = await Page.findOne({ path, grant: Page.GRANT_PUBLIC });
  479. expect(_page).toBeTruthy();
  480. await updatePage(_page, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_OWNER });
  481. const page = await Page.findOne({ path });
  482. expect(page.grant).toBe(Page.GRANT_OWNER);
  483. expect(page.grantedUsers).toStrictEqual([dummyUser1._id]);
  484. });
  485. test('successfully change to GRANT_OWNER from GRANT_USER_GROUP', async() => {
  486. const path = '/mup20';
  487. const _page = await Page.findOne({ path, grant: Page.GRANT_USER_GROUP, grantedGroup: groupIdA });
  488. expect(_page).toBeTruthy();
  489. await updatePage(_page, 'newRevisionBody', 'oldRevisionBody', pModelUser1, { grant: Page.GRANT_OWNER });
  490. const page = await Page.findOne({ path });
  491. expect(page.grant).toBe(Page.GRANT_OWNER);
  492. expect(page.grantedUsers).toStrictEqual([pModelUser1._id]);
  493. expect(page.grantedGroup).toBeNull();
  494. });
  495. test('successfully change to GRANT_OWNER from GRANT_RESTRICTED', async() => {
  496. const path = '/mup21';
  497. const _page = await Page.findOne({ path, grant: Page.GRANT_RESTRICTED });
  498. expect(_page).toBeTruthy();
  499. await updatePage(_page, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_OWNER });
  500. const page = await Page.findOne({ path });
  501. expect(page.grant).toBe(Page.GRANT_OWNER);
  502. expect(page.grantedUsers).toStrictEqual([dummyUser1._id]);
  503. });
  504. test('Failed to change to GRANT_OWNER if one of the ancestors is GRANT_USER_GROUP page', async() => {
  505. const path1 = '/mup22';
  506. const path2 = '/mup22/mup23';
  507. const _page1 = await Page.findOne({ path: path1, grant: Page.GRANT_PUBLIC });
  508. const _page2 = await Page.findOne({ path: path2, grant: Page.GRANT_USER_GROUP, grantedGroup: groupIdA });
  509. expect(_page1).toBeTruthy();
  510. expect(_page2).toBeTruthy();
  511. await expect(updatePage(_page1, 'newRevisionBody', 'oldRevisionBody', dummyUser1, { grant: Page.GRANT_OWNER }))
  512. .rejects.toThrow(new Error('The selected grant or grantedGroup is not assignable to this page.'));
  513. const page1 = await Page.findOne({ path1 });
  514. expect(page1).toBeTruthy();
  515. expect(page1.grant).toBe(Page.GRANT_PUBLIC);
  516. expect(page1.grantedUsers).not.toStrictEqual([dummyUser1._id]);
  517. });
  518. });
  519. });
  520. });