Skip to content

Commit

Permalink
Add UI testing for group deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
malchua committed Oct 8, 2024
1 parent 59cde47 commit ac91d50
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<div class="flex flex-row-reverse gap-x-3 text-slate-500">
<% if @namespace.type == "Group" %>
<%= viral_tooltip(title: t(:'.stats.samples')) do %>
<span class="flex items-center text-sm">
<span class="flex items-center text-sm samples-count">
<%= viral_icon(name: :beaker, color: :subdued, classes: "h-5 w-5") %><%= @namespace.samples_count %>
</span>
<% end %>
Expand Down
40 changes: 40 additions & 0 deletions test/system/dashboard/groups_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,45 @@ def setup
fill_in I18n.t(:'dashboard.groups.index.search.placeholder'), with: 'z6z6z6'
assert_text I18n.t(:'dashboard.groups.index.no_groups_description')
end

test 'should update samples count after a deletion' do
login_as users(:john_doe)
visit dashboard_groups_url

assert_selector 'h1', text: I18n.t(:'dashboard.groups.index.title')
group_twelve_samples_count = 0
group_twelve_a_samples_count = 0

within :xpath, "//li[contains(@class, 'namespace-entry')][.//*/a[text()='#{groups(:group_twelve).name}']]" do
assert_text groups(:group_twelve).name
group_twelve_samples_count = find('span.samples-count').text.to_i
find('a.folder-toggle-wrap').click
end

within :xpath,
"(//li[contains(@class, 'namespace-entry')][.//*/a[text()='#{groups(:subgroup_twelve_a).name}']])[last()]" do

Check warning on line 220 in test/system/dashboard/groups_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Line is too long. [122/120] Raw Output: test/system/dashboard/groups_test.rb:220:121: C: Layout/LineLength: Line is too long. [122/120]
assert_text groups(:subgroup_twelve_a).name
group_twelve_a_samples_count = find('span.samples-count').text.to_i
find('a.folder-toggle-wrap').click
end

assert_difference('Group.count', -1) do
Groups::DestroyService.new(groups(:subgroup_twelve_a_a), users(:john_doe)).execute
end

visit current_url

within :xpath, "//li[contains(@class, 'namespace-entry')][.//*/a[text()='#{groups(:group_twelve).name}']]" do
assert_text groups(:group_twelve).name
assert_equal group_twelve_samples_count - 2, find('span.samples-count').text.to_i
find('a.folder-toggle-wrap').click
end

within :xpath,
"(//li[contains(@class, 'namespace-entry')][.//*/a[text()='#{groups(:subgroup_twelve_a).name}']])[last()]" do

Check warning on line 239 in test/system/dashboard/groups_test.rb

View workflow job for this annotation

GitHub Actions / runner / rubocop

[rubocop] reported by reviewdog 🐶 Line is too long. [122/120] Raw Output: test/system/dashboard/groups_test.rb:239:121: C: Layout/LineLength: Line is too long. [122/120]
assert_text groups(:subgroup_twelve_a).name
assert_equal group_twelve_a_samples_count - 2, find('span.samples-count').text.to_i
end
end
end
end

0 comments on commit ac91d50

Please sign in to comment.