diff --git a/cypress/e2e/generic/public-comment.cy.js b/cypress/e2e/generic/public-comment.cy.js index 22e5e1d..fb2e036 100644 --- a/cypress/e2e/generic/public-comment.cy.js +++ b/cypress/e2e/generic/public-comment.cy.js @@ -43,9 +43,13 @@ describe("Guest comment", { testIsolation: false }, () => { const loggedInEditText = generateRandomCopy() cy.intercept("PUT", ".netlify/functions/comment/*").as("putComment") cy.get(".overflow-menu-button").first().click() - cy.get(".comment-edit-button").first().click() - cy.get("form.comment-form .comment-field").clear().type(loggedInEditText) - cy.get("form.comment-form .comment-update-button").click() + cy.get(".comment-edit-button").click() + cy.get("li.comment.is-open form.comment-form .comment-field") + .clear() + .type(loggedInEditText) + cy.get( + "li.comment.is-open form.comment-form .comment-update-button" + ).click() cy.wait("@putComment").its("response.statusCode").should("eq", 204) // 204 cy.contains("article.comment-body p", loggedInEditText).should("exist") }) @@ -65,13 +69,19 @@ describe("Guest comment", { testIsolation: false }, () => { } else req.reply() }).as("putComment") cy.get(".overflow-menu-button").first().click() - cy.get(".comment-edit-button").first().click() + cy.get(".comment-edit-button").click() + cy.get("li.comment.is-open form.comment-form .comment-field") + .clear() + .type(errorText) + cy.get( + "li.comment.is-open form.comment-form .comment-update-button" + ).click() - cy.get("form.comment-form .comment-field").clear().type(errorText) - cy.get("form.comment-form .comment-update-button").click() cy.wait("@putComment") - cy.get("form.comment-form .comment-update-button").click() + cy.get( + "li.comment.is-open form.comment-form .comment-update-button" + ).click() cy.wait("@putComment").then(interception => { expect(interception.response.statusCode).to.equal(204) @@ -102,10 +112,12 @@ describe("Guest comment", { testIsolation: false }, () => { }) it("Reply to a comment as a logged-in guest", () => { - cy.get("button.comment-reply-button").first().as("replyButton") - cy.get("@replyButton").closest("article.comment-body").as("commentBody") - cy.get("@replyButton").click() - cy.get("form.guest-login-form").should("not.exist") + const commentText = generateRandomCopy() + cy.get("button.comment-reply-button").first().click() + // cy.wait(500) + cy.get("textarea.comment-field").should("have.length", 1).type(commentText) + cy.get("button.comment-submit-button").click() + cy.get("article.comment-body p").contains(commentText).should("exist") }) it("Can log out", () => { diff --git a/cypress/e2e/generic/rtl.cy.js b/cypress/e2e/generic/rtl.cy.js index 1072f6d..26b52e1 100644 --- a/cypress/e2e/generic/rtl.cy.js +++ b/cypress/e2e/generic/rtl.cy.js @@ -114,9 +114,10 @@ describe("Simple Comment right-to-left rendering", () => { }) }) cy.visit("/") - cy.get("li#http-localhost-7070_hvh-21s6-c1m6p") - .first() - .should("have.class", "is-rtl") + cy.get("li#http-localhost-7070_hvh-21s6-c1m6p").should( + "have.class", + "is-rtl" + ) }) it("properly renders Arabic", () => { @@ -143,9 +144,9 @@ describe("Simple Comment right-to-left rendering", () => { }) }) cy.visit("/") - cy.get("li#http-localhost-7070_hvh-21s6-c1m6p") - .children("article.comment-body") - .first() - .should("not.have.class", "is-rtl") + cy.get("li#http-localhost-7070_hvh-21s6-c1m6p").should( + "not.have.class", + "is-rtl" + ) }) }) diff --git a/src/components/CommentDisplay.svelte b/src/components/CommentDisplay.svelte index 870870c..2c91aba 100644 --- a/src/components/CommentDisplay.svelte +++ b/src/components/CommentDisplay.svelte @@ -16,10 +16,10 @@ import { ClosedCaptionAlt as ReplyIcon, Edit as EditIcon, - OverflowMenuHorizontal, - ChevronLeft, + OverflowMenuHorizontal as OverflowMenuIcon, + ChevronLeft as ChevronLeftIcon, } from "carbon-icons-svelte" - import { linear } from "svelte/easing" + import { open } from "../lib/svelte-transitions" export let comment: (Comment & { isNew?: true }) | undefined = undefined export let showReply: string @@ -92,30 +92,6 @@ if (showReply !== comment.id) isOverflowToggled = false } - - const toggleExpand = ( - _overflowMenu: HTMLElement, - params?: { - delay: number - duration: number - easing: (t: number) => number - direction: "in" | "out" | "both" - } - ) => { - const { delay = 0, duration = 250, easing = linear } = params - - const css = (t: number, u: number) => { - const maxWidth = (1 - u) * 100 - return `max-width: ${maxWidth}%` - } - - return { - delay, - duration, - easing, - css, - } - }
Reply {#if isOverflowToggled} - diff --git a/src/components/CommentInput.svelte b/src/components/CommentInput.svelte index 11f793a..4aa2f2f 100644 --- a/src/components/CommentInput.svelte +++ b/src/components/CommentInput.svelte @@ -1,6 +1,8 @@