access-to-sidebar.spec.ts 6.6 KB

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