From 6e47b4a94149324366b4572a083f63fe2e07c6c2 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Wed, 9 Aug 2023 10:53:52 +0530 Subject: [PATCH] test: fix discussions test --- cypress/e2e/course_creation.cy.js | 58 ++++++++++++++++++++++--------- lms/www/batch/learn.html | 4 ++- 2 files changed, 44 insertions(+), 18 deletions(-) diff --git a/cypress/e2e/course_creation.cy.js b/cypress/e2e/course_creation.cy.js index 3aaf6155..48f3c5dd 100644 --- a/cypress/e2e/course_creation.cy.js +++ b/cypress/e2e/course_creation.cy.js @@ -86,26 +86,50 @@ describe("Course Creation", () => { // Add Discussion cy.get(".reply").click(); cy.wait(500); - cy.get(".topic-title").type("Question Title"); - cy.get(".comment-field").type( - "Question Content. This is a very long question. It contains more than once sentence. Its meant to be this long as this is a UI test." - ); - cy.get(".submit-discussion").click(); + cy.get(".discussion-modal").should("be.visible"); - // View Discussion - cy.wait(1000); - cy.get(".discussion-topic-title:first").contains("Question Title"); - cy.get(".sidebar-parent:first").click(); - cy.get(".reply-text").contains( - "Question Content. This is a very long question. It contains more than once sentence. Its meant to be this long as this is a UI test." + // Enter title + cy.get(".modal .topic-title") + .type("Discussion from tests") + .should("have.value", "Discussion from tests"); + + // Enter comment + cy.get(".modal .discussions-comment").type( + "This is a discussion from the cypress ui tests." ); - cy.get(".comment-field:visible").type( - "This is a reply to the previous comment. Its not that long." + + // Submit + cy.get(".modal .submit-discussion").click(); + cy.wait(2000); + + // Check if discussion is added to page and content is visible + cy.get(".sidebar-parent:first .discussion-topic-title").should( + "have.text", + "Discussion from tests" ); - cy.get(".submit-discussion:visible").click(); - cy.wait(1000); - cy.get(".reply-text:last p").contains( - "This is a reply to the previous comment. Its not that long." + cy.get(".sidebar-parent:first .discussion-topic-title").click(); + cy.get(".discussion-on-page:visible").should("have.class", "show"); + cy.get( + ".discussion-on-page:visible .reply-card .reply-text .ql-editor p" + ).should( + "have.text", + "This is a discussion from the cypress ui tests." ); + + cy.get(".discussion-form:visible .discussions-comment").type( + "This is a discussion from the cypress ui tests. \n\nThis comment was entered through the commentbox on the page." + ); + + cy.get(".discussion-form:visible .submit-discussion").click(); + cy.wait(3000); + cy.get(".discussion-on-page:visible").should("have.class", "show"); + cy.get(".discussion-on-page:visible") + .children(".reply-card") + .eq(1) + .find(".reply-text") + .should( + "have.text", + "This is a discussion from the cypress ui tests. This comment was entered through the commentbox on the page.\n" + ); }); }); diff --git a/lms/www/batch/learn.html b/lms/www/batch/learn.html index 7c92be60..9c582d68 100644 --- a/lms/www/batch/learn.html +++ b/lms/www/batch/learn.html @@ -238,7 +238,9 @@ {% set redirect_to = "/courses/" + course.name %} {% set empty_state_title = _("Have a doubt?") %} {% set empty_state_subtitle = _("Post it here, our mentors will help you out.") %} - {% include "frappe/templates/discussions/discussions_section.html" %} +
+ {% include "frappe/templates/discussions/discussions_section.html" %} +
{% endmacro %}