Commit 2607cff7 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '215031-update-qa-selectors' into 'master'

Added QA selectors to Snippet edit form fields

Closes #215031

See merge request gitlab-org/gitlab!29985
parents 72d7d5cb e3d59881
...@@ -5,6 +5,7 @@ export default { ...@@ -5,6 +5,7 @@ export default {
components: { components: {
GlFormInput, GlFormInput,
}, },
inheritAttrs: false,
props: { props: {
value: { value: {
type: String, type: String,
...@@ -27,8 +28,9 @@ export default { ...@@ -27,8 +28,9 @@ export default {
s__('Snippets|Give your file a name to add code highlighting, e.g. example.rb for Ruby') s__('Snippets|Give your file a name to add code highlighting, e.g. example.rb for Ruby')
" "
name="snippet_file_name" name="snippet_file_name"
class="form-control js-snippet-file-name qa-snippet-file-name" class="form-control js-snippet-file-name"
type="text" type="text"
v-bind="$attrs"
@change="$emit('input', name)" @change="$emit('input', name)"
/> />
</div> </div>
......
...@@ -176,7 +176,13 @@ export default { ...@@ -176,7 +176,13 @@ export default {
class="loading-animation prepend-top-20 append-bottom-20" class="loading-animation prepend-top-20 append-bottom-20"
/> />
<template v-else> <template v-else>
<title-field :id="titleFieldId" v-model="snippet.title" required :autofocus="true" /> <title-field
:id="titleFieldId"
v-model="snippet.title"
data-qa-selector="snippet_title"
required
:autofocus="true"
/>
<snippet-description-edit <snippet-description-edit
:id="descriptionFieldId" :id="descriptionFieldId"
v-model="snippet.description" v-model="snippet.description"
...@@ -201,6 +207,7 @@ export default { ...@@ -201,6 +207,7 @@ export default {
category="primary" category="primary"
variant="success" variant="success"
:disabled="updatePrevented" :disabled="updatePrevented"
data-qa-selector="create_snippet_button"
@click="handleFormSubmit" @click="handleFormSubmit"
>{{ saveButtonLabel }}</gl-button >{{ saveButtonLabel }}</gl-button
> >
......
...@@ -33,7 +33,11 @@ export default { ...@@ -33,7 +33,11 @@ export default {
<div class="form-group file-editor"> <div class="form-group file-editor">
<label>{{ s__('Snippets|File') }}</label> <label>{{ s__('Snippets|File') }}</label>
<div class="file-holder snippet"> <div class="file-holder snippet">
<blob-header-edit :value="fileName" @input="$emit('name-change', $event)" /> <blob-header-edit
:value="fileName"
data-qa-selector="snippet_file_name"
@input="$emit('name-change', $event)"
/>
<gl-loading-icon <gl-loading-icon
v-if="isLoading" v-if="isLoading"
:label="__('Loading snippet')" :label="__('Loading snippet')"
......
...@@ -51,9 +51,9 @@ export default { ...@@ -51,9 +51,9 @@ export default {
> >
<textarea <textarea
slot="textarea" slot="textarea"
class="note-textarea js-gfm-input js-autosize markdown-area class="note-textarea js-gfm-input js-autosize markdown-area"
qa-description-textarea"
dir="auto" dir="auto"
data-qa-selector="snippet_description_field"
data-supports-quick-actions="false" data-supports-quick-actions="false"
:value="value" :value="value"
:aria-label="__('Description')" :aria-label="__('Description')"
......
...@@ -6,6 +6,7 @@ export default { ...@@ -6,6 +6,7 @@ export default {
GlFormInput, GlFormInput,
GlFormGroup, GlFormGroup,
}, },
inheritAttrs: false,
}; };
</script> </script>
<template> <template>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
= text_field_tag nil, nil, class: 'form-control', placeholder: description_placeholder, data: { qa_selector: 'description_placeholder' } = text_field_tag nil, nil, class: 'form-control', placeholder: description_placeholder, data: { qa_selector: 'description_placeholder' }
.js-expanded{ class: ('d-none' if !is_expanded) } .js-expanded{ class: ('d-none' if !is_expanded) }
= render layout: 'projects/md_preview', locals: { url: preview_markdown_path(@project), referenced_users: true } do = render layout: 'projects/md_preview', locals: { url: preview_markdown_path(@project), referenced_users: true } do
= render 'projects/zen', f: f, attr: :description, classes: 'note-textarea', placeholder: description_placeholder, qa_selector: 'description_field' = render 'projects/zen', f: f, attr: :description, classes: 'note-textarea', placeholder: description_placeholder, qa_selector: 'snippet_description_field'
= render 'shared/notes/hints' = render 'shared/notes/hints'
.form-group.file-editor .form-group.file-editor
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
= markdown_field(@snippet, :title) = markdown_field(@snippet, :title)
- if @snippet.description.present? - if @snippet.description.present?
.description{ data: { qa_selector: 'snippet_description' } } .description{ data: { qa_selector: 'snippet_description_field' } }
.md .md
= markdown_field(@snippet, :description) = markdown_field(@snippet, :description)
%textarea.hidden.js-task-list-field %textarea.hidden.js-task-list-field
......
...@@ -5,12 +5,20 @@ module QA ...@@ -5,12 +5,20 @@ module QA
module Dashboard module Dashboard
module Snippet module Snippet
class New < Page::Base class New < Page::Base
view 'app/assets/javascripts/snippets/components/edit.vue' do
element :create_snippet_button
end
view 'app/assets/javascripts/snippets/components/snippet_description_edit.vue' do
element :snippet_description_field, required: true
end
view 'app/views/shared/form_elements/_description.html.haml' do view 'app/views/shared/form_elements/_description.html.haml' do
element :issuable_form_description element :issuable_form_description
end end
view 'app/views/shared/snippets/_form.html.haml' do view 'app/views/shared/snippets/_form.html.haml' do
element :description_field element :snippet_description_field
element :description_placeholder element :description_placeholder
element :snippet_title element :snippet_title
element :snippet_file_name element :snippet_file_name
...@@ -28,7 +36,7 @@ module QA ...@@ -28,7 +36,7 @@ module QA
def fill_description(description) def fill_description(description)
click_element :description_placeholder click_element :description_placeholder
fill_element :description_field, description fill_element :snippet_description_field, description
end end
def set_visibility(visibility) def set_visibility(visibility)
...@@ -46,6 +54,7 @@ module QA ...@@ -46,6 +54,7 @@ module QA
end end
def click_create_snippet_button def click_create_snippet_button
wait_until(reload: false) { !find_element(:create_snippet_button).disabled? }
click_element :create_snippet_button click_element :create_snippet_button
end end
......
...@@ -5,9 +5,13 @@ module QA ...@@ -5,9 +5,13 @@ module QA
module Dashboard module Dashboard
module Snippet module Snippet
class Show < Page::Base class Show < Page::Base
view 'app/assets/javascripts/snippets/components/snippet_description_edit.vue' do
element :snippet_description_field, required: true
end
view 'app/views/shared/snippets/_header.html.haml' do view 'app/views/shared/snippets/_header.html.haml' do
element :snippet_title, required: true element :snippet_title, required: true
element :snippet_description, required: true element :snippet_description_field, required: true
element :embed_type element :embed_type
element :snippet_box element :snippet_box
end end
...@@ -25,7 +29,7 @@ module QA ...@@ -25,7 +29,7 @@ module QA
end end
def has_snippet_description?(snippet_description) def has_snippet_description?(snippet_description)
has_element? :snippet_description, text: snippet_description has_element? :snippet_description_field, text: snippet_description
end end
def has_embed_type?(embed_type) def has_embed_type?(embed_type)
......
...@@ -5,7 +5,7 @@ exports[`Blob Header Editing rendering matches the snapshot 1`] = ` ...@@ -5,7 +5,7 @@ exports[`Blob Header Editing rendering matches the snapshot 1`] = `
class="js-file-title file-title-flex-parent" class="js-file-title file-title-flex-parent"
> >
<gl-form-input-stub <gl-form-input-stub
class="form-control js-snippet-file-name qa-snippet-file-name" class="form-control js-snippet-file-name"
id="snippet_file_name" id="snippet_file_name"
name="snippet_file_name" name="snippet_file_name"
placeholder="Give your file a name to add code highlighting, e.g. example.rb for Ruby" placeholder="Give your file a name to add code highlighting, e.g. example.rb for Ruby"
......
...@@ -12,6 +12,7 @@ exports[`Snippet Blob Edit component rendering matches the snapshot 1`] = ` ...@@ -12,6 +12,7 @@ exports[`Snippet Blob Edit component rendering matches the snapshot 1`] = `
class="file-holder snippet" class="file-holder snippet"
> >
<blob-header-edit-stub <blob-header-edit-stub
data-qa-selector="snippet_file_name"
value="lorem.txt" value="lorem.txt"
/> />
......
...@@ -35,8 +35,8 @@ exports[`Snippet Description Edit component rendering matches the snapshot 1`] = ...@@ -35,8 +35,8 @@ exports[`Snippet Description Edit component rendering matches the snapshot 1`] =
> >
<textarea <textarea
aria-label="Description" aria-label="Description"
class="note-textarea js-gfm-input js-autosize markdown-area class="note-textarea js-gfm-input js-autosize markdown-area"
qa-description-textarea" data-qa-selector="snippet_description_field"
data-supports-quick-actions="false" data-supports-quick-actions="false"
dir="auto" dir="auto"
placeholder="Write a comment or drag your files here…" placeholder="Write a comment or drag your files here…"
......
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