No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

discussions.js 3.3 KiB

hace 2 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. context("Discussions", () => {
  2. before(() => {
  3. cy.login();
  4. cy.visit("/app");
  5. return cy
  6. .window()
  7. .its("xhiveframework")
  8. .then((xhiveframework) => {
  9. return xhiveframework.call("xhiveframework.tests.ui_test_helpers.create_data_for_discussions");
  10. });
  11. });
  12. const reply_through_modal = () => {
  13. cy.visit("/test-page-discussions");
  14. // Open the modal
  15. cy.get(".reply").click();
  16. cy.wait(500);
  17. cy.get(".discussion-modal").should("be.visible");
  18. // Enter title
  19. cy.get(".modal .topic-title")
  20. .type("Discussion from tests")
  21. .should("have.value", "Discussion from tests");
  22. // Enter comment
  23. cy.get(".modal .comment-field")
  24. .type("This is a discussion from the cypress ui tests.")
  25. .should("have.value", "This is a discussion from the cypress ui tests.");
  26. // Submit
  27. cy.get(".modal .submit-discussion").click();
  28. cy.wait(2000);
  29. // Check if discussion is added to page and content is visible
  30. cy.get(".sidebar-parent:first .discussion-topic-title").should(
  31. "have.text",
  32. "Discussion from tests"
  33. );
  34. cy.get(".discussion-on-page:visible").should("have.class", "show");
  35. cy.get(".discussion-on-page:visible .reply-card .reply-text").should(
  36. "have.text",
  37. "This is a discussion from the cypress ui tests.\n"
  38. );
  39. };
  40. const reply_through_comment_box = () => {
  41. cy.get(".discussion-form:visible .comment-field")
  42. .type(
  43. "This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page."
  44. )
  45. .should(
  46. "have.value",
  47. "This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page."
  48. );
  49. cy.get(".discussion-form:visible .submit-discussion").click();
  50. cy.wait(3000);
  51. cy.get(".discussion-on-page:visible").should("have.class", "show");
  52. cy.get(".discussion-on-page:visible")
  53. .children(".reply-card")
  54. .eq(1)
  55. .find(".reply-text")
  56. .should(
  57. "have.text",
  58. "This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page.\n"
  59. );
  60. };
  61. const cancel_and_clear_comment_box = () => {
  62. cy.get(".discussion-form:visible .comment-field")
  63. .type("This is a discussion from the cypress ui tests.")
  64. .should("have.value", "This is a discussion from the cypress ui tests.");
  65. cy.get(".discussion-form:visible .cancel-comment").click();
  66. cy.get(".discussion-form:visible .comment-field").should("have.value", "");
  67. };
  68. const single_thread_discussion = () => {
  69. cy.visit("/test-single-thread");
  70. cy.get(".discussions-sidebar").should("have.length", 0);
  71. cy.get(".reply").should("have.length", 0);
  72. cy.get(".discussion-form:visible .comment-field")
  73. .type("This comment is being made on a single thread discussion.")
  74. .should("have.value", "This comment is being made on a single thread discussion.");
  75. cy.get(".discussion-form:visible .submit-discussion").click();
  76. cy.wait(3000);
  77. cy.get(".discussion-on-page")
  78. .children(".reply-card")
  79. .eq(-1)
  80. .find(".reply-text")
  81. .should("have.text", "This comment is being made on a single thread discussion.\n");
  82. };
  83. it("reply through modal", reply_through_modal);
  84. it("reply through comment box", reply_through_comment_box);
  85. it("cancel and clear comment box", cancel_and_clear_comment_box);
  86. it("single thread discussion", single_thread_discussion);
  87. });