diff --git a/db/schema.rb b/db/schema.rb index f845501e21..8cfb78abd3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -783,8 +783,8 @@ end create_table "scishield_trainings", charset: "utf8mb3", force: :cascade do |t| - t.integer "user_id" - t.string "course_name" + t.integer "user_id", null: false + t.string "course_name", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false end diff --git a/docker-compose.yaml b/docker-compose.yaml index 8f6a6fdd0d..69ca464565 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,7 +7,7 @@ services: context: . # To debug Github Actions CI issues: # 1) Replace `target: develop` with `dockerfile: Dockerfile.github-actions`, - # 2) Update the `command:` (for example `command: cd app && bundle install && bundle exec rake teaspoon`) + # 2) Update the `command:` (for example `command: bash -c "cd app && bundle install && bundle exec rake teaspoon"`) # 3) Run `docker compose build app`. # 4) Re-run as needed ot attach to the container to run other debugging commands target: develop @@ -29,7 +29,7 @@ services: - SELENIUM_HOST=selenium - SELENIUM_PORT=4444 - TEST_APP_PORT=3000 - - DOCKER=true + - DOCKER_LOCAL_DEV=true # Uncomment below to run teaspoon tests # - RAILS_ENV=test # - TEASPOON_RAILS_ENV=test @@ -78,7 +78,7 @@ services: stdin_open: true # For system-tests and teaspoon selenium: - image: selenium/standalone-chrome-debug + image: selenium/standalone-chrome:119.0.6045.199-chromedriver-119.0.6045.105 logging: driver: none ports: diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ba61648f6e..2baa2b3c9c 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -29,13 +29,19 @@ end config.before(:each, type: :system, js: true) do - if ENV["DOCKER"] + if ENV["DOCKER_LOCAL_DEV"] Capybara.register_driver :selenium_remote do |app| - options = { url: "http://chrome:4444/wd/hub", - browser: :chrome, - options: [:chrome] - } - Capybara::Selenium::Driver.new(app, options) + options = Selenium::WebDriver::Chrome::Options.new + options.add_argument("--headless") + options.add_argument("--window-size=1366,768") + options.add_argument("--no-sandbox") + options.add_argument("--disable-gpu") + options.add_argument("--disable-dev-shm-usage") + Capybara::Selenium::Driver.new(app, + browser: :remote, + url: "http://selenium:4444/wd/hub", + options:) + end driven_by(:selenium_remote) @@ -61,7 +67,7 @@ # Gives more verbose output for JS errors, fails any spec with SEVERE errors # Based on https://medium.com/@coorasse/catch-javascript-errors-in-your-system-tests-89c2fe6773b1 config.after(:each, type: :system, js: true) do |example| - unless ENV['DOCKER'] + unless ENV["DOCKER_LOCAL_DEV"] # Must call page.driver.browser.logs.get(:browser) after every run, # otherwise the logs don't get cleared and leak into other specs. js_errors = page.driver.browser.logs.get(:browser) @@ -162,9 +168,12 @@ # Javascript specs need to be able to talk to localhost config.around(:each, :js) do |example| - if ENV["DOCKER"] - WebMock.allow_net_connect! + if ENV["DOCKER_LOCAL_DEV"] + # As a workaround for https://github.com/bblimke/webmock/issues/1014, + # we disable WebMock completely for specs run locally within docker. + WebMock.disable! example.call + WebMock.enable! WebMock.disable_net_connect! else WebMock.disable_net_connect!(allow_localhost: true)