access-to-page.spec.ts 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. // collapse sidebar
  9. cy.collapseSidebar(true);
  10. });
  11. it('/Sandbox is successfully loaded', () => {
  12. cy.visit('/Sandbox', { });
  13. cy.screenshot(`${ssPrefix}-sandbox`);
  14. });
  15. it('/Sandbox with anchor hash is successfully loaded', () => {
  16. cy.visit('/Sandbox#Headers');
  17. cy.waitUntilSkeletonDisappear();
  18. // for check download toc data
  19. cy.get('.toc-link').should('be.visible');
  20. // hide fab // disable fab for sticky-events warning
  21. // cy.getByTestid('grw-fab-container').invoke('attr', 'style', 'display: none');
  22. // remove animation for screenshot
  23. // remove 'blink' class because ::after element cannot be operated
  24. // https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin/21709814#21709814
  25. cy.get('#mdcont-headers').invoke('removeClass', 'blink');
  26. cy.screenshot(`${ssPrefix}-sandbox-headers`);
  27. });
  28. it('/Sandbox/Math is successfully loaded', () => {
  29. cy.visit('/Sandbox/Math');
  30. cy.waitUntilSkeletonDisappear();
  31. // for check download toc data
  32. cy.get('.toc-link').should('be.visible');
  33. cy.screenshot(`${ssPrefix}-sandbox-math`);
  34. });
  35. it('/Sandbox with edit is successfully loaded', () => {
  36. cy.visit('/Sandbox');
  37. cy.waitUntilSkeletonDisappear();
  38. cy.get('#grw-subnav-container', { timeout: 30000 }).should('be.visible').within(() => {
  39. // eslint-disable-next-line cypress/no-unnecessary-waiting
  40. cy.wait(2000);
  41. cy.getByTestid('editor-button', { timeout: 30000 }).should('be.visible').click();
  42. })
  43. cy.getByTestid('navbar-editor', { timeout: 30000 }).should('be.visible');
  44. cy.screenshot(`${ssPrefix}-Sandbox-edit-page`);
  45. })
  46. it('/user/admin is successfully loaded', () => {
  47. cy.visit('/user/admin', { });
  48. cy.waitUntilSkeletonDisappear();
  49. // for check download toc data
  50. cy.get('.toc-link').should('be.visible');
  51. // eslint-disable-next-line cypress/no-unnecessary-waiting
  52. cy.wait(2000); // wait for calcViewHeight and rendering
  53. cy.screenshot(`${ssPrefix}-user-admin`);
  54. });
  55. });
  56. context('Access to /me page', () => {
  57. const ssPrefix = 'access-to-me-page-';
  58. beforeEach(() => {
  59. // login
  60. cy.fixture("user-admin.json").then(user => {
  61. cy.login(user.username, user.password);
  62. });
  63. // collapse sidebar
  64. cy.collapseSidebar(true);
  65. });
  66. it('/me is successfully loaded', () => {
  67. cy.visit('/me', { });
  68. // eslint-disable-next-line cypress/no-unnecessary-waiting
  69. cy.wait(500); // wait loading image
  70. cy.screenshot(`${ssPrefix}-me`);
  71. });
  72. // it('Draft page is successfully shown', () => {
  73. // cy.visit('/me/drafts');
  74. // cy.screenshot(`${ssPrefix}-draft-page`);
  75. // });
  76. });
  77. context('Access to special pages', () => {
  78. const ssPrefix = 'access-to-special-pages-';
  79. beforeEach(() => {
  80. // login
  81. cy.fixture("user-admin.json").then(user => {
  82. cy.login(user.username, user.password);
  83. });
  84. // collapse sidebar
  85. cy.collapseSidebar(true);
  86. });
  87. it('/trash is successfully loaded', () => {
  88. cy.visit('/trash', { });
  89. cy.getByTestid('trash-page-list').should('be.visible');
  90. cy.screenshot(`${ssPrefix}-trash`);
  91. });
  92. it('/tags is successfully loaded', () => {
  93. // open sidebar
  94. cy.collapseSidebar(false);
  95. cy.visit('/tags');
  96. // select tags
  97. cy.getByTestid('grw-sidebar-nav-primary-tags').click();
  98. cy.getByTestid('grw-sidebar-content-tags').should('be.visible');
  99. cy.getByTestid('grw-tags-list').should('be.visible');
  100. cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
  101. cy.getByTestid('tags-page').should('be.visible');
  102. cy.screenshot(`${ssPrefix}-tags`);
  103. });
  104. });
  105. context('Access to Template Editing Mode', () => {
  106. const ssPrefix = 'access-to-modal-';
  107. beforeEach(() => {
  108. // login
  109. cy.fixture("user-admin.json").then(user => {
  110. cy.login(user.username, user.password);
  111. });
  112. // collapse sidebar
  113. cy.collapseSidebar(true);
  114. });
  115. // TODO: 109057
  116. // it('Access to Template Editor mode for only child pages successfully', () => {
  117. // cy.visit('/Sandbox/Bootstrap4', { });
  118. // cy.waitUntilSkeletonDisappear();
  119. // cy.get('#grw-subnav-container').within(() => {
  120. // cy.getByTestid('open-page-item-control-btn').should('be.visible');
  121. // cy.getByTestid('open-page-item-control-btn').click();
  122. // cy.getByTestid('open-page-template-modal-btn').should('be.visible');
  123. // cy.getByTestid('open-page-template-modal-btn').click();
  124. // });
  125. // cy.getByTestid('page-template-modal').should('be.visible');
  126. // cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  127. // Todo: `@`alias may be changed. This code was made in an attempt to solve the error of element being dettached from the dom which couldn't be solved at this time.
  128. // Wait for Todo: 109057 is solved and fix or leave the code below for better test code.
  129. // cy.getByTestid('template-button-children').as('template-button-children');
  130. // cy.get('@template-button-children').should('be.visible').click();
  131. // cy.waitUntilSkeletonDisappear();
  132. // cy.getByTestid('navbar-editor').should('be.visible').then(()=>{
  133. // cy.url().should('include', '/_template#edit');
  134. // cy.screenshot();
  135. // });
  136. // });
  137. // TODO: 109057
  138. // it('Access to Template Editor mode including decendants successfully', () => {
  139. // cy.visit('/Sandbox/Bootstrap4', { });
  140. // cy.waitUntilSkeletonDisappear();
  141. // cy.get('#grw-subnav-container').within(() => {
  142. // cy.getByTestid('open-page-item-control-btn').should('be.visible');
  143. // cy.getByTestid('open-page-item-control-btn').click();
  144. // cy.getByTestid('open-page-template-modal-btn').should('be.visible');
  145. // cy.getByTestid('open-page-template-modal-btn').click();
  146. // });
  147. // cy.getByTestid('page-template-modal').should('be.visible');
  148. // Todo: `@`alias may be changed. This code was made in an attempt to solve the error of element being dettached from the dom which couldn't be solved at this time.
  149. // Wait for Todo: 109057 is solved and fix or leave the code below for better test code.
  150. // cy.getByTestid('template-button-decendants').as('template-button-decendants');
  151. // cy.get('@template-button-decendants').should('be.visible').click();
  152. // cy.waitUntilSkeletonDisappear();
  153. // cy.getByTestid('navbar-editor').should('be.visible').then(()=>{
  154. // cy.url().should('include', '/__template#edit');
  155. // cy.screenshot();
  156. // });
  157. // });
  158. });
  159. context('Access to /me/all-in-app-notifications', () => {
  160. const ssPrefix = 'in-app-notifications-';
  161. beforeEach(() => {
  162. // login
  163. cy.fixture("user-admin.json").then(user => {
  164. cy.login(user.username, user.password);
  165. });
  166. // collapse sidebar
  167. cy.collapseSidebar(true);
  168. });
  169. it('All In-App Notification list is successfully loaded', { scrollBehavior: false },() => {
  170. cy.visit('/');
  171. cy.get('.notification-wrapper').click();
  172. cy.get('.notification-wrapper > .dropdown-menu > a').click();
  173. cy.getByTestid('grw-in-app-notification-page').should('be.visible');
  174. cy.getByTestid('grw-in-app-notification-page-spinner').should('not.exist');
  175. cy.screenshot(`${ssPrefix}-see-all`, { capture: 'viewport' });
  176. cy.get('.grw-custom-nav-tab > div > ul > li:nth-child(2) > a').click();
  177. cy.getByTestid('grw-in-app-notification-page-spinner').should('not.exist');
  178. cy.screenshot(`${ssPrefix}-see-unread`, { capture: 'viewport' });
  179. });
  180. })