access-to-sidebar.spec.ts 6.5 KB

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