From d56347f328885107322fc2beb54ed2bfaca61198 Mon Sep 17 00:00:00 2001 From: Henning Koch Date: Mon, 12 Feb 2024 10:33:10 +0100 Subject: [PATCH 1/5] [specs] Send images from fixtures folder --- spec/features/synchronization_spec.rb | 7 +++++-- spec/fixtures/image.jpg | Bin 0 -> 107 bytes spec/support/app.rb | 5 +++++ spec/support/matchers/be_broken_image.rb | 15 +++++++++++++++ spec/support/matchers/be_loaded_image.rb | 16 ++++++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/image.jpg create mode 100644 spec/support/matchers/be_broken_image.rb create mode 100644 spec/support/matchers/be_loaded_image.rb diff --git a/spec/features/synchronization_spec.rb b/spec/features/synchronization_spec.rb index dd9bfa8..51f5e37 100644 --- a/spec/features/synchronization_spec.rb +++ b/spec/features/synchronization_spec.rb @@ -27,8 +27,7 @@ wall = Wall.new App.next_action = -> do wall.block - content_type 'image/png' - Base64.decode64('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=') + send_file_sync('spec/fixtures/image.jpg', 'image/jpeg') end visit '/start' @@ -38,6 +37,8 @@ wall.release wait(0.5.seconds).for(command).to be_finished + + expect('img').to be_loaded_image end it 'waits until a dynamically inserted image has failed to load' do @@ -58,6 +59,8 @@ wall.release wait(0.5.seconds).for(command).to be_finished + + expect('img').to be_broken_image end it 'waits until a dynamically inserted script has loaded' do diff --git a/spec/fixtures/image.jpg b/spec/fixtures/image.jpg new file mode 100644 index 0000000000000000000000000000000000000000..71911bf48766c7181518c1070911019fbb00b1fc GIT binary patch literal 107 zcmWm0!3~2z3 0') + + expect(is_loaded).to eq(true) + end + +end From bbc17ac986315d6e9b8fdd7ec23b729c86565eee Mon Sep 17 00:00:00 2001 From: Henning Koch Date: Mon, 12 Feb 2024 12:24:16 +0100 Subject: [PATCH 2/5] Wait for media elements to load their metadata --- README.md | 1 + lib/capybara-lockstep/helper.js | 35 +++- spec/features/synchronization_spec.rb | 194 +++++++++++++++++- spec/fixtures/audio.mp3 | Bin 0 -> 9194 bytes spec/fixtures/image.jpg | Bin 107 -> 0 bytes spec/fixtures/image.png | Bin 0 -> 519 bytes spec/fixtures/video.mp4 | Bin 0 -> 68005 bytes .../be_media_element_with_metadata.rb | 15 ++ spec/support/matchers/have_ready_state.rb | 15 ++ 9 files changed, 254 insertions(+), 6 deletions(-) create mode 100644 spec/fixtures/audio.mp3 delete mode 100644 spec/fixtures/image.jpg create mode 100644 spec/fixtures/image.png create mode 100644 spec/fixtures/video.mp4 create mode 100644 spec/support/matchers/be_media_element_with_metadata.rb create mode 100644 spec/support/matchers/have_ready_state.rb diff --git a/README.md b/README.md index cf411b6..627adb4 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ When capybara-lockstep synchronizes it will: - wait for any pending AJAX requests to finish and their callbacks to be called. - wait for dynamically inserted `