Skip to content

Commit

Permalink
Improve rescript tests
Browse files Browse the repository at this point in the history
In this commit, a deply is put between UI interaction and database
check. This, fixed false positive test pass for not updating database on
empty form submission.
  • Loading branch information
ahangarha committed Jan 1, 2024
1 parent 3455e55 commit 71a779d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spec/rescript/rescript_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,35 @@
fill_in author_field, with: comment.author
fill_in text_field, with: comment.text
click_button("Post")

page.driver.browser.manage.timeouts.implicit_wait = 1

expect(Comment.all.count).to equal(new_comment_count)
end

it "comment count remains the same when author field is empty" do
initial_comment_count = Comment.all.count
fill_in text_field, with: comment.text
click_button("Post")

expect(page).to have_text(/Can't save the comment!/)
expect(Comment.all.count).to equal(initial_comment_count)
end

it "comment count remains the same when text field is empty" do
initial_comment_count = Comment.all.count
fill_in author_field, with: comment.author
click_button("Post")

expect(page).to have_text(/Can't save the comment!/)
expect(Comment.all.count).to equal(initial_comment_count)
end

it "comment count remains the same when both form fields are empty" do
initial_comment_count = Comment.all.count
click_button("Post")

expect(page).to have_text(/Can't save the comment!/)
expect(Comment.all.count).to equal(initial_comment_count)
end
end
Expand Down

0 comments on commit 71a779d

Please sign in to comment.