diff --git a/modules/editorial-comments/editorial-comments.php b/modules/editorial-comments/editorial-comments.php index a46e8be7d..5b6bb425b 100644 --- a/modules/editorial-comments/editorial-comments.php +++ b/modules/editorial-comments/editorial-comments.php @@ -84,7 +84,7 @@ function add_admin_scripts( ) { if ( !in_array( $pagenow, array( 'post.php', 'page.php', 'post-new.php', 'page-new.php' ) ) ) return; - wp_enqueue_script( 'edit_flow-post_comment', $this->module_url . 'lib/editorial-comments.js', array( 'jquery','post' ), EDIT_FLOW_VERSION, true ); + wp_enqueue_script( 'edit_flow-post_comment', $this->module_url . 'lib/editorial-comments.js', array( 'jquery', 'wp-ajax-response' ), EDIT_FLOW_VERSION, true ); wp_localize_script( 'edit_flow-post_comment', '__ef_localize_post_comment', array( 'and' => esc_html__( 'and', 'edit-flow' ), 'none_notified' => esc_html__( 'No one will be notified.', 'edit-flow' ), diff --git a/tests/e2e/specs/editorial-comments.test.js b/tests/e2e/specs/editorial-comments.test.js new file mode 100644 index 000000000..4d83cd330 --- /dev/null +++ b/tests/e2e/specs/editorial-comments.test.js @@ -0,0 +1,35 @@ +/** + * WordPress dependencies + */ + +import { createNewPost, saveDraft } from "@wordpress/e2e-test-utils"; + +describe("Editorial Comments", () => { + + it("expects a user can create an editorial comment on a post", async () => { + await createNewPost({title: 'Title'}); + await saveDraft(); + + // todo: Eventually, we should show the "Respond to post" button when a post is saved in Gutenberg + // without having to reload the page + await page.reload({ waitUntil: ["networkidle0", "domcontentloaded"] }); + + const COMMENT_TEXT = 'Hello'; + + const respondButton = await page.$('#ef-comment_respond'); + await respondButton.click(); + + await page.type('#ef-replycontent', COMMENT_TEXT); + + const saveReplyButton = await page.$('.ef-replysave'); + await saveReplyButton.click(); + + const commentNodes = await page.waitFor('#ef-comments .comment-content'); + + const comments = await commentNodes.$$eval('p', nodes => nodes.map(n => { + return n.innerText + })); + + expect(comments).toContain(COMMENT_TEXT); + }); +}); \ No newline at end of file