20-basic-features--username-mention.cy.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. context('Mention username in comment', () => {
  2. const ssPrefix = 'mention-username-';
  3. beforeEach(() => {
  4. // login
  5. cy.fixture("user-admin.json").then(user => {
  6. cy.login(user.username, user.password);
  7. });
  8. // Visit /Sandbox
  9. cy.visit('/Sandbox');
  10. cy.waitUntilSkeletonDisappear();
  11. cy.collapseSidebar(true, true);
  12. // Go to comment page
  13. cy.getByTestid('page-comment-button').click();
  14. // Open comment editor
  15. cy.waitUntil(() => {
  16. // do
  17. cy.getByTestid('open-comment-editor-button').click();
  18. // wait until
  19. return cy.get('.comment-write').then($elem => $elem.is(':visible'));
  20. });
  21. });
  22. it('Successfully mention username in comment', () => {
  23. const username = 'adm';
  24. cy.intercept('GET', `/_api/v3/users/usernames?q=${username}&limit=20`).as('searchUsername');
  25. cy.get('.CodeMirror').type('@' + username);
  26. cy.wait('@searchUsername');
  27. cy.get('.CodeMirror-hints').should('be.visible');
  28. cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}1-username-found`) });
  29. // Click on mentioned username
  30. cy.get('.CodeMirror-hints > li').first().click();
  31. cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}2-username-mentioned`) });
  32. });
  33. it('Username not found when mention username in comment', () => {
  34. const username = 'user';
  35. cy.intercept('GET', `/_api/v3/users/usernames?q=${username}&limit=20`).as('searchUsername');
  36. cy.get('.CodeMirror').type('@' + username);
  37. cy.wait('@searchUsername');
  38. cy.get('.CodeMirror-hints').should('be.visible');
  39. cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}3-username-not-found`) });
  40. // Click on username not found hint
  41. cy.get('.CodeMirror-hints > li').first().click();
  42. cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}4-no-username-mentioned`) });
  43. });
  44. });