Open
Conversation
jadehamel
reviewed
Jul 1, 2024
There was a problem hiding this comment.
Some test suggestions: to ensure that edge cases are covered and the global timeout interacts correctly with other options and operations. It includes scenarios where the global timeout interacts with specific options like waitForSelector or when performing multiple asynchronous operations.
describe 'Timeout handling with waitForSelector' do
let(:url_or_html) do
<<-HTML
<html>
<body></body>
<script>
setTimeout(function() {
document.body.innerHTML = '<h1>Hey there</h1>';
}, 200);
</script>
</html>
HTML
end
let(:options) { basic_header_footer_options.merge('timeout' => timeout, 'waitForSelector' => 'h1') }
context 'when the timeout is less than the page content load' do
let(:timeout) { 100 }
it_behaves_like 'raises navigation timeout error', timeout: 100
end
context 'when the timeout is greater than the page content load' do
let(:timeout) { 2000 }
it { is_expected.to start_with "%PDF-1.4\n" }
it { expect(pdf_text_content).to eq "#{date} Hey there #{protocol}://www.example.net/foo/bar 1/1" }
end
end
describe 'Handling multiple async operations within global timeout' do
let(:timeout) { 3000 } # 3 seconds
let(:options) { basic_header_footer_options.merge('timeout' => timeout) }
let(:url_or_html) do
<<-HTML
<html>
<body>
<img src="large-image.jpg" />
<script>
setTimeout(function() {
document.body.innerHTML += '<h1>Additional Content</h1>';
}, 2000); // 2 seconds delay
</script>
</body>
</html>
HTML
end
it 'completes all operations within the global timeout period' do
expect(convert).to start_with "%PDF-1.4\n"
expect(pdf_text_content).to include "Additional Content"
end
context 'when global timeout is exceeded by operations' do
let(:timeout) { 1000 } # 1 second
it_behaves_like 'raises global timeout error', timeout: 1000
end
end
# Conflicts: # .github/workflows/test.yml # spec/spec_helper.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
Page.setDefaultTimeoutwill apply the more generaltimeoutoption more generally 😄