access-to-sidebar.spec.ts 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import { expect, test } from '@playwright/test';
  2. import { collapseSidebar } from '../utils';
  3. test.describe('Access to sidebar', () => {
  4. test.beforeEach(async ({ page }) => {
  5. await page.goto('/');
  6. await collapseSidebar(page, false);
  7. });
  8. test('Successfully show sidebar', async ({ page }) => {
  9. await expect(page.getByTestId('grw-sidebar-contents')).toBeVisible();
  10. });
  11. test('Successfully access to page tree', async ({ page }) => {
  12. await page.getByTestId('grw-sidebar-nav-primary-page-tree').click();
  13. await expect(page.getByTestId('grw-sidebar-contents')).toBeVisible();
  14. await expect(
  15. page.getByTestId('grw-pagetree-item-container').first(),
  16. ).toBeVisible();
  17. });
  18. test('Successfully access to recent changes', async ({ page }) => {
  19. await page.getByTestId('grw-sidebar-nav-primary-recent-changes').click();
  20. await expect(page.getByTestId('grw-recent-changes')).toBeVisible();
  21. await expect(page.locator('.list-group-item').first()).toBeVisible();
  22. });
  23. test('Successfully access to custom sidebar', async ({ page }) => {
  24. await page.getByTestId('grw-sidebar-nav-primary-custom-sidebar').click();
  25. await expect(page.getByTestId('grw-sidebar-contents')).toBeVisible();
  26. // Check if edit_note icon is visible within the button
  27. const editNoteIcon = page
  28. .locator('.grw-custom-sidebar-content button .material-symbols-outlined')
  29. .filter({ hasText: 'edit_note' });
  30. await expect(editNoteIcon).toBeVisible();
  31. });
  32. test('Successfully access to GROWI Docs page', async ({ page }) => {
  33. const linkElement = page.locator(
  34. '.grw-sidebar-nav-secondary-container a[href*="https://docs.growi.org"]',
  35. );
  36. const docsUrl = await linkElement.getAttribute('href');
  37. if (docsUrl == null) {
  38. throw new Error('url is null');
  39. }
  40. const response = await page.request.get(docsUrl);
  41. const body = await response.text();
  42. expect(body).toContain('</html>');
  43. });
  44. test('Successfully access to trash page', async ({ page }) => {
  45. await page
  46. .locator('.grw-sidebar-nav-secondary-container a[href*="/trash"]')
  47. .click();
  48. await expect(page.getByTestId('trash-page-list')).toBeVisible();
  49. });
  50. //
  51. // Deactivate: An error occurs that cannot be reproduced in the development environment. -- Yuki Takei 2024.05.10
  52. //
  53. // it('Successfully click Add to Bookmarks button', () => {
  54. // cy.waitUntil(() => {
  55. // // do
  56. // cy.getByTestid('grw-sidebar-contents').within(() => {
  57. // cy.getByTestid('grw-pagetree-item-container').eq(1).within(() => { // against the second element
  58. // cy.get('li').realHover();
  59. // cy.getByTestid('open-page-item-control-btn').find('button').first().realClick();
  60. // });
  61. // });
  62. // // wait until
  63. // return cy.get('.dropdown-menu.show').then($elem => $elem.is(':visible'));
  64. // });
  65. // cy.get('.dropdown-menu.show').should('be.visible').within(() => {
  66. // // take a screenshot for dropdown menu
  67. // cy.screenshot(`${ssPrefix}page-tree-2-before-adding-bookmark`)
  68. // // click add remove bookmark btn
  69. // cy.getByTestid('add-bookmark-btn').click();
  70. // })
  71. // // show dropdown again
  72. // cy.waitUntil(() => {
  73. // // do
  74. // cy.getByTestid('grw-sidebar-contents').within(() => {
  75. // cy.getByTestid('grw-pagetree-item-container').eq(1).within(() => { // against the second element
  76. // cy.get('li').realHover();
  77. // cy.getByTestid('open-page-item-control-btn').find('button').first().realClick();
  78. // });
  79. // });
  80. // // wait until
  81. // return cy.get('.dropdown-menu.show').then($elem => $elem.is(':visible'));
  82. // });
  83. // cy.get('.dropdown-menu.show').should('be.visible').within(() => {
  84. // // expect to be visible
  85. // cy.getByTestid('remove-bookmark-btn').should('be.visible');
  86. // // take a screenshot for dropdown menu
  87. // cy.screenshot(`${ssPrefix}page-tree-2-after-adding-bookmark`);
  88. // });
  89. // });
  90. // it('Successfully show duplicate page modal', () => {
  91. // cy.waitUntil(() => {
  92. // // do
  93. // cy.getByTestid('grw-sidebar-contents').within(() => {
  94. // cy.getByTestid('grw-pagetree-item-container').eq(1).within(() => { // against the second element
  95. // cy.get('li').realHover();
  96. // cy.getByTestid('open-page-item-control-btn').find('button').first().realClick();
  97. // });
  98. // });
  99. // // wait until
  100. // return cy.get('.dropdown-menu.show').then($elem => $elem.is(':visible'));
  101. // });
  102. // cy.get('.dropdown-menu.show').should('be.visible').within(() => {
  103. // cy.getByTestid('open-page-duplicate-modal-btn').click();
  104. // })
  105. // cy.getByTestid('page-duplicate-modal').should('be.visible').within(() => {
  106. // cy.get('.form-control').type('_test');
  107. // cy.screenshot(`${ssPrefix}page-tree-5-duplicate-page-modal`, { blackout: blackoutOverride });
  108. // cy.get('.modal-header > button').click();
  109. // });
  110. // });
  111. // it('Successfully rename page', () => {
  112. // cy.waitUntil(() => {
  113. // // do
  114. // cy.getByTestid('grw-sidebar-contents').within(() => {
  115. // cy.getByTestid('grw-pagetree-item-container').eq(1).within(() => { // against the second element
  116. // cy.get('li').realHover();
  117. // cy.getByTestid('open-page-item-control-btn').find('button').first().realClick();
  118. // });
  119. // });
  120. // // wait until
  121. // return cy.get('.dropdown-menu.show').then($elem => $elem.is(':visible'));
  122. // });
  123. // cy.get('.dropdown-menu.show').should('be.visible').within(() => {
  124. // cy.getByTestid('rename-page-btn').click();
  125. // })
  126. // cy.getByTestid('grw-sidebar-contents').within(() => {
  127. // cy.getByTestid('autosize-submittable-input').type('_newname');
  128. // })
  129. // cy.screenshot(`${ssPrefix}page-tree-6-rename-page`, { blackout: blackoutOverride });
  130. // });
  131. // it('Successfully show delete page modal', () => {
  132. // cy.waitUntil(() => {
  133. // // do
  134. // cy.getByTestid('grw-sidebar-contents').within(() => {
  135. // cy.getByTestid('grw-pagetree-item-container').eq(1).within(() => { // against the second element
  136. // cy.get('li').realHover();
  137. // cy.getByTestid('open-page-item-control-btn').find('button').first().realClick();
  138. // });
  139. // });
  140. // // wait until
  141. // return cy.get('.dropdown-menu.show').then($elem => $elem.is(':visible'));
  142. // });
  143. // cy.get('.dropdown-menu.show').should('be.visible').within(() => {
  144. // cy.getByTestid('open-page-delete-modal-btn').click();
  145. // })
  146. // cy.getByTestid('page-delete-modal').should('be.visible').within(() => {
  147. // cy.screenshot(`${ssPrefix}page-tree-7-delete-page-modal`, { blackout: blackoutOverride });
  148. // cy.get('.modal-header > button').click();
  149. // });
  150. // });
  151. });