Skip to content

Commit

Permalink
attempt to fix flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHuynh333 committed Dec 19, 2024
1 parent 480bac1 commit 9ed349a
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 40 deletions.
72 changes: 52 additions & 20 deletions test/system/groups/bots_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -275,36 +275,51 @@ def setup
visit group_bots_path(@namespace)
# PAT panel is not present
assert_no_selector '#access-token-section div'
# create new bot to render PAT panel
click_link I18n.t(:'groups.bots.index.add_new_bot')
# create new PAT to render PAT panel
within "tr[id='#{namespace_bot.id}']" do
click_link I18n.t('bots.index.table.actions.generate_new_token')
end

within('#dialog') do
fill_in I18n.t('groups.bots.index.bot_listing.new_bot_modal.token_name'), with: 'Uploader'
find('#bot_access_level').find('option',
text: I18n.t('activerecord.models.member.access_level.analyst')).select_option
assert_text I18n.t(
'groups.bots.index.bot_listing.generate_personal_access_token_modal.title'
)

assert_text I18n.t('groups.bots.index.bot_listing.generate_personal_access_token_modal.description',
bot_account: namespace_bot.user.email)

fill_in I18n.t('groups.bots.index.bot_listing.new_bot_modal.token_name'), with: 'Newest token'

all('input[type=checkbox]').each(&:click)

click_button I18n.t(:'groups.bots.index.bot_listing.new_bot_modal.submit')
click_button I18n.t('groups.bots.index.bot_listing.generate_personal_access_token_modal.submit')
end

# PAT panel now present
assert_selector '#access-token-section div'
# additional asserts to prevent flakes
within('#access-token-section') do
assert_text I18n.t('groups.bots.index.access_token_section.label', bot_name: namespace_bot.user.email)
assert_text I18n.t('groups.bots.index.access_token_section.description')
end
### SETUP END ###

### ACTIONS START ###
# additional asserts to prevent flakes
assert_selector '#bots-table'
assert_selector '#bots-table table tbody tr', count: 20
within "tr[id='#{namespace_bot.id}']" do
# click active tokens number
click_link active_personal_tokens.count.to_s
end

# bot's current PATs dialog
within("#dialog table tbody tr[id='#{active_personal_tokens.first.id}']") do
within('#dialog') do
# revoke a PAT
click_link I18n.t('personal_access_tokens.table.revoke')
end
within("table tbody tr[id='#{active_personal_tokens.first.id}']") do
click_link I18n.t('personal_access_tokens.table.revoke')
end

within('#dialog') do
click_button I18n.t('personal_access_tokens.new_revoke.submit_button')
end
### ACTIONS END ###
Expand All @@ -316,36 +331,53 @@ def setup
end

test 'PAT panel removed after bot destroy' do
namespace_bot = namespace_bots(:group1_bot0)
### SETUP START ###
visit group_bots_path(@namespace)
# PAT panel is not present
assert_no_selector '#access-token-section div'
# create new bot to render PAT panel
click_link I18n.t(:'groups.bots.index.add_new_bot')
# create new PAT to render PAT panel
within "tr[id='#{namespace_bot.id}']" do
click_link I18n.t('bots.index.table.actions.generate_new_token')
end

within('dialog') do
fill_in I18n.t('groups.bots.index.bot_listing.new_bot_modal.token_name'), with: 'Uploader'
find('#bot_access_level').find('option',
text: I18n.t('activerecord.models.member.access_level.analyst')).select_option
within('#dialog') do
assert_text I18n.t(
'groups.bots.index.bot_listing.generate_personal_access_token_modal.title'
)

assert_text I18n.t('groups.bots.index.bot_listing.generate_personal_access_token_modal.description',
bot_account: namespace_bot.user.email)

fill_in I18n.t('groups.bots.index.bot_listing.new_bot_modal.token_name'), with: 'Newest token'

all('input[type=checkbox]').each(&:click)

click_button I18n.t(:'groups.bots.index.bot_listing.new_bot_modal.submit')
click_button I18n.t('groups.bots.index.bot_listing.generate_personal_access_token_modal.submit')
end

# PAT panel now present
assert_selector '#access-token-section div'
# additional asserts to prevent flakes
within('#access-token-section') do
assert_text I18n.t('groups.bots.index.access_token_section.label', bot_name: namespace_bot.user.email)
assert_text I18n.t('groups.bots.index.access_token_section.description')
end
### SETUP END ###

### ACTIONS START ###
within('table tbody tr:first-child td:last-child') do
# additional asserts to prevent flakes
assert_selector '#bots-table'
assert_selector '#bots-table table tbody tr', count: 20
within('#bots-table table tbody tr:first-child td:last-child') do
# destroy bot
click_link I18n.t(:'bots.index.table.actions.destroy')
end

within('#dialog') do
# within('#dialog') do

Check warning on line 377 in test/system/groups/bots_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Incorrect indentation detected (column 6 instead of 8). Raw Output: test/system/groups/bots_test.rb:377:7: C: Layout/CommentIndentation: Incorrect indentation detected (column 6 instead of 8).
# confirm destroy bot
click_button I18n.t('bots.new_destroy.submit_button')

Check warning on line 379 in test/system/groups/bots_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Inconsistent indentation detected. Raw Output: test/system/groups/bots_test.rb:379:9: C: Layout/IndentationConsistency: Inconsistent indentation detected.
end
# end
### ACTIONS END ###

### VERIFY START ###
Expand Down
72 changes: 52 additions & 20 deletions test/system/projects/bots_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,36 +277,51 @@ def setup
visit namespace_project_bots_path(@namespace, @project)
# PAT panel is not present
assert_no_selector '#access-token-section div'
# create new bot to render PAT panel
click_link I18n.t(:'projects.bots.index.add_new_bot')
# create new PAT to render PAT panel
within "tr[id='#{namespace_bot.id}']" do
click_link I18n.t('bots.index.table.actions.generate_new_token')
end

within('#dialog') do
fill_in I18n.t('projects.bots.index.bot_listing.new_bot_modal.token_name'), with: 'Uploader'
find('#bot_access_level').find('option',
text: I18n.t('activerecord.models.member.access_level.analyst')).select_option
assert_text I18n.t(
'projects.bots.index.bot_listing.generate_personal_access_token_modal.title'
)

assert_text I18n.t('projects.bots.index.bot_listing.generate_personal_access_token_modal.description',
bot_account: namespace_bot.user.email)

fill_in I18n.t('projects.bots.index.bot_listing.new_bot_modal.token_name'), with: 'Newest token'

all('input[type=checkbox]').each(&:click)

click_button I18n.t(:'projects.bots.index.bot_listing.new_bot_modal.submit')
click_button I18n.t('projects.bots.index.bot_listing.generate_personal_access_token_modal.submit')
end

# PAT panel now present
# additional asserts to prevent flakes
assert_selector '#access-token-section div'
within('#access-token-section') do
assert_text I18n.t('projects.bots.index.access_token_section.label', bot_name: namespace_bot.user.email)
assert_text I18n.t('projects.bots.index.access_token_section.description')
end
### SETUP END ###

### ACTIONS START ###
# additional asserts to prevent flakes
assert_selector '#bots-table'
assert_selector '#bots-table table tbody tr', count: 20
within "tr[id='#{namespace_bot.id}']" do
# click active tokens number
click_link active_personal_tokens.count.to_s
end

# bot's current PATs dialog
within("#dialog table tbody tr[id='#{active_personal_tokens.first.id}']") do
within('#dialog') do
# revoke a PAT
click_link I18n.t('personal_access_tokens.table.revoke')
end
within("table tbody tr[id='#{active_personal_tokens.first.id}']") do
click_link I18n.t('personal_access_tokens.table.revoke')
end

within('#dialog') do
click_button I18n.t('personal_access_tokens.new_revoke.submit_button')
end
### ACTIONS END ###
Expand All @@ -318,36 +333,53 @@ def setup
end

test 'PAT panel removed after bot destroy' do
namespace_bot = namespace_bots(:project1_bot0)
### SETUP START ###
visit namespace_project_bots_path(@namespace, @project)
# PAT panel is not present
assert_no_selector '#access-token-section div'
# create new bot to render PAT panel
click_link I18n.t(:'projects.bots.index.add_new_bot')
# create new PAT to render PAT panel
within "tr[id='#{namespace_bot.id}']" do
click_link I18n.t('bots.index.table.actions.generate_new_token')
end

within('dialog') do
fill_in I18n.t('projects.bots.index.bot_listing.new_bot_modal.token_name'), with: 'Uploader'
find('#bot_access_level').find('option',
text: I18n.t('activerecord.models.member.access_level.analyst')).select_option
within('#dialog') do
assert_text I18n.t(
'projects.bots.index.bot_listing.generate_personal_access_token_modal.title'
)

assert_text I18n.t('projects.bots.index.bot_listing.generate_personal_access_token_modal.description',
bot_account: namespace_bot.user.email)

fill_in I18n.t('projects.bots.index.bot_listing.new_bot_modal.token_name'), with: 'Newest token'

all('input[type=checkbox]').each(&:click)

click_button I18n.t(:'projects.bots.index.bot_listing.new_bot_modal.submit')
click_button I18n.t('projects.bots.index.bot_listing.generate_personal_access_token_modal.submit')
end

# PAT panel now present
assert_selector '#access-token-section div'
# additional asserts to prevent flakes
within('#access-token-section') do
assert_text I18n.t('projects.bots.index.access_token_section.label', bot_name: namespace_bot.user.email)
assert_text I18n.t('projects.bots.index.access_token_section.description')
end
### SETUP END ###

### ACTIONS START ###
within('table tbody tr:first-child td:last-child') do
# additional asserts to prevent flakes
assert_selector '#bots-table'
assert_selector '#bots-table table tbody tr', count: 20
within('#bots-table table tbody tr:first-child td:last-child') do
# destroy bot
click_link I18n.t(:'bots.index.table.actions.destroy')
end

within('#dialog') do
# within('#dialog') do

Check warning on line 379 in test/system/projects/bots_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Incorrect indentation detected (column 6 instead of 8). Raw Output: test/system/projects/bots_test.rb:379:7: C: Layout/CommentIndentation: Incorrect indentation detected (column 6 instead of 8).
# confirm destroy bot
click_button I18n.t('bots.new_destroy.submit_button')

Check warning on line 381 in test/system/projects/bots_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Inconsistent indentation detected. Raw Output: test/system/projects/bots_test.rb:381:9: C: Layout/IndentationConsistency: Inconsistent indentation detected.
end
# end
### ACTIONS END ###

### VERIFY START ###
Expand Down

0 comments on commit 9ed349a

Please sign in to comment.