Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-08-04 21:10:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-08-04 21:10:05 +0300
commit43fb9e32f29817020267b13616c6670512fc5eab (patch)
tree4d9a800bbd959fe1bc6225c211343e560174256b /spec
parentd984d4a092018d86eec724a06ce2e6c066c3fb44 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/protected_tags_spec.rb13
-rw-r--r--spec/frontend/pipelines/pipeline_multi_actions_spec.js95
-rw-r--r--spec/services/groups/group_links/create_service_spec.rb2
-rw-r--r--spec/support/shared_examples/features/protected_tags_with_deploy_keys_examples.rb3
-rw-r--r--spec/support/shared_examples/protected_tags/access_control_ce_shared_examples.rb2
5 files changed, 113 insertions, 2 deletions
diff --git a/spec/features/protected_tags_spec.rb b/spec/features/protected_tags_spec.rb
index 45315f53fd6..f5b463d63fa 100644
--- a/spec/features/protected_tags_spec.rb
+++ b/spec/features/protected_tags_spec.rb
@@ -15,6 +15,8 @@ RSpec.describe 'Protected Tags', :js, :with_license, feature_category: :source_c
describe "explicit protected tags" do
it "allows creating explicit protected tags" do
visit project_protected_tags_path(project)
+ click_button('Add tag')
+
set_protected_tag_name('some-tag')
set_allowed_to('create')
click_on_protect
@@ -29,6 +31,7 @@ RSpec.describe 'Protected Tags', :js, :with_license, feature_category: :source_c
project.repository.add_tag(user, 'some-tag', commit.id)
visit project_protected_tags_path(project)
+ click_button('Add tag')
set_protected_tag_name('some-tag')
set_allowed_to('create')
click_on_protect
@@ -38,6 +41,7 @@ RSpec.describe 'Protected Tags', :js, :with_license, feature_category: :source_c
it "displays an error message if the named tag does not exist" do
visit project_protected_tags_path(project)
+ click_button('Add tag')
set_protected_tag_name('some-tag')
set_allowed_to('create')
click_on_protect
@@ -49,6 +53,7 @@ RSpec.describe 'Protected Tags', :js, :with_license, feature_category: :source_c
describe "wildcard protected tags" do
it "allows creating protected tags with a wildcard" do
visit project_protected_tags_path(project)
+ click_button('Add tag')
set_protected_tag_name('*-stable')
set_allowed_to('create')
click_on_protect
@@ -63,12 +68,16 @@ RSpec.describe 'Protected Tags', :js, :with_license, feature_category: :source_c
project.repository.add_tag(user, 'staging-stable', 'master')
visit project_protected_tags_path(project)
+ click_button('Add tag')
set_protected_tag_name('*-stable')
set_allowed_to('create')
click_on_protect
+ within("#js-protected-tags-settings .gl-new-card-count") do
+ expect(page).to have_content("2")
+ end
+
within(".protected-tags-list") do
- expect(page).to have_content("Protected tags (2)")
expect(page).to have_content("2 matching tags")
end
end
@@ -79,11 +88,13 @@ RSpec.describe 'Protected Tags', :js, :with_license, feature_category: :source_c
project.repository.add_tag(user, 'development', 'master')
visit project_protected_tags_path(project)
+ click_button('Add tag')
set_protected_tag_name('*-stable')
set_allowed_to('create')
click_on_protect
visit project_protected_tags_path(project)
+ click_button('Add tag')
click_on "2 matching tags"
within(".protected-tags-list") do
diff --git a/spec/frontend/pipelines/pipeline_multi_actions_spec.js b/spec/frontend/pipelines/pipeline_multi_actions_spec.js
index 43336bbc748..0fdc45a5931 100644
--- a/spec/frontend/pipelines/pipeline_multi_actions_spec.js
+++ b/spec/frontend/pipelines/pipeline_multi_actions_spec.js
@@ -28,6 +28,20 @@ describe('Pipeline Multi Actions Dropdown', () => {
path: '/download/path-two',
},
];
+ const newArtifacts = [
+ {
+ name: 'job-3 my-new-artifact',
+ path: '/new/download/path',
+ },
+ {
+ name: 'job-4 my-new-artifact-2',
+ path: '/new/download/path-two',
+ },
+ {
+ name: 'job-5 my-new-artifact-3',
+ path: '/new/download/path-three',
+ },
+ ];
const artifactItemTestId = 'artifact-item';
const artifactsEndpointPlaceholder = ':pipeline_artifacts_id';
const artifactsEndpoint = `endpoint/${artifactsEndpointPlaceholder}/artifacts.json`;
@@ -59,8 +73,15 @@ describe('Pipeline Multi Actions Dropdown', () => {
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findAllArtifactItems = () => wrapper.findAllByTestId(artifactItemTestId);
const findFirstArtifactItem = () => wrapper.findByTestId(artifactItemTestId);
+ const findAllArtifactItemsData = () =>
+ wrapper.findAllByTestId(artifactItemTestId).wrappers.map((x) => ({
+ path: x.attributes('href'),
+ name: x.text(),
+ }));
const findSearchBox = () => wrapper.findComponent(GlSearchBoxByType);
const findEmptyMessage = () => wrapper.findByTestId('artifacts-empty-message');
+ const findWarning = () => wrapper.findByTestId('artifacts-fetch-warning');
+ const changePipelineId = (newId) => wrapper.setProps({ pipelineId: newId });
beforeEach(() => {
mockAxios = new MockAdapter(axios);
@@ -136,6 +157,80 @@ describe('Pipeline Multi Actions Dropdown', () => {
expect(findFirstArtifactItem().attributes('href')).toBe(artifacts[0].path);
expect(findFirstArtifactItem().text()).toBe(artifacts[0].name);
});
+
+ describe('when opened again with new artifacts', () => {
+ describe('with a successful refetch', () => {
+ beforeEach(async () => {
+ mockAxios.resetHistory();
+ mockAxios.onGet(endpoint).replyOnce(HTTP_STATUS_OK, { artifacts: newArtifacts });
+
+ findDropdown().vm.$emit('show');
+ await nextTick();
+ });
+
+ it('should hide list and render a loading spinner on dropdown click', () => {
+ expect(findAllArtifactItems()).toHaveLength(0);
+ expect(findLoadingIcon().exists()).toBe(true);
+ });
+
+ it('should not render warning or empty message while loading', () => {
+ expect(findEmptyMessage().exists()).toBe(false);
+ expect(findWarning().exists()).toBe(false);
+ });
+
+ it('should render the correct new list', async () => {
+ await waitForPromises();
+
+ expect(findAllArtifactItemsData()).toEqual(newArtifacts);
+ });
+ });
+
+ describe('with a failing refetch', () => {
+ beforeEach(async () => {
+ mockAxios.onGet(endpoint).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
+
+ findDropdown().vm.$emit('show');
+ await waitForPromises();
+ });
+
+ it('should render warning', () => {
+ expect(findWarning().text()).toBe(i18n.artifactsFetchWarningMessage);
+ });
+
+ it('should render old list', () => {
+ expect(findAllArtifactItemsData()).toEqual(artifacts);
+ });
+ });
+ });
+
+ describe('pipeline id has changed', () => {
+ const newEndpoint = artifactsEndpoint.replace(
+ artifactsEndpointPlaceholder,
+ pipelineId + 1,
+ );
+
+ beforeEach(() => {
+ changePipelineId(pipelineId + 1);
+ });
+
+ describe('followed by a failing request', () => {
+ beforeEach(async () => {
+ mockAxios.onGet(newEndpoint).replyOnce(HTTP_STATUS_INTERNAL_SERVER_ERROR);
+
+ findDropdown().vm.$emit('show');
+ await waitForPromises();
+ });
+
+ it('should render error message and no warning', () => {
+ expect(findWarning().exists()).toBe(false);
+ expect(findAlert().text()).toBe(i18n.artifactsFetchErrorMessage);
+ });
+
+ it('should clear list', () => {
+ expect(findAllArtifactItems()).toHaveLength(0);
+ });
+ });
+ });
});
describe('artifacts list is empty', () => {
diff --git a/spec/services/groups/group_links/create_service_spec.rb b/spec/services/groups/group_links/create_service_spec.rb
index 8acbcdc77af..9ba664212b8 100644
--- a/spec/services/groups/group_links/create_service_spec.rb
+++ b/spec/services/groups/group_links/create_service_spec.rb
@@ -54,7 +54,7 @@ RSpec.describe Groups::GroupLinks::CreateService, '#execute', feature_category:
it_behaves_like 'shareable'
context 'when sharing outside the hierarchy is disabled' do
- let_it_be(:group_parent) do
+ let_it_be_with_refind(:group_parent) do
create(:group,
namespace_settings: create(:namespace_settings, prevent_sharing_groups_outside_hierarchy: true))
end
diff --git a/spec/support/shared_examples/features/protected_tags_with_deploy_keys_examples.rb b/spec/support/shared_examples/features/protected_tags_with_deploy_keys_examples.rb
index cc0984b6226..703ba5b018a 100644
--- a/spec/support/shared_examples/features/protected_tags_with_deploy_keys_examples.rb
+++ b/spec/support/shared_examples/features/protected_tags_with_deploy_keys_examples.rb
@@ -14,6 +14,7 @@ RSpec.shared_examples 'Deploy keys with protected tags' do
it "shows all dropdown sections in the 'Allowed to create' main dropdown, with only one deploy key" do
visit project_protected_tags_path(project)
+ click_button('Add tag')
find(".js-allowed-to-create").click
wait_for_requests
@@ -31,6 +32,7 @@ RSpec.shared_examples 'Deploy keys with protected tags' do
create(:protected_tag, :no_one_can_create, project: project, name: 'v1.0.0')
visit project_protected_tags_path(project)
+ click_button('Add tag')
within(".js-protected-tag-edit-form") do
find(".js-allowed-to-create").click
@@ -46,6 +48,7 @@ RSpec.shared_examples 'Deploy keys with protected tags' do
context 'when no deploy key can push' do
it "just shows all sections but not deploy keys in the 'Allowed to create' dropdown" do
visit project_protected_tags_path(project)
+ click_button('Add tag')
find(".js-allowed-to-create").click
wait_for_requests
diff --git a/spec/support/shared_examples/protected_tags/access_control_ce_shared_examples.rb b/spec/support/shared_examples/protected_tags/access_control_ce_shared_examples.rb
index f308b4ad372..371f33f2b29 100644
--- a/spec/support/shared_examples/protected_tags/access_control_ce_shared_examples.rb
+++ b/spec/support/shared_examples/protected_tags/access_control_ce_shared_examples.rb
@@ -4,6 +4,7 @@ RSpec.shared_examples "protected tags > access control > CE" do
ProtectedRef::AccessLevel.human_access_levels.each do |(access_type_id, access_type_name)|
it "allows creating protected tags that #{access_type_name} can create" do
visit project_protected_tags_path(project)
+ click_button('Add tag')
set_protected_tag_name('master')
set_allowed_to('create', access_type_name)
@@ -15,6 +16,7 @@ RSpec.shared_examples "protected tags > access control > CE" do
it "allows updating protected tags so that #{access_type_name} can create them" do
visit project_protected_tags_path(project)
+ click_button('Add tag')
set_protected_tag_name('master')
set_allowed_to('create', 'No one')