From 44ab69ae4ec7151b306b06533c33affbbf776242 Mon Sep 17 00:00:00 2001 From: Daniel Uber Date: Mon, 11 Apr 2022 22:24:13 -0500 Subject: [PATCH] Wait for js component to mount before editing (#17239) This test had been failing with "title can't be blank" a few times recently. Looking for a difference between the v2 form template (in app/views/articles) and the ArticleForm component (in app/javascript/article-form/) showed there is an id on the js form but not the erb/html form we respond with first. The test had been sometimes typing the title into the text area before the component mounts, and trying to view the article gives a validation error rather than the expected response. --- spec/system/user_uses_the_editor_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/system/user_uses_the_editor_spec.rb b/spec/system/user_uses_the_editor_spec.rb index 86ed89589..ab7c5a671 100644 --- a/spec/system/user_uses_the_editor_spec.rb +++ b/spec/system/user_uses_the_editor_spec.rb @@ -98,11 +98,12 @@ RSpec.describe "Using the editor", type: :system do describe "using v2 editor", js: true do it "fill out form with rich content and click publish" do visit "/new" - fill_in "article-form-title", with: "This is a test" - fill_in "tag-input", with: "What, Yo" - fill_in "article_body_markdown", with: "Hello" + within "form#article-form" do + fill_in "article-form-title", with: "This is a test" + fill_in "tag-input", with: "What, Yo" + fill_in "article_body_markdown", with: "Hello" + end find("button", text: /\APublish\z/).click - expect(page).to have_xpath("//div[@class='crayons-article__header__meta']//h1") expect(page).to have_text("Hello") expect(page).to have_link("what", href: "/t/what")