[QA] Group filtering fails when filter text field is filled before the group list is fully loaded leading to "Path has already been taken" error QA tries to create a bew subgroup
It seems that groups filtering changed since it's common the filter text field is filled before the groups list is loaded (and probably before the JS event listener), thus leading to groups not being filtered, and leading to an inability to find an already existing subgroup, leading to the creation of a subgroup that already exists, thus the group isn't created, and the user is redirected to the dashboard groups page, and the rest of the test fails.
Steps to reproduce:
-
Run at least two QA test that needs to create a project, e.g.
CHROME_HEADLESS=0 GITLAB_USERNAME="root" GITLAB_PASSWORD="5iveL\!fe" bin/qa Test::Instance::All http://localhost:3000 -- qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb:8
-
The first test successfully creates the subgroup that will be used for all the QA run tests:
-
The first test pass
-
The second test tries to filter the
gitlab-qa-sandbox-group
subgroups before the groups list is loaded (and probably before the JS event listener: -
Because of that, the filtering never kicks in and the subgroup cannot be found since it's not present in the first page of the groups list (that's why the error doesn't appear in nightly QA runs, because the GitLab instance is empty there, thus the subgroup is always on the first page, and can thus always be found even if the filtering isn't working):
-
Since the subgroup cannot be found, we try to create it, but get a legit "Path has already been taken" error:
-
Since we don't verify that the group is actually created, this error is silent even though we should probably fail at this stage
-
The rest of the test continues, thus we end up on the
Dashboard > Groups
page, and the test fails in the Project factory onPage::Group::Show.act { go_to_new_project }
since there's no.new-project-subgroup
class in the page:
The following diff fixes the problem:
diff --git a/app/assets/javascripts/groups/components/groups.vue b/app/assets/javascripts/groups/components/groups.vue
index adde8c8cdb3..73ae928b0d9 100644
--- a/app/assets/javascripts/groups/components/groups.vue
+++ b/app/assets/javascripts/groups/components/groups.vue
@@ -37,7 +37,7 @@
</script>
<template>
- <div class="groups-list-tree-container">
+ <div class="groups-list-tree-container qa-groups-list-tree-container">
<div
v-if="searchEmpty"
class="has-no-search-results"
diff --git a/app/views/shared/groups/_empty_state.html.haml b/app/views/shared/groups/_empty_state.html.haml
index 13bb4baee3f..a9c78547eae 100644
--- a/app/views/shared/groups/_empty_state.html.haml
+++ b/app/views/shared/groups/_empty_state.html.haml
@@ -1,4 +1,4 @@
-.groups-empty-state
+.groups-empty-state.qa-groups-empty-state
= custom_icon("icon_empty_groups")
.text-content
diff --git a/qa/qa/factory/resource/group.rb b/qa/qa/factory/resource/group.rb
index 531fccd2ad8..d2ac6cd2e62 100644
--- a/qa/qa/factory/resource/group.rb
+++ b/qa/qa/factory/resource/group.rb
@@ -26,6 +26,11 @@ module QA
group.set_visibility('Public')
group.create
end
+
+ page.wait(time: 1) do
+ page.has_text?(@path) &&
+ page.has_new_project_or_subgroup_dropdown?
+ end
end
end
end
diff --git a/qa/qa/page/dashboard/groups.rb b/qa/qa/page/dashboard/groups.rb
index e853e0d85e0..3aa9a26ef71 100644
--- a/qa/qa/page/dashboard/groups.rb
+++ b/qa/qa/page/dashboard/groups.rb
@@ -11,7 +11,21 @@ module QA
element :new_group_button, 'link_to _("New group")'
end
+ view 'app/views/shared/groups/_empty_state.html.haml' do
+ element :groups_empty_state
+ end
+
+ view 'app/assets/javascripts/groups/components/groups.vue' do
+ element :groups_list_tree_container
+ end
+
def filter_by_name(name)
+ wait(reload: false) do
+
+ page.has_css?(element_selector_css(:groups_empty_state)) ||
+ page.has_css?(element_selector_css(:groups_list_tree_container))
+ end
+
fill_in 'Filter by name...', with: name
end
diff --git a/qa/qa/page/group/show.rb b/qa/qa/page/group/show.rb
index 3e0eaa392f5..d021e88fb3c 100644
--- a/qa/qa/page/group/show.rb
+++ b/qa/qa/page/group/show.rb
@@ -17,14 +17,32 @@ module QA
element :no_result_text, 'Sorry, no groups or projects matched your search'
end
- def go_to_subgroup(name)
- click_link name
+ view 'app/views/shared/groups/_empty_state.html.haml' do
+ element :groups_empty_state
+ end
+
+ view 'app/assets/javascripts/groups/components/groups.vue' do
+ element :groups_list_tree_container
end
def filter_by_name(name)
+ wait(reload: false) do
+
+ page.has_css?(element_selector_css(:groups_empty_state)) ||
+ page.has_css?(element_selector_css(:groups_list_tree_container))
+ end
+
fill_in 'Filter by name...', with: name
end
+ def go_to_subgroup(name)
+ click_link name
+ end
+
+ def has_new_project_or_subgroup_dropdown?
+ page.has_css?(element_selector_css(:new_project_or_subgroup_dropdown))
+ end
+
def has_subgroup?(name)
filter_by_name(name)
But that would be nice to understand when this issue was introduced. Unfortunately, given that the issue would only occur when the subgroup is not in the first page of groups, we couldn't have caught it in a package-and-qa
job since the instance is empty in this case.