Commit 78d9736b authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch '867-e2e-test-for-browsing-locked-expired-artifacts' into 'master'

Add E2E test for locked artifacts

Closes gitlab-org/quality/testcases#867

See merge request gitlab-org/gitlab!34551
parents 6c17a007 f5e017aa
......@@ -71,6 +71,7 @@ export default {
:href="artifact.browse_path"
class="btn btn-sm btn-default"
data-testid="browse-artifacts"
data-qa-selector="browse_artifacts_button"
>{{ s__('Job|Browse') }}</gl-link
>
</div>
......
......@@ -3,6 +3,6 @@
%tr.tree-item{ 'data-link' => path_to_directory }
%td.tree-item-file-name
= tree_icon('folder', '755', directory.name)
= link_to path_to_directory, class: 'str-truncated' do
= link_to path_to_directory, class: 'str-truncated', data: { qa_selector: 'directory_name_link', qa_directory_name: directory.name } do
%span= directory.name
%td
......@@ -100,6 +100,10 @@ module QA
autoload :Show, 'qa/ee/page/project/show'
autoload :Menu, 'qa/ee/page/project/menu'
module Artifact
autoload :Show, 'qa/ee/page/project/artifact/show'
end
module SubMenus
autoload :SecurityCompliance, 'qa/ee/page/project/sub_menus/security_compliance'
autoload :Repository, 'qa/ee/page/project/sub_menus/repository'
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Artifact
class Show < QA::Page::Base
view 'app/views/projects/artifacts/_tree_directory.html.haml' do
element :directory_name_link
end
def go_to_directory(name)
click_element(:directory_name_link, directory_name: name)
end
end
end
end
end
end
end
......@@ -19,6 +19,10 @@ module QA
element :retry_button
end
view 'app/assets/javascripts/jobs/components/artifacts_block.vue' do
element :browse_artifacts_button
end
def successful?(timeout: 60)
raise "Timed out waiting for the build trace to load" unless loaded?
raise "Timed out waiting for the status to be a valid completed state" unless completed?(timeout: timeout)
......@@ -42,6 +46,14 @@ module QA
result
end
def has_browse_button?
has_element? :browse_artifacts_button
end
def click_browse_button
click_element :browse_artifacts_button
end
def retry!
click_element :retry_button
end
......
# frozen_string_literal: true
module QA
RSpec.describe 'Verify', :docker, :runner, :requires_admin do
describe 'Artifacts' do
context 'when locked' do
let(:ff_keep_latest) { 'keep_latest_artifacts_for_ref' }
let(:ff_destroy_unlocked) { 'destroy_only_unlocked_expired_artifacts' }
let(:file_name) { 'artifact.txt' }
let(:directory_name) { 'my_artifacts' }
let(:executor) { "qa-runner-#{Time.now.to_i}" }
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-locked-artifacts'
end
end
let!(:runner) do
Resource::Runner.fabricate! do |runner|
runner.project = project
runner.name = executor
runner.tags = [executor]
end
end
before do
[ff_keep_latest, ff_destroy_unlocked].each { |flag| Runtime::Feature.enable_and_verify(flag) }
Flow::Login.sign_in
end
after do
[ff_keep_latest, ff_destroy_unlocked].each { |flag| Runtime::Feature.disable_and_verify(flag) }
runner.remove_via_api!
end
it 'can be browsed' do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files(
[
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
test-artifacts:
tags:
- '#{executor}'
artifacts:
paths:
- '#{directory_name}'
expire_in: 1 sec
script:
- |
mkdir #{directory_name}
echo "CONTENTS" > #{directory_name}/#{file_name}
YAML
}
]
)
end.project.visit!
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform do |index|
index.wait_for_latest_pipeline_completion
index.click_on_latest_pipeline
end
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('test-artifacts')
end
Page::Project::Job::Show.perform do |show|
expect(show).to have_browse_button
show.click_browse_button
end
EE::Page::Project::Artifact::Show.perform do |show|
show.go_to_directory(directory_name)
expect(show).to have_content(file_name)
end
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment