access-to-page.spec.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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
  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('#Headers').invoke('removeClass', 'blink');
  23. cy.screenshot(`${ssPrefix}-sandbox-headers`);
  24. });
  25. it('/Sandbox/Math is successfully loaded', () => {
  26. cy.visit('/Sandbox/Math');
  27. cy.get('mjx-container').should('be.visible');
  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.screenshot(`${ssPrefix}-user-admin`);
  39. });
  40. });
  41. context('Access to /me page', () => {
  42. const ssPrefix = 'access-to-me-page-';
  43. beforeEach(() => {
  44. // login
  45. cy.fixture("user-admin.json").then(user => {
  46. cy.login(user.username, user.password);
  47. });
  48. // collapse sidebar
  49. cy.collapseSidebar(true);
  50. });
  51. it('/me is successfully loaded', () => {
  52. cy.visit('/me', { });
  53. // eslint-disable-next-line cypress/no-unnecessary-waiting
  54. cy.wait(500); // wait loading image
  55. cy.screenshot(`${ssPrefix}-me`);
  56. });
  57. it('Draft page is successfully shown', () => {
  58. cy.visit('/me/drafts');
  59. cy.screenshot(`${ssPrefix}-draft-page`);
  60. });
  61. });
  62. context('Access to special pages', () => {
  63. const ssPrefix = 'access-to-special-pages-';
  64. beforeEach(() => {
  65. // login
  66. cy.fixture("user-admin.json").then(user => {
  67. cy.login(user.username, user.password);
  68. });
  69. // collapse sidebar
  70. cy.collapseSidebar(true);
  71. });
  72. it('/trash is successfully loaded', () => {
  73. cy.visit('/trash', { });
  74. cy.getByTestid('trash-page-list').should('be.visible');
  75. cy.screenshot(`${ssPrefix}-trash`);
  76. });
  77. it('/tags is successfully loaded', () => {
  78. cy.visit('/tags');
  79. // open sidebar
  80. cy.collapseSidebar(false);
  81. // select tags
  82. cy.getByTestid('grw-sidebar-nav-primary-tags').click();
  83. cy.getByTestid('grw-sidebar-content-tags').should('be.visible');
  84. cy.getByTestid('grw-tags-list').should('be.visible');
  85. cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
  86. cy.getByTestid('tags-page').should('be.visible');
  87. cy.screenshot(`${ssPrefix}-tags`);
  88. });
  89. });
  90. context('Access to Template Editing Mode', () => {
  91. const ssPrefix = 'access-to-modal-';
  92. beforeEach(() => {
  93. // login
  94. cy.fixture("user-admin.json").then(user => {
  95. cy.login(user.username, user.password);
  96. });
  97. // collapse sidebar
  98. cy.collapseSidebar(true);
  99. });
  100. it('Access to Template Editor mode for only child pages successfully', () => {
  101. cy.visit('/Sandbox/Bootstrap4', { });
  102. cy.get('#grw-subnav-container').within(() => {
  103. cy.getByTestid('open-page-item-control-btn').click();
  104. cy.getByTestid('open-page-template-modal-btn').click();
  105. });
  106. cy.getByTestid('page-template-modal').should('be.visible')
  107. cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  108. cy.getByTestid('template-button-children').click();
  109. cy.url().should('include', '/_template#edit');
  110. cy.screenshot();
  111. });
  112. it('Access to Template Editor mode including decendants successfully', () => {
  113. cy.visit('/Sandbox/Bootstrap4', { });
  114. cy.get('#grw-subnav-container').within(() => {
  115. cy.getByTestid('open-page-item-control-btn').click();
  116. cy.getByTestid('open-page-template-modal-btn').click();
  117. });
  118. cy.getByTestid('page-template-modal').should('be.visible')
  119. // cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  120. cy.getByTestid('template-button-decendants').click();
  121. cy.url().should('include', '/__template#edit');
  122. cy.screenshot();
  123. });
  124. });
  125. context('Access to /me/all-in-app-notifications', () => {
  126. const ssPrefix = 'in-app-notifications-';
  127. beforeEach(() => {
  128. // login
  129. cy.fixture("user-admin.json").then(user => {
  130. cy.login(user.username, user.password);
  131. });
  132. // collapse sidebar
  133. cy.collapseSidebar(true);
  134. });
  135. it('All In-App Notification list is successfully loaded', () => {
  136. cy.visit('/');
  137. cy.get('.notification-wrapper > a').click();
  138. cy.get('.notification-wrapper > .dropdown-menu > a').click();
  139. cy.screenshot(`${ssPrefix}-see-all`, { capture: 'viewport' });
  140. cy.get('.grw-custom-nav-tab > div > ul > li:nth-child(2) > a').click();
  141. cy.screenshot(`${ssPrefix}-see-unread`, { capture: 'viewport' });
  142. });
  143. })