20-basic-features--access-to-page.spec.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. context('Access to page', () => {
  2. const ssPrefix = 'access-to-page-';
  3. beforeEach(() => {
  4. // login
  5. cy.fixture("user-admin.json").then(user => {
  6. cy.login(user.username, user.password);
  7. });
  8. });
  9. it('/Sandbox is successfully loaded', () => {
  10. cy.visit('/Sandbox');
  11. cy.waitUntilSkeletonDisappear();
  12. // for check download toc data
  13. // https://redmine.weseek.co.jp/issues/111384
  14. // cy.get('.toc-link').should('be.visible');
  15. cy.collapseSidebar(true, true);
  16. cy.screenshot(`${ssPrefix}-sandbox`);
  17. });
  18. // TODO: https://redmine.weseek.co.jp/issues/109939
  19. it('/Sandbox with anchor hash is successfully loaded', () => {
  20. cy.visit('/Sandbox#headers');
  21. cy.waitUntilSkeletonDisappear();
  22. // for check download toc data
  23. // https://redmine.weseek.co.jp/issues/111384
  24. // cy.get('.toc-link').should('be.visible');
  25. // hide fab
  26. cy.getByTestid('grw-fab-container').invoke('attr', 'style', 'display: none');
  27. // remove animation for screenshot
  28. // remove 'blink' class because ::after element cannot be operated
  29. // https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin/21709814#21709814
  30. cy.get('#headers').invoke('removeClass', 'blink');
  31. cy.collapseSidebar(true);
  32. cy.screenshot(`${ssPrefix}-sandbox-headers`);
  33. });
  34. it('/Sandbox/Math is successfully loaded', () => {
  35. cy.visit('/Sandbox/Math');
  36. cy.waitUntilSkeletonDisappear();
  37. // for check download toc data
  38. // https://redmine.weseek.co.jp/issues/111384
  39. // cy.get('.toc-link').should('be.visible');
  40. cy.get('.math').should('be.visible');
  41. cy.collapseSidebar(true);
  42. cy.screenshot(`${ssPrefix}-sandbox-math`);
  43. });
  44. it('/Sandbox with edit is successfully loaded', () => {
  45. cy.visit('/Sandbox#edit');
  46. cy.waitUntilSkeletonDisappear();
  47. cy.getByTestid('navbar-editor').should('be.visible');
  48. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  49. cy.getByTestid('save-page-btn').should('be.visible');
  50. cy.get('.grw-grant-selector').should('be.visible');
  51. cy.collapseSidebar(true);
  52. cy.screenshot(`${ssPrefix}-Sandbox-edit-page`);
  53. })
  54. it('View and Edit contents are successfully loaded', () => {
  55. const body1 = 'hello';
  56. cy.visit('/Sandbox/testForUseEditingMarkdown');
  57. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  58. cy.waitUntil(() => {
  59. // do
  60. cy.get('@pageEditorModeManager').within(() => {
  61. cy.get('button:nth-child(2)').click();
  62. });
  63. // until
  64. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  65. })
  66. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  67. // check edited contents after save
  68. cy.get('.CodeMirror').type(body1);
  69. cy.get('.CodeMirror').contains(body1);
  70. cy.get('.page-editor-preview-body').contains(body1);
  71. cy.getByTestid('page-editor').should('be.visible');
  72. cy.getByTestid('save-page-btn').click();
  73. cy.get('.wiki').should('be.visible');
  74. cy.get('.wiki').children().first().should('have.text', body1);
  75. })
  76. it('Editing contents are successfully loaded with shortcut key', () => {
  77. const body2 = ' world!';
  78. const savePageShortcutKey = '{ctrl+s}';
  79. cy.visit('/Sandbox/testForUseEditingMarkdown');
  80. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  81. cy.waitUntil(() => {
  82. // do
  83. cy.get('@pageEditorModeManager').within(() => {
  84. cy.get('button:nth-child(2)').click();
  85. });
  86. // until
  87. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  88. })
  89. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  90. // check editing contents with shortcut key
  91. cy.get('.CodeMirror-line').children().first().invoke('text').then((text) => {
  92. cy.get('.CodeMirror').type(body2);
  93. cy.get('.CodeMirror').contains(text+body2);
  94. cy.get('.page-editor-preview-body').contains(text+body2);
  95. cy.get('.CodeMirror').type(savePageShortcutKey);
  96. cy.get('.CodeMirror').contains(text+body2);
  97. cy.get('.page-editor-preview-body').contains(text+body2);
  98. })
  99. })
  100. it('/user/admin is successfully loaded', () => {
  101. cy.visit('/user/admin');
  102. cy.waitUntilSkeletonDisappear();
  103. // for check download toc data
  104. // https://redmine.weseek.co.jp/issues/111384
  105. // cy.get('.toc-link').should('be.visible');
  106. // eslint-disable-next-line cypress/no-unnecessary-waiting
  107. cy.wait(2000); // wait for calcViewHeight and rendering
  108. cy.collapseSidebar(true);
  109. cy.screenshot(`${ssPrefix}-user-admin`);
  110. });
  111. });
  112. context('Access to /me page', () => {
  113. const ssPrefix = 'access-to-me-page-';
  114. beforeEach(() => {
  115. // login
  116. cy.fixture("user-admin.json").then(user => {
  117. cy.login(user.username, user.password);
  118. });
  119. });
  120. it('/me is successfully loaded', () => {
  121. cy.visit('/me');
  122. cy.getByTestid('grw-user-settings').should('be.visible');
  123. cy.collapseSidebar(true);
  124. cy.screenshot(`${ssPrefix}-me`);
  125. });
  126. // it('Draft page is successfully shown', () => {
  127. // cy.visit('/me/drafts');
  128. // cy.screenshot(`${ssPrefix}-draft-page`);
  129. // });
  130. });
  131. context('Access to special pages', () => {
  132. const ssPrefix = 'access-to-special-pages-';
  133. beforeEach(() => {
  134. // login
  135. cy.fixture("user-admin.json").then(user => {
  136. cy.login(user.username, user.password);
  137. });
  138. });
  139. it('/trash is successfully loaded', () => {
  140. cy.visit('/trash');
  141. cy.getByTestid('trash-page-list').contains('There are no pages under this page.');
  142. cy.collapseSidebar(true);
  143. cy.screenshot(`${ssPrefix}-trash`);
  144. });
  145. it('/tags is successfully loaded', { scrollBehavior: false } ,() => {
  146. // open sidebar
  147. // cy.collapseSidebar(false);
  148. cy.visit('/tags');
  149. // cy.getByTestid('grw-sidebar-content-tags').within(() => {
  150. // cy.getByTestid('grw-tags-list').should('be.visible');
  151. // cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
  152. // })
  153. cy.getByTestid('tags-page').within(() => {
  154. cy.getByTestid('grw-tags-list').should('be.visible');
  155. cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
  156. });
  157. cy.collapseSidebar(true);
  158. cy.screenshot(`${ssPrefix}-tags`);
  159. });
  160. });
  161. context('Access to Template Editing Mode', () => {
  162. const ssPrefix = 'access-to-template-page-';
  163. const templateBody1 = 'Template for children';
  164. const templateBody2 = 'Template for descendants';
  165. const createPageFromPageTreeTest = (newPagePath: string, parentPagePath: string, expectedBody: string) => {
  166. cy.visit('/');
  167. cy.waitUntilSkeletonDisappear();
  168. // Open sidebar
  169. cy.collapseSidebar(false);
  170. cy.getByTestid('grw-contextual-navigation-sub').should('be.visible');
  171. cy.waitUntilSkeletonDisappear();
  172. // If PageTree is not active when the sidebar is opened, make it active
  173. cy.getByTestid('grw-sidebar-nav-primary-page-tree').should('be.visible')
  174. .then($elem => {
  175. if (!$elem.hasClass('active')) {
  176. cy.getByTestid('grw-sidebar-nav-primary-page-tree').click();
  177. }
  178. });
  179. // Create page (/{parentPath}}/{newPagePath}) from PageTree
  180. cy.getByTestid('grw-contextual-navigation-sub').within(() => {
  181. cy.get('.grw-pagetree-item-children').first().as('pagetreeItem').within(() => {
  182. cy.get('#page-create-button-in-page-tree').first().click({force: true})
  183. });
  184. });
  185. cy.get('@pagetreeItem').within(() => {
  186. cy.getByTestid('closable-text-input').type(newPagePath).type('{enter}');
  187. })
  188. cy.visit(`/${parentPagePath}/${newPagePath}`);
  189. cy.waitUntilSkeletonDisappear();
  190. cy.collapseSidebar(true);
  191. // Check if the template is applied
  192. cy.get('.content-main').within(() => {
  193. cy.get('.wiki').should('be.visible');
  194. cy.get('.wiki').children().first().should('have.text', expectedBody);
  195. })
  196. cy.screenshot(`${ssPrefix}-page(${newPagePath})-to-which-template-is-applied`)
  197. }
  198. beforeEach(() => {
  199. // login
  200. cy.fixture("user-admin.json").then(user => {
  201. cy.login(user.username, user.password);
  202. });
  203. });
  204. it("Successfully created template for children", () => {
  205. cy.visit('/Sandbox');
  206. cy.waitUntilSkeletonDisappear();
  207. cy.waitUntil(() => {
  208. // do
  209. cy.get('#grw-subnav-container').within(() => {
  210. cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
  211. });
  212. // wait until
  213. return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
  214. });
  215. cy.getByTestid('open-page-template-modal-btn').filter(':visible').click({force: true});
  216. cy.getByTestid('page-template-modal').should('be.visible');
  217. cy.screenshot(`${ssPrefix}-open-page-template-modal`);
  218. cy.getByTestid('template-button-children').click(({force: true}))
  219. cy.waitUntilSkeletonDisappear();
  220. cy.getByTestid('navbar-editor').should('be.visible').then(()=>{
  221. cy.url().should('include', '/_template#edit');
  222. cy.screenshot(`${ssPrefix}-open-template-page-for-children-in-editor-mode`);
  223. });
  224. cy.get('.CodeMirror').type(templateBody1);
  225. cy.get('.CodeMirror').contains(templateBody1);
  226. cy.get('.page-editor-preview-body').contains(templateBody1);
  227. cy.getByTestid('page-editor').should('be.visible');
  228. cy.getByTestid('save-page-btn').click();
  229. });
  230. it('Template is applied to pages created from PageTree (template for children 1)', () => {
  231. createPageFromPageTreeTest('template-test-page1', '/Sandbox' ,templateBody1);
  232. });
  233. it('Successfully created template for descendants', () => {
  234. cy.visit('/Sandbox');
  235. cy.waitUntilSkeletonDisappear();
  236. cy.waitUntil(() => {
  237. // do
  238. cy.get('#grw-subnav-container').within(() => {
  239. cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
  240. });
  241. // Wait until
  242. return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
  243. });
  244. cy.getByTestid('open-page-template-modal-btn').filter(':visible').click({force: true});
  245. cy.getByTestid('page-template-modal').should('be.visible');
  246. cy.getByTestid('template-button-decendants').click(({force: true}))
  247. cy.waitUntilSkeletonDisappear();
  248. cy.getByTestid('navbar-editor').should('be.visible').then(()=>{
  249. cy.url().should('include', '/__template#edit');
  250. cy.screenshot(`${ssPrefix}-open-template-page-for-descendants-in-editor-mode`);
  251. })
  252. cy.get('.CodeMirror').type(templateBody2);
  253. cy.get('.CodeMirror').contains(templateBody2);
  254. cy.get('.page-editor-preview-body').contains(templateBody2);
  255. cy.getByTestid('page-editor').should('be.visible');
  256. cy.getByTestid('save-page-btn').click();
  257. });
  258. it('Template is applied to pages created from PageTree (template for children 2)', () => {
  259. createPageFromPageTreeTest('template-test-page2','Sandbox',templateBody1);
  260. });
  261. it('Template is applied to pages created from PageTree (template for descendants)', () => {
  262. // delete /Sandbox/_template
  263. cy.visit('/Sandbox/_template');
  264. cy.waitUntil(() => {
  265. //do
  266. cy.get('#grw-subnav-container').within(() => {
  267. cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
  268. });
  269. // wait until
  270. return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
  271. });
  272. cy.getByTestid('open-page-delete-modal-btn').filter(':visible').click({force: true});
  273. cy.getByTestid('page-delete-modal').should('be.visible').within(() => {
  274. cy.intercept('POST', '/_api/pages.remove').as('remove');
  275. cy.getByTestid('delete-page-button').click();
  276. cy.wait('@remove')
  277. });
  278. createPageFromPageTreeTest('template-test-page3','Sandbox',`${templateBody1}\n${templateBody2}`);
  279. })
  280. });
  281. context('Access to /me/all-in-app-notifications', () => {
  282. const ssPrefix = 'in-app-notifications-';
  283. beforeEach(() => {
  284. // login
  285. cy.fixture("user-admin.json").then(user => {
  286. cy.login(user.username, user.password);
  287. });
  288. });
  289. it('All In-App Notification list is successfully loaded', { scrollBehavior: false },() => {
  290. cy.visit('/');
  291. cy.get('.notification-wrapper').click();
  292. cy.get('.notification-wrapper > .dropdown-menu > a').click();
  293. cy.getByTestid('grw-in-app-notification-page').should('be.visible');
  294. cy.getByTestid('grw-in-app-notification-page-spinner').should('not.exist');
  295. cy.collapseSidebar(true);
  296. cy.screenshot(`${ssPrefix}-see-all`);
  297. cy.get('.grw-custom-nav-tab > div > ul > li:nth-child(2) > a').click();
  298. cy.getByTestid('grw-in-app-notification-page-spinner').should('not.exist');
  299. cy.collapseSidebar(true);
  300. cy.screenshot(`${ssPrefix}-see-unread`);
  301. });
  302. })