Skip to content
代码片段 群组 项目
提交 74186238 编辑于 作者: Will Meek's avatar Will Meek 提交者: Rahul Chanila
浏览文件

Migrate more selectors to use data-testid

上级 251a9ccd
No related branches found
No related tags found
无相关合并请求
显示
23 个添加33 个删除
...@@ -281,7 +281,7 @@ export default { ...@@ -281,7 +281,7 @@ export default {
:shape="$options.AVATAR_SHAPE_OPTION_RECT" :shape="$options.AVATAR_SHAPE_OPTION_RECT"
/> />
<div> <div>
<div data-testid="project-name" data-qa-selector="project_name">{{ item.name }}</div> <div data-testid="project-name">{{ item.name }}</div>
<div class="gl-text-gray-500" data-testid="project-full-path"> <div class="gl-text-gray-500" data-testid="project-full-path">
{{ item.fullPath }} {{ item.fullPath }}
</div> </div>
......
...@@ -27,11 +27,6 @@ export default { ...@@ -27,11 +27,6 @@ export default {
required: false, required: false,
default: null, default: null,
}, },
qaSelector: {
type: String,
required: false,
default: null,
},
testid: { testid: {
type: String, type: String,
required: false, required: false,
...@@ -80,7 +75,6 @@ export default { ...@@ -80,7 +75,6 @@ export default {
:autocomplete="autocomplete" :autocomplete="autocomplete"
:name="name" :name="name"
:minlength="minimumPasswordLength" :minlength="minimumPasswordLength"
:data-qa-selector="qaSelector"
:data-testid="testid" :data-testid="testid"
:title="title" :title="title"
:type="type" :type="type"
......
...@@ -9,7 +9,7 @@ export const initPasswordInput = () => { ...@@ -9,7 +9,7 @@ export const initPasswordInput = () => {
} }
const { form } = el; const { form } = el;
const { title, id, minimumPasswordLength, qaSelector, testid, autocomplete, name } = el.dataset; const { title, id, minimumPasswordLength, testid, autocomplete, name } = el.dataset;
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
...@@ -21,7 +21,6 @@ export const initPasswordInput = () => { ...@@ -21,7 +21,6 @@ export const initPasswordInput = () => {
title, title,
id, id,
minimumPasswordLength, minimumPasswordLength,
qaSelector,
testid, testid,
autocomplete, autocomplete,
name, name,
......
...@@ -119,7 +119,6 @@ export default { ...@@ -119,7 +119,6 @@ export default {
type="password" type="password"
name="current_password" name="current_password"
:state="currentPasswordState" :state="currentPasswordState"
data-qa-selector="current_password_field"
/> />
</gl-form-group> </gl-form-group>
......
...@@ -149,7 +149,6 @@ export default { ...@@ -149,7 +149,6 @@ export default {
block block
class="gl-font-regular" class="gl-font-regular"
data-testid="template-selector" data-testid="template-selector"
data-qa-selector="template_selector"
:toggle-text="dropdownToggleText" :toggle-text="dropdownToggleText"
:search-placeholder="$options.i18n.searchPlaceholder" :search-placeholder="$options.i18n.searchPlaceholder"
:items="dropdownItems" :items="dropdownItems"
......
...@@ -7,11 +7,11 @@ def ssh_key_delete_modal_data(key, path) ...@@ -7,11 +7,11 @@ def ssh_key_delete_modal_data(key, path)
{ {
path: path, path: path,
method: 'delete', method: 'delete',
qa_selector: 'delete_ssh_key_button', testid: 'delete-ssh-key-button',
title: title, title: title,
aria_label: title, aria_label: title,
modal_attributes: { modal_attributes: {
'data-qa-selector': 'ssh_key_delete_modal', 'data-testid': 'ssh-key-delete-modal',
title: _('Are you sure you want to delete this SSH key?'), title: _('Are you sure you want to delete this SSH key?'),
message: _('This action cannot be undone, and will permanently delete the %{key} SSH key') % { key: key.title }, message: _('This action cannot be undone, and will permanently delete the %{key} SSH key') % { key: key.title },
okVariant: 'danger', okVariant: 'danger',
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
.form-group .form-group
= f.label :key, s_('Profiles|Key'), class: 'label-bold' = f.label :key, s_('Profiles|Key'), class: 'label-bold'
= f.text_area :key, class: "form-control gl-form-input js-add-ssh-key-validation-input", rows: 8, required: true, data: { supported_algorithms: Gitlab::SSHPublicKey.supported_algorithms, qa_selector: 'key_public_key_field' } = f.text_area :key, class: "form-control gl-form-input js-add-ssh-key-validation-input", rows: 8, required: true, data: { supported_algorithms: Gitlab::SSHPublicKey.supported_algorithms, testid: 'key-public-key-field' }
%p.form-text.text-muted= s_('Profiles|Begins with %{ssh_key_algorithms}.') % { ssh_key_algorithms: ssh_key_allowed_algorithms } %p.form-text.text-muted= s_('Profiles|Begins with %{ssh_key_algorithms}.') % { ssh_key_algorithms: ssh_key_allowed_algorithms }
.form-row .form-row
.col.form-group .col.form-group
= f.label :title, s_('Profiles|Title'), class: 'label-bold' = f.label :title, s_('Profiles|Title'), class: 'label-bold'
= f.text_field :title, class: "form-control gl-form-input input-lg", required: true, placeholder: s_('Profiles|Example: MacBook key'), data: { qa_selector: 'key_title_field' } = f.text_field :title, class: "form-control gl-form-input input-lg", required: true, placeholder: s_('Profiles|Example: MacBook key'), data: { testid: 'key-title-field' }
%p.form-text.text-muted= s_('Profiles|Key titles are publicly visible.') %p.form-text.text-muted= s_('Profiles|Key titles are publicly visible.')
.form-row .form-row
.col.form-group .col.form-group
...@@ -32,6 +32,6 @@ ...@@ -32,6 +32,6 @@
button_options: { class: 'js-add-ssh-key-validation-confirm-submit' }) do button_options: { class: 'js-add-ssh-key-validation-confirm-submit' }) do
= _("Yes, add it") = _("Yes, add it")
= f.submit s_('Profiles|Add key'), class: "js-add-ssh-key-validation-original-submit", pajamas_button: true, data: { qa_selector: 'add_key_button' } = f.submit s_('Profiles|Add key'), class: "js-add-ssh-key-validation-original-submit", pajamas_button: true, data: { testid: 'add-key-button' }
= render Pajamas::ButtonComponent.new(button_options: { type: 'reset', class: 'js-add-ssh-key-validation-cancel gl-ml-2 js-toggle-button' }) do = render Pajamas::ButtonComponent.new(button_options: { type: 'reset', class: 'js-add-ssh-key-validation-cancel gl-ml-2 js-toggle-button' }) do
= _('Cancel') = _('Cancel')
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
- if @keys.any? - if @keys.any?
.table-holder .table-holder
%table.table.b-table.gl-table.b-table-stacked-md.gl-mt-n1.gl-mb-n2.ssh-keys-list{ data: { qa_selector: 'ssh_keys_list' } } %table.table.b-table.gl-table.b-table-stacked-md.gl-mt-n1.gl-mb-n2.ssh-keys-list{ data: { testid: 'ssh-keys-list' } }
%thead.d-none.d-md-table-header-group %thead.d-none.d-md-table-header-group
%tr %tr
%th= _('Title') %th= _('Title')
......
...@@ -15,7 +15,7 @@ class Form < Page::Base ...@@ -15,7 +15,7 @@ class Form < Page::Base
end end
view 'app/assets/javascripts/blob/filepath_form/components/template_selector.vue' do view 'app/assets/javascripts/blob/filepath_form/components/template_selector.vue' do
element :template_selector element 'template-selector'
end end
def add_name(name) def add_name(name)
...@@ -35,7 +35,7 @@ def add_custom_name(template_name) ...@@ -35,7 +35,7 @@ def add_custom_name(template_name)
def select_template(template_type, template) def select_template(template_type, template)
case template_type case template_type
when '.gitignore', '.gitlab-ci.yml', 'Dockerfile', 'LICENSE' when '.gitignore', '.gitlab-ci.yml', 'Dockerfile', 'LICENSE'
click_element :template_selector click_element 'template-selector'
else else
raise %(Unsupported template_type "#{template_type}". Please confirm that it is a valid option.) raise %(Unsupported template_type "#{template_type}". Please confirm that it is a valid option.)
end end
......
...@@ -5,9 +5,9 @@ module Page ...@@ -5,9 +5,9 @@ module Page
module Profile module Profile
class SSHKeys < Page::Base class SSHKeys < Page::Base
view 'app/views/profiles/keys/_form.html.haml' do view 'app/views/profiles/keys/_form.html.haml' do
element :key_title_field element 'key-title-field'
element :key_public_key_field element 'key-public-key-field'
element :add_key_button element 'add-key-button'
end end
view 'app/assets/javascripts/access_tokens/components/expires_at_field.vue' do view 'app/assets/javascripts/access_tokens/components/expires_at_field.vue' do
...@@ -15,25 +15,25 @@ class SSHKeys < Page::Base ...@@ -15,25 +15,25 @@ class SSHKeys < Page::Base
end end
view 'app/helpers/ssh_keys_helper.rb' do view 'app/helpers/ssh_keys_helper.rb' do
element :delete_ssh_key_button element 'delete-ssh-key-button'
element :ssh_key_delete_modal element 'ssh-key-delete-modal'
end end
view 'app/views/profiles/keys/_key_table.html.haml' do view 'app/views/profiles/keys/_key_table.html.haml' do
element :ssh_keys_list element 'ssh-keys-list'
end end
def add_key(public_key, title) def add_key(public_key, title)
click_button('Add new key') click_button('Add new key')
fill_element(:key_public_key_field, public_key) fill_element('key-public-key-field', public_key)
fill_element(:key_title_field, title) fill_element('key-title-field', title)
# Expire in 2 days just in case the key is created just before midnight # Expire in 2 days just in case the key is created just before midnight
fill_expiry_date(Date.today + 2) fill_expiry_date(Date.today + 2)
# Close the datepicker # Close the datepicker
find_element('expiry-date-field').find('input').send_keys(:enter) find_element('expiry-date-field').find('input').send_keys(:enter)
click_element(:add_key_button) click_element('add-key-button')
end end
def fill_expiry_date(date) def fill_expiry_date(date)
...@@ -50,19 +50,19 @@ def fill_expiry_date(date) ...@@ -50,19 +50,19 @@ def fill_expiry_date(date)
def remove_key(title) def remove_key(title)
click_link(title) click_link(title)
click_element(:delete_ssh_key_button) click_element('delete-ssh-key-button')
# Retrying due to https://gitlab.com/gitlab-org/gitlab/-/issues/255287 # Retrying due to https://gitlab.com/gitlab-org/gitlab/-/issues/255287
retry_on_exception do retry_on_exception do
wait_for_animated_element(:ssh_key_delete_modal) wait_for_animated_element('ssh-key-delete-modal')
within_element(:ssh_key_delete_modal) do within_element('ssh-key-delete-modal') do
click_button('Delete') click_button('Delete')
end end
end end
end end
def keys_list def keys_list
find_element(:ssh_keys_list).text find_element('ssh-keys-list').text
end end
end end
end end
......
...@@ -9,7 +9,6 @@ describe('PasswordInput', () => { ...@@ -9,7 +9,6 @@ describe('PasswordInput', () => {
title: 'This field is required', title: 'This field is required',
id: 'new_user_password', id: 'new_user_password',
minimumPasswordLength: '8', minimumPasswordLength: '8',
qaSelector: 'new_user_password_field',
testid: 'new_user_password', testid: 'new_user_password',
autocomplete: 'new-password', autocomplete: 'new-password',
name: 'new_user', name: 'new_user',
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册