From 08f4d5f0d7a5eda8e5c1348bf0d2e9bcdc55bc5f Mon Sep 17 00:00:00 2001 From: Jacob Brennan Date: Fri, 6 Dec 2019 14:52:24 -0500 Subject: [PATCH] Changed comments to be four times as long (was 300, now 1200 characters) before they are hidden behind show more. Added two tests, one to make sure comments of length > 300 but < 1200 are fully visible, and another to check that comments > 1200 characters are hidden. --- cypress/integration/common/post.js | 18 ++++++++++++++++++ cypress/integration/post/Comment.feature | 16 ++++++++++++++++ webapp/constants/comment.js | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/cypress/integration/common/post.js b/cypress/integration/common/post.js index 814159a34..a680986f4 100644 --- a/cypress/integration/common/post.js +++ b/cypress/integration/common/post.js @@ -3,6 +3,14 @@ import { When, Then } from "cypress-cucumber-preprocessor/steps"; const narratorAvatar = "https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg"; +When("I type in a comment with {int} characters", size => { + var c=""; + for (var i = 0; i < size; i++) { + c += "c" + } + cy.get(".editor .ProseMirror").type(c); +}); + Then("I click on the {string} button", text => { cy.get("button") .contains(text) @@ -23,6 +31,16 @@ Then("I should see my comment", () => { .should("contain", "today at"); }); +Then("I should see the entirety of my comment", () => { + cy.get("div.comment") + .should("not.contain", "show more") +}); + +Then("I should see an abreviated version of my comment", () => { + cy.get("div.comment") + .should("contain", "show more") +}); + Then("the editor should be cleared", () => { cy.get(".ProseMirror p").should("have.class", "is-empty"); }); diff --git a/cypress/integration/post/Comment.feature b/cypress/integration/post/Comment.feature index e7e462824..50284d6f5 100644 --- a/cypress/integration/post/Comment.feature +++ b/cypress/integration/post/Comment.feature @@ -20,3 +20,19 @@ Feature: Post Comment Then my comment should be successfully created And I should see my comment And the editor should be cleared + + Scenario: View medium length comments + Given I visit "post/bWBjpkTKZp/101-essays" + And I type in a comment with 305 characters + And I click on the "Comment" button + Then my comment should be successfully created + And I should see the entirety of my comment + And the editor should be cleared + + Scenario: View long comments + Given I visit "post/bWBjpkTKZp/101-essays" + And I type in a comment with 1205 characters + And I click on the "Comment" button + Then my comment should be successfully created + And I should see an abreviated version of my comment + And the editor should be cleared diff --git a/webapp/constants/comment.js b/webapp/constants/comment.js index 09d6ed9ea..d0a240b49 100644 --- a/webapp/constants/comment.js +++ b/webapp/constants/comment.js @@ -1,3 +1,3 @@ export const COMMENT_MIN_LENGTH = 1 -export const COMMENT_MAX_UNTRUNCATED_LENGTH = 300 +export const COMMENT_MAX_UNTRUNCATED_LENGTH = 1200 export const COMMENT_TRUNCATE_TO_LENGTH = 180