Skip to content

Commit 2b06552

Browse files
committed
HOMS-523 Update puma and selenium, and steady the specs they run on
1 parent 6250c82 commit 2b06552

15 files changed

Lines changed: 95 additions & 20 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
3030
ruby-dev \
3131
telnet
3232

33-
RUN npm install -g yarn && yarn set version stable
33+
RUN npm install -g corepack@latest && corepack enable
3434

3535
ENV NLS_LANG=AMERICAN_RUSSIA.AL32UTF8
3636

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ GEM
365365
date
366366
stringio
367367
public_suffix (7.0.5)
368-
puma (7.2.0)
368+
puma (8.0.2)
369369
nio4r (~> 2.0)
370370
racc (1.8.1)
371371
rack (2.2.22)
@@ -453,9 +453,9 @@ GEM
453453
ruby_parser (3.22.0)
454454
racc (~> 1.5)
455455
sexp_processor (~> 4.16)
456-
rubyzip (3.2.2)
456+
rubyzip (3.4.1)
457457
securerandom (0.4.1)
458-
selenium-webdriver (4.41.0)
458+
selenium-webdriver (4.46.0)
459459
base64 (~> 0.2)
460460
logger (~> 1.4)
461461
rexml (~> 3.2, >= 3.2.5)

config/puma.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
port 3000, '0.0.0.0'
2+
13
threads 1, 1

hbw/app/models/hbw/camunda/yml_api.rb

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,54 @@ class YMLAPI < ::HBW::Common::YMLAPI
55

66
class << self
77
def build(path)
8-
new(YAML.load_file(path, aliases: true), [])
8+
from_file(path)
99
end
1010

1111
def for_prosess_keys(path, process_keys)
12-
new(YAML.load_file(path, aliases: true), process_keys)
12+
from_file(path, process_keys)
13+
end
14+
15+
def with_global(path, global)
16+
responses = merge_responses(load_file(global), load_file(path))
17+
log_stub("#{path} + global #{global}")
18+
new(responses, [])
19+
end
20+
21+
private
22+
23+
def from_file(path, process_keys = [])
24+
log_stub(path + (process_keys.empty? ? '' : " #{process_keys.inspect}"))
25+
new(load_file(path), process_keys)
26+
end
27+
28+
def load_file(path)
29+
YAML.load_file(path, aliases: true)
30+
end
31+
32+
def log_stub(desc)
33+
Rails.logger.info("[camunda-mock] stub <- #{desc}")
34+
end
35+
36+
# Combine two {method => {url => [entry]}} mocks. `overlay` entries come before `base` so
37+
# fetch_response's find-by-params returns them first: the test mock wins and the global mock
38+
# only fills endpoints or params the test mock does not define.
39+
def merge_responses(base, overlay)
40+
# Not Array(): Array(Hash) splits it into [key, value] pairs instead of wrapping it.
41+
entries = lambda do |mock, method, url|
42+
case (found = mock.dig(method, url))
43+
when nil then []
44+
when Array then found
45+
else [found]
46+
end
47+
end
48+
49+
(base.keys | overlay.keys).to_h do |method|
50+
urls = (base[method] || {}).keys | (overlay[method] || {}).keys
51+
merged = urls.to_h do |url|
52+
[url, entries.call(overlay, method, url) + entries.call(base, method, url)]
53+
end
54+
[method, merged]
55+
end
1356
end
1457
end
1558

hbw/app/models/hbw/common/yml_api.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ def load(response_file_path)
4343
# - params: <body-2 or querystring-2>
4444
# response: <response-2>
4545
def fetch_response(method, url, params)
46-
responses.fetch(method)
47-
.fetch(url)
48-
.find { |el| el['params'] == Addressable::URI.unescape(params.to_query) }
49-
.fetch('response')
46+
query = Addressable::URI.unescape(params.to_query)
47+
entry = responses.dig(method, url)&.find { |el| el['params'] == query }
48+
49+
Rails.logger.info("[camunda-mock] #{entry ? 'HIT ' : 'MISS'} #{method.upcase} #{url} params=#{query.inspect}")
50+
51+
raise KeyError, "no camunda mock entry for #{method.upcase} #{url} params=#{query.inspect}" if entry.nil?
52+
53+
entry.fetch('response')
5054
end
5155
end
5256

run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ echo "sources:
3030
password: test
3131
" > config/sources.yml
3232

33-
bundle exec rspec ./spec --format RspecJunitFormatter --out test-reports/out.xml --format progress
33+
bundle exec rspec ./spec --format RspecJunitFormatter --out test-reports/out.xml --format documentation
3434

3535
rubocop --display-only-failed --format junit --out test-reports/rubocop.xml
3636

spec/features/users/delete_user_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
admin = FactoryBot.create(:user, :admin)
44
@user = FactoryBot.create(:user, :john)
55
signin(admin.email, admin.password)
6+
expect(page).not_to have_content 'Sign in'
7+
expect(page).to have_content 'Orders list'
68
end
79

810
scenario 'we can delete user' do
@@ -11,7 +13,7 @@
1113
expect(page).to have_content I18n.t('users.edit.title')
1214

1315
click_link(I18n.t('users.show.delete_user'))
14-
expect(current_path.should).to eq('/users')
15-
expect(page).to have_no_content @user.email
16+
expect(page).to have_current_path('/users')
17+
expect(page).to have_no_content @user.email
1618
end
1719
end

spec/features/users/users_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
]
124124

125125
user_generate_api_token(admin).click
126-
expect(user_generate_api_token(admin).text).to eq 'Renew API token'
126+
expect(page).to have_link('Renew API token', href: "/users/#{admin.id}/generate_api_token")
127127
expect(is_button_red?("/users/#{admin.id}/generate_api_token")).to be true
128128

129129
admin.reload

spec/hbw/features/bp_form/translation_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
describe 'with current lang = ru' do
2121
let(:locale) { :ru }
2222

23-
scenario 'should be translated to russian' do
23+
scenario 'should be translated to russian [Q]' do
2424
click_and_wait 'ORD-1'
2525

2626
expect(page).to have_content 'Тестирование переводов'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
get:
2+
# The business-process definition list. The widget queries it two ways on every page: bare (the
3+
# full list) and filtered by the BP user for the start button (/widget/buttons). An empty list
4+
# means "nothing to start", so the widget renders no start button — correct for any test that
5+
# does not drive process starting. A test that does provides its own entry, which wins.
6+
process-definition:
7+
- params: ''
8+
response: []
9+
- params: 'latestVersion=true&startableBy=demo'
10+
response: []

0 commit comments

Comments
 (0)