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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. cy.get('.cm-content').type(commetText);
  39. cy.getByTestid("comment-submit-button").eq(0).click();
  40. // Check update comment count
  41. commentCount += 1
  42. cy.getByTestid('page-comment-button').contains(commentCount);
  43. cy.screenshot(`${ssPrefix}1-add-comments`);
  44. });
  45. it('Successfully reply comments', () => {
  46. const commetText = 'reply comment';
  47. cy.getByTestid('page-comment-button').click();
  48. // Open reply comment editor
  49. cy.waitUntil(() => {
  50. // do
  51. cy.getByTestid('comment-reply-button').eq(0).click();
  52. // wait until
  53. return cy.get('.comment-write').then($elem => $elem.is(':visible'));
  54. });
  55. cy.get('.cm-content').type(commetText);
  56. cy.getByTestid("comment-submit-button").eq(0).click();
  57. // TODO : https://redmine.weseek.co.jp/issues/139431
  58. // Check update comment count
  59. // commentCount += 1
  60. // cy.getByTestid('page-comment-button').contains(commentCount);
  61. // cy.screenshot(`${ssPrefix}2-reply-comments`);
  62. });
  63. // TODO:https://redmine.weseek.co.jp/issues/139467
  64. // it('Successfully delete comments', () => {
  65. // cy.getByTestid('page-comment-button').click();
  66. // cy.get('.page-comments').should('be.visible');
  67. // cy.getByTestid('comment-delete-button').eq(0).click({force: true});
  68. // cy.get('.modal-content').then($elem => $elem.is(':visible'));
  69. // cy.get('.modal-footer > button:nth-child(3)').click();
  70. // // Check update comment count
  71. // commentCount -= 2
  72. // cy.getByTestid('page-comment-button').contains(commentCount);
  73. // cy.screenshot(`${ssPrefix}3-delete-comments`);
  74. // });
  75. // TODO: https://redmine.weseek.co.jp/issues/139520
  76. // // Mention username in comment
  77. // it('Successfully mention username in comment', () => {
  78. // const username = '@adm';
  79. // cy.getByTestid('page-comment-button').click();
  80. // // Open comment editor
  81. // cy.waitUntil(() => {
  82. // // do
  83. // cy.getByTestid('open-comment-editor-button').click();
  84. // // wait until
  85. // return cy.get('.comment-write').then($elem => $elem.is(':visible'));
  86. // });
  87. // cy.appendTextToEditorUntilContains(username);
  88. // cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}4-mention-username-found`) });
  89. // // Click on mentioned username
  90. // cy.get('.CodeMirror-hints > li').first().click();
  91. // cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}5-mention-username-mentioned`) });
  92. // });
  93. // TODO: https://redmine.weseek.co.jp/issues/139520
  94. // it('Username not found when mention username in comment', () => {
  95. // const username = '@user';
  96. // cy.getByTestid('page-comment-button').click();
  97. // // Open comment editor
  98. // cy.waitUntil(() => {
  99. // // do
  100. // cy.getByTestid('open-comment-editor-button').click();
  101. // // wait until
  102. // return cy.get('.comment-write').then($elem => $elem.is(':visible'));
  103. // });
  104. // cy.appendTextToEditorUntilContains(username);
  105. // cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}6-mention-username-not-found`) });
  106. // // Click on username not found hint
  107. // cy.get('.CodeMirror-hints > li').first().click();
  108. // cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}7-mention-no-username-mentioned`) });
  109. // });
  110. })