access-to-page.spec.ts 4.9 KB

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