Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
44bd41fe
Commit
44bd41fe
authored
Oct 23, 2020
by
Anastasia McDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add E2E to test deleting a file from snippet
See
https://gitlab.com/gitlab-org/quality/testcases/-/issues/1023
parent
119b6f30
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
6 deletions
+91
-6
app/assets/javascripts/blob/components/blob_edit_header.vue
app/assets/javascripts/blob/components/blob_edit_header.vue
+1
-0
qa/qa/page/component/snippet.rb
qa/qa/page/component/snippet.rb
+12
-0
qa/qa/page/dashboard/snippet/edit.rb
qa/qa/page/dashboard/snippet/edit.rb
+10
-0
qa/qa/resource/snippet.rb
qa/qa/resource/snippet.rb
+8
-6
qa/qa/specs/features/browser_ui/3_create/snippet/delete_file_from_snippet_spec.rb
...wser_ui/3_create/snippet/delete_file_from_snippet_spec.rb
+60
-0
No files found.
app/assets/javascripts/blob/components/blob_edit_header.vue
View file @
44bd41fe
...
...
@@ -50,6 +50,7 @@ export default {
variant=
"danger"
category=
"secondary"
:disabled=
"!canDelete"
data-qa-selector=
"delete_file_button"
@
click=
"$emit('delete')"
>
{{
s__
(
'
Snippets|Delete file
'
)
}}
</gl-button
>
...
...
qa/qa/page/component/snippet.rb
View file @
44bd41fe
...
...
@@ -110,6 +110,18 @@ module QA
end
end
def
has_no_file_name?
(
file_name
,
file_number
=
nil
)
if
file_number
within_element_by_index
(
:file_title_content
,
file_number
-
1
)
do
has_no_text?
(
file_name
)
end
else
within_element
(
:file_title_content
)
do
has_no_text?
(
file_name
)
end
end
end
def
has_file_content?
(
file_content
,
file_number
=
nil
)
if
file_number
within_element_by_index
(
:file_content
,
file_number
-
1
)
do
...
...
qa/qa/page/dashboard/snippet/edit.rb
View file @
44bd41fe
...
...
@@ -14,6 +14,10 @@ module QA
element
:file_holder_container
end
view
'app/assets/javascripts/blob/components/blob_edit_header.vue'
do
element
:delete_file_button
end
def
add_to_file_content
(
content
)
text_area
.
set
content
text_area
.
has_text?
(
content
)
# wait for changes to take effect
...
...
@@ -47,6 +51,12 @@ module QA
end
end
def
click_delete_file
(
file_number
)
within_element_by_index
(
:file_holder_container
,
file_number
-
1
)
do
click_element
(
:delete_file_button
)
end
end
def
save_changes
wait_until
(
reload:
false
)
{
!
find_element
(
:submit_button
).
disabled?
}
click_element
(
:submit_button
,
Page
::
Dashboard
::
Snippet
::
Show
)
...
...
qa/qa/resource/snippet.rb
View file @
44bd41fe
...
...
@@ -56,14 +56,16 @@ module QA
title:
title
,
description:
description
,
visibility:
visibility
.
downcase
,
files:
[
{
content:
file_content
,
file_path:
file_name
}
]
files:
all_file_contents
}
end
def
all_file_contents
@files
.
insert
(
0
,
{
name:
@file_name
,
content:
@file_content
})
@files
.
each
do
|
file
|
file
[
:file_path
]
=
file
.
delete
(
:name
)
end
end
end
end
end
qa/qa/specs/features/browser_ui/3_create/snippet/delete_file_from_snippet_spec.rb
0 → 100644
View file @
44bd41fe
# frozen_string_literal: true
module
QA
RSpec
.
describe
'Create'
do
describe
'Multiple file snippet'
do
let
(
:personal_snippet
)
do
Resource
::
Snippet
.
fabricate_via_api!
do
|
snippet
|
snippet
.
title
=
'Personal snippet to delete file from'
snippet
.
file_name
=
'Original file name'
snippet
.
file_content
=
'Original file content'
snippet
.
add_files
do
|
files
|
files
.
append
(
name:
'Second file name'
,
content:
'Second file content'
)
end
end
end
let
(
:project_snippet
)
do
Resource
::
ProjectSnippet
.
fabricate_via_api!
do
|
snippet
|
snippet
.
title
=
'Project snippet to delete file from'
snippet
.
file_name
=
'Original file name'
snippet
.
file_content
=
'Original file content'
snippet
.
add_files
do
|
files
|
files
.
append
(
name:
'Second file name'
,
content:
'Second file content'
)
end
end
end
before
do
Flow
::
Login
.
sign_in
end
shared_examples
'deleting file from snippet'
do
|
snippet_type
|
it
"deletes second file from an existing
#{
snippet_type
}
to make it single-file"
do
send
(
snippet_type
).
visit!
Page
::
Dashboard
::
Snippet
::
Show
.
perform
(
&
:click_edit_button
)
Page
::
Dashboard
::
Snippet
::
Edit
.
perform
do
|
snippet
|
snippet
.
click_delete_file
(
2
)
snippet
.
save_changes
end
Page
::
Dashboard
::
Snippet
::
Show
.
perform
do
|
snippet
|
aggregate_failures
'file names and contents'
do
expect
(
snippet
).
to
have_file_name
(
'Original file name'
)
expect
(
snippet
).
to
have_file_content
(
'Original file content'
)
expect
(
snippet
).
to
have_no_file_name
(
'Second file name'
)
expect
(
snippet
).
to
have_no_file_content
(
'Second file content'
)
end
end
end
end
it_behaves_like
'deleting file from snippet'
,
:personal_snippet
it_behaves_like
'deleting file from snippet'
,
:project_snippet
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment