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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.waitUntil(() => {
  25. // do
  26. cy.get('.CodeMirror').type(username);
  27. // wait until
  28. return cy.get('.CodeMirror-hints').then($elem => $elem.is(':visible'));
  29. });
  30. cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}1-username-found`) });
  31. // Click on mentioned username
  32. cy.get('.CodeMirror-hints > li').first().click();
  33. cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}2-username-mentioned`) });
  34. });
  35. it('Username not found when mention username in comment', () => {
  36. const username = '@user';
  37. cy.waitUntil(() => {
  38. // do
  39. cy.get('.CodeMirror').type(username);
  40. // wait until
  41. return cy.get('.CodeMirror-hints').then($elem => $elem.is(':visible'));
  42. });
  43. cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}3-username-not-found`) });
  44. // Click on username not found hint
  45. cy.get('.CodeMirror-hints > li').first().click();
  46. cy.get('#comments-container').within(() => { cy.screenshot(`${ssPrefix}4-no-username-mentioned`) });
  47. });
  48. });