Skip to content

Remove Race Condition From All System Tests #6693

@FireLemons

Description

@FireLemons

Our system tests run on a browser. Sometimes Github's servers are strained so the browser performs very slowly. For some tests this causes a race condition between entering data using a the browser and checking the effect of the entered data through ActiveRecord which bypasses the browser. The database check happens before the browser actions are completed if the browser's performance is crippled enough.

Examples:

Good expects

  expect(page).to have_content "Court Date"
  expect(page).to have_text(supervisor_name)
  
  wait_for_download
  expect(download_docx.paragraphs.map(&:to_s)).to include("Hearing Date: January 8, 2021")

Bad/Suspicious expects

  expect(CourtDate.count).to eq 2
  expect(supervisor.reload).not_to be_active
  
  deliveries = ActionMailer::Base.deliveries
  expect(deliveries.count).to eq(1)
  expect(deliveries.last.subject).to have_text "CASA Console invitation instructions"

The bad expects don't get their data from the browser. If they don't get the data from the browser, it doesn't make them automatically invalid. If the test waits for the page to load before checking data from the backend, that's valid. However for a system test, we should try to write them so all the steps of the test would have meaning to a user. A user would be able to see elements on a webpage but they wouldn't be able to check the database.

This is a continuation of: #6265

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions