Skip to content

Commit 2ff74f1

Browse files
committed
test(pc_e2e): add timeout for click operation in e2e scenario
A timeout of 1 second has been added to the click operation on the index page in the end-to-end test scenario to ensure the action completes as expected. Refactoring test
1 parent d471b69 commit 2ff74f1

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

spec/test_equipment/user_operation/user_operation_helper_spec.rb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
describe '#switch_to_the_window' do
104104
let(:operation) { :switch_to_the_window }
105105
let(:args) { { window_name: 'new' } }
106-
let(:args_with_timeout) { { window_name: 'new', timeout: 5 } }
106+
let(:timeout_sec) { 2 }
107+
let(:args_with_timeout) { { window_name: 'new', timeout: timeout_sec } }
107108
it 'call driver.swich_to_window_by_name' do
108109
expect(driver_double).to receive_message_chain(:switch_to, :window)
109110
subject.send(operation, args)
@@ -113,7 +114,7 @@
113114
subject.send(operation, args)
114115
end
115116
it 'call wait_until_helper with timeout argument' do
116-
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) }
117+
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) }
117118
subject.send(operation, args_with_timeout)
118119
end
119120
end
@@ -151,7 +152,8 @@
151152
describe '#input' do
152153
let(:operation) { :input }
153154
let(:args) { { page: 'top', part: 'form', word: 'hogehoge' } }
154-
let(:args_with_timeout) { { page: 'top', part: 'form', word: 'hogehoge', timeout: 5 } }
155+
let(:timeout_sec) { 2 }
156+
let(:args_with_timeout) { args.merge(timeout: timeout_sec) }
155157
let(:elem_double) { double('elem double') }
156158
it 'call part#send_keys' do
157159
expect(pages_double).to receive_message_chain(:get_part, :send_keys)
@@ -165,7 +167,7 @@
165167
it 'call wait_until_helper with timeout argument' do
166168
allow(pages_double).to receive_message_chain(:get_part, :send_keys).and_return(elem_double)
167169
# Verify that some of the arguments match.
168-
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) }
170+
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) }
169171
subject.send(operation, args_with_timeout)
170172
end
171173
end
@@ -182,7 +184,8 @@
182184
describe '#click' do
183185
let(:operation) { :click }
184186
let(:args) { { page: 'top', part: 'form' } }
185-
let(:args_with_timeout) { { page: 'top', part: 'form', timeout: 5 } }
187+
let(:timeout_sec) { 2 }
188+
let(:args_with_timeout) { args.merge(timeout: timeout_sec) }
186189
let(:elem_double) { double('elem double') }
187190
it 'call part#click' do
188191
allow(pages_double).to receive(:get_part).and_return(elem_double)
@@ -205,7 +208,7 @@
205208
allow(pages_double).to receive(:get_part).and_return(elem_double)
206209
allow(elem_double).to receive(:click)
207210
# Verify that some of the arguments match.
208-
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) }
211+
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) }
209212
subject.send(operation, args_with_timeout)
210213
end
211214
end
@@ -216,7 +219,8 @@
216219
let(:args_value) { { page: 'top', part: 'form', value: 1 } }
217220
let(:args_index) { { page: 'top', part: 'form', index: 1 } }
218221
let(:args_error) { { page: 'top', part: 'form', error: 1 } }
219-
let(:args_text_with_timeout) { { page: 'top', part: 'form', text: 'foo', timeout: 5 } }
222+
let(:timeout_sec) { 2 }
223+
let(:args_text_with_timeout) { args_text.merge(timeout: timeout_sec) }
220224
let(:option_double) { double('option double') }
221225
let(:elem_double) { double('elem double') }
222226
before do
@@ -246,14 +250,16 @@
246250
it 'call wait_until_helper with timeout argument' do
247251
allow(option_double).to receive(:select_by).with(:text, 'foo')
248252
# Verify that some of the arguments match.
249-
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) }.and_return(option_double)
253+
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) }.and_return(option_double)
250254
subject.send(operation, args_text_with_timeout)
251255
end
252256
end
253257

254258
describe '#accept_alert' do
255259
let(:operation) { :accept_alert }
256260
let(:alert_double) { double('alert double') }
261+
let(:timeout_sec) { 2 }
262+
let(:args_timeout) { { timeout: timeout_sec } }
257263
it 'call driver.switch_to.alert.accept' do
258264
expect(driver_double).to receive_message_chain(:switch_to, :alert, :accept)
259265
subject.send(operation, nil)
@@ -268,8 +274,8 @@
268274
allow(driver_double).to receive_message_chain(:switch_to, :alert).and_return(alert_double)
269275
allow(alert_double).to receive(:accept)
270276
# Verify that some of the arguments match.
271-
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) }.and_return(alert_double)
272-
subject.send(operation, nil)
277+
expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(2) }.and_return(alert_double)
278+
subject.send(operation, args_timeout)
273279
end
274280
end
275281

system_testing/test_bucky_project/services/service_a/pc/scenarios/e2e/pc_e2e.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ cases:
1717
operate: click
1818
page: index
1919
part: link
20+
timeout: 1
2021
- proc: check title
2122
exec:
2223
verify: assert_title
@@ -128,4 +129,4 @@ cases:
128129
- proc: index
129130
exec:
130131
verify: click_multiple_element
131-
page: index
132+
page: index

0 commit comments

Comments
 (0)