test: fix discussions test

This commit is contained in:
Jannat Patel
2023-08-09 10:53:52 +05:30
parent 8479e90aeb
commit 6e47b4a941
2 changed files with 44 additions and 18 deletions

View File

@@ -86,26 +86,50 @@ describe("Course Creation", () => {
// Add Discussion // Add Discussion
cy.get(".reply").click(); cy.get(".reply").click();
cy.wait(500); cy.wait(500);
cy.get(".topic-title").type("Question Title"); cy.get(".discussion-modal").should("be.visible");
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();
// View Discussion // Enter title
cy.wait(1000); cy.get(".modal .topic-title")
cy.get(".discussion-topic-title:first").contains("Question Title"); .type("Discussion from tests")
cy.get(".sidebar-parent:first").click(); .should("have.value", "Discussion from tests");
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 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.get(".sidebar-parent:first .discussion-topic-title").click();
cy.wait(1000); cy.get(".discussion-on-page:visible").should("have.class", "show");
cy.get(".reply-text:last p").contains( cy.get(
"This is a reply to the previous comment. Its not that long." ".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"
);
}); });
}); });

View File

@@ -238,7 +238,9 @@
{% set redirect_to = "/courses/" + course.name %} {% set redirect_to = "/courses/" + course.name %}
{% set empty_state_title = _("Have a doubt?") %} {% set empty_state_title = _("Have a doubt?") %}
{% set empty_state_subtitle = _("Post it here, our mentors will help you out.") %} {% set empty_state_subtitle = _("Post it here, our mentors will help you out.") %}
{% include "frappe/templates/discussions/discussions_section.html" %} <div class="pt-8">
{% include "frappe/templates/discussions/discussions_section.html" %}
</div>
{% endmacro %} {% endmacro %}