access-to-page.spec.ts 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. // hide fab // disable fab for sticky-events warning
  18. // cy.getByTestid('grw-fab-container').invoke('attr', 'style', 'display: none');
  19. // remove animation for screenshot
  20. // remove 'blink' class because ::after element cannot be operated
  21. // https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin/21709814#21709814
  22. cy.get('#mdcont-headers').invoke('removeClass', 'blink');
  23. cy.get('.grw-skelton').should('not.exist');
  24. cy.screenshot(`${ssPrefix}-sandbox-headers`);
  25. });
  26. it('/Sandbox/Math is successfully loaded', () => {
  27. cy.visit('/Sandbox/Math');
  28. // eslint-disable-next-line cypress/no-unnecessary-waiting
  29. cy.wait(2000); // wait for 2 seconds for MathJax.typesetPromise();
  30. cy.screenshot(`${ssPrefix}-sandbox-math`);
  31. });
  32. it('/Sandbox with edit is successfully loaded', () => {
  33. cy.visit('/Sandbox#edit');
  34. cy.screenshot(`${ssPrefix}-sandbox-edit-page`);
  35. })
  36. it('/user/admin is successfully loaded', () => {
  37. cy.visit('/user/admin', { });
  38. cy.get('.grw-skelton').should('not.exist');
  39. // for check download toc data
  40. cy.get('.toc-link').should('be.visible');
  41. // eslint-disable-next-line cypress/no-unnecessary-waiting
  42. cy.wait(2000); // wait for calcViewHeight and rendering
  43. cy.screenshot(`${ssPrefix}-user-admin`);
  44. });
  45. });
  46. context('Access to /me page', () => {
  47. const ssPrefix = 'access-to-me-page-';
  48. beforeEach(() => {
  49. // login
  50. cy.fixture("user-admin.json").then(user => {
  51. cy.login(user.username, user.password);
  52. });
  53. // collapse sidebar
  54. cy.collapseSidebar(true);
  55. });
  56. it('/me is successfully loaded', () => {
  57. cy.visit('/me', { });
  58. // eslint-disable-next-line cypress/no-unnecessary-waiting
  59. cy.wait(500); // wait loading image
  60. cy.screenshot(`${ssPrefix}-me`);
  61. });
  62. // it('Draft page is successfully shown', () => {
  63. // cy.visit('/me/drafts');
  64. // cy.screenshot(`${ssPrefix}-draft-page`);
  65. // });
  66. });
  67. context('Access to special pages', () => {
  68. const ssPrefix = 'access-to-special-pages-';
  69. beforeEach(() => {
  70. // login
  71. cy.fixture("user-admin.json").then(user => {
  72. cy.login(user.username, user.password);
  73. });
  74. // collapse sidebar
  75. cy.collapseSidebar(true);
  76. });
  77. it('/trash is successfully loaded', () => {
  78. cy.visit('/trash', { });
  79. cy.getByTestid('trash-page-list').should('be.visible');
  80. cy.screenshot(`${ssPrefix}-trash`);
  81. });
  82. it('/tags is successfully loaded', () => {
  83. // open sidebar
  84. cy.collapseSidebar(false);
  85. cy.visit('/tags');
  86. // select tags
  87. cy.getByTestid('grw-sidebar-nav-primary-tags').click();
  88. cy.getByTestid('grw-sidebar-content-tags').should('be.visible');
  89. cy.getByTestid('grw-tags-list').should('be.visible');
  90. cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
  91. cy.getByTestid('tags-page').should('be.visible');
  92. cy.screenshot(`${ssPrefix}-tags`);
  93. });
  94. });
  95. context('Access to Template Editing Mode', () => {
  96. const ssPrefix = 'access-to-modal-';
  97. beforeEach(() => {
  98. // login
  99. cy.fixture("user-admin.json").then(user => {
  100. cy.login(user.username, user.password);
  101. });
  102. // collapse sidebar
  103. cy.collapseSidebar(true);
  104. });
  105. it('Access to Template Editor mode for only child pages successfully', () => {
  106. cy.visit('/Sandbox/Bootstrap4', { });
  107. cy.get('#grw-subnav-container').within(() => {
  108. cy.getByTestid('open-page-item-control-btn').click();
  109. cy.getByTestid('open-page-template-modal-btn').click();
  110. });
  111. cy.getByTestid('page-template-modal').should('be.visible')
  112. cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  113. cy.getByTestid('template-button-children').click();
  114. cy.url().should('include', '/_template#edit');
  115. cy.screenshot();
  116. });
  117. it('Access to Template Editor mode including decendants successfully', () => {
  118. cy.visit('/Sandbox/Bootstrap4', { });
  119. cy.get('#grw-subnav-container').within(() => {
  120. cy.getByTestid('open-page-item-control-btn').click();
  121. cy.getByTestid('open-page-template-modal-btn').click();
  122. });
  123. cy.getByTestid('page-template-modal').should('be.visible')
  124. // cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  125. cy.getByTestid('template-button-decendants').click();
  126. cy.url().should('include', '/__template#edit');
  127. cy.screenshot();
  128. });
  129. });
  130. context('Access to /me/all-in-app-notifications', () => {
  131. const ssPrefix = 'in-app-notifications-';
  132. beforeEach(() => {
  133. // login
  134. cy.fixture("user-admin.json").then(user => {
  135. cy.login(user.username, user.password);
  136. });
  137. // collapse sidebar
  138. cy.collapseSidebar(true);
  139. });
  140. it('All In-App Notification list is successfully loaded', () => {
  141. cy.visit('/');
  142. cy.get('.notification-wrapper > a').click();
  143. cy.get('.notification-wrapper > .dropdown-menu > a').click();
  144. cy.screenshot(`${ssPrefix}-see-all`, { capture: 'viewport' });
  145. cy.get('.grw-custom-nav-tab > div > ul > li:nth-child(2) > a').click();
  146. cy.screenshot(`${ssPrefix}-see-unread`, { capture: 'viewport' });
  147. });
  148. })