20-basic-features--comments.cy.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. context('Comment', () => {
  2. const ssPrefix = 'comments-';
  3. let commentCount = 0;
  4. beforeEach(() => {
  5. // login
  6. cy.fixture("user-admin.json").then(user => {
  7. cy.login(user.username, user.password);
  8. });
  9. // visit page
  10. cy.visit('/comment');
  11. cy.collapseSidebar(true, true);
  12. })
  13. it('Create comment page', () => {
  14. // save page
  15. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  16. cy.waitUntil(() => {
  17. // do
  18. cy.get('@pageEditorModeManager').within(() => {
  19. cy.get('button:nth-child(2)').click();
  20. });
  21. // until
  22. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  23. });
  24. cy.get('.cm-content').should('be.visible');
  25. cy.getByTestid('page-editor').should('be.visible');
  26. cy.getByTestid('save-page-btn').click();
  27. })
  28. it('Successfully add comments', () => {
  29. const commetText = 'add comment';
  30. cy.getByTestid('page-comment-button').click();
  31. // Open comment editor
  32. cy.waitUntil(() => {
  33. // do
  34. cy.getByTestid('open-comment-editor-button').click();
  35. // wait until
  36. return cy.get('.comment-write').then($elem => $elem.is(':visible'));
  37. });
  38. // // Open comment editor
  39. // cy.getByTestid('open-comment-editor-button').click();
  40. // cy.get('.comment-write').then($elem => $elem.is(':visible'));
  41. cy.get('.cm-content').type(commetText);
  42. cy.getByTestid("comment-submit-button").eq(0).click();
  43. // Check update comment count
  44. commentCount += 1
  45. cy.getByTestid('page-comment-button').contains(commentCount);
  46. cy.screenshot(`${ssPrefix}1-add-comments`);
  47. });
  48. it('Successfully reply comments', () => {
  49. const commetText = 'reply comment';
  50. cy.getByTestid('page-comment-button').click();
  51. // // Open reply comment editor
  52. // cy.getByTestid('comment-reply-button').eq(0).click();
  53. // cy.get('.comment-write').then($elem => $elem.is(':visible'));
  54. // Open reply comment editor
  55. cy.waitUntil(() => {
  56. // do
  57. cy.getByTestid('comment-reply-button').eq(0).click();
  58. // wait until
  59. return cy.get('.comment-write').then($elem => $elem.is(':visible'));
  60. });
  61. cy.get('.cm-content').type(commetText);
  62. cy.getByTestid("comment-submit-button").eq(0).click();
  63. // TODO : https://redmine.weseek.co.jp/issues/139431
  64. // Check update comment count
  65. // commentCount += 1
  66. // cy.getByTestid('page-comment-button').contains(commentCount);
  67. // cy.screenshot(`${ssPrefix}2-reply-comments`);
  68. });
  69. // TODO:https://redmine.weseek.co.jp/issues/139467
  70. // it('Successfully delete comments', () => {
  71. // cy.getByTestid('page-comment-button').click();
  72. // cy.get('.page-comments').should('be.visible');
  73. // cy.getByTestid('comment-delete-button').eq(0).click({force: true});
  74. // cy.get('.modal-content').then($elem => $elem.is(':visible'));
  75. // cy.get('.modal-footer > button:nth-child(3)').click();
  76. // // Check update comment count
  77. // commentCount -= 2
  78. // cy.getByTestid('page-comment-button').contains(commentCount);
  79. // cy.screenshot(`${ssPrefix}3-delete-comments`);
  80. // });
  81. // TODO: https://redmine.weseek.co.jp/issues/139520
  82. // // Mention username in comment
  83. // it('Successfully mention username in comment', () => {
  84. // const username = '@adm';
  85. // cy.getByTestid('page-comment-button').click();
  86. // // Open comment editor
  87. // cy.waitUntil(() => {
  88. // // do
  89. // cy.getByTestid('open-comment-editor-button').click();
  90. // // wait until
  91. // return cy.get('.comment-write').then($elem => $elem.is(':visible'));
  92. // });
  93. // cy.appendTextToEditorUntilContains(username);
  94. // cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}4-mention-username-found`) });
  95. // // Click on mentioned username
  96. // cy.get('.CodeMirror-hints > li').first().click();
  97. // cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}5-mention-username-mentioned`) });
  98. // });
  99. // TODO: https://redmine.weseek.co.jp/issues/139520
  100. // it('Username not found when mention username in comment', () => {
  101. // const username = '@user';
  102. // cy.getByTestid('page-comment-button').click();
  103. // // Open comment editor
  104. // cy.waitUntil(() => {
  105. // // do
  106. // cy.getByTestid('open-comment-editor-button').click();
  107. // // wait until
  108. // return cy.get('.comment-write').then($elem => $elem.is(':visible'));
  109. // });
  110. // cy.appendTextToEditorUntilContains(username);
  111. // cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}6-mention-username-not-found`) });
  112. // // Click on username not found hint
  113. // cy.get('.CodeMirror-hints > li').first().click();
  114. // cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}7-mention-no-username-mentioned`) });
  115. // });
  116. })