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
885f3a75
Commit
885f3a75
authored
May 20, 2021
by
Coung Ngo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove data-testids in favour of testing by label text
Remove data-testids in app/assets/javascripts/issuable
parent
0c2ac180
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
94 additions
and
129 deletions
+94
-129
app/assets/javascripts/issuable/components/csv_export_modal.vue
...sets/javascripts/issuable/components/csv_export_modal.vue
+0
-1
app/assets/javascripts/issuable/components/csv_import_export_buttons.vue
...scripts/issuable/components/csv_import_export_buttons.vue
+5
-12
app/assets/javascripts/issuable/components/csv_import_modal.vue
...sets/javascripts/issuable/components/csv_import_modal.vue
+1
-7
app/assets/javascripts/issuable/components/issuable_by_email.vue
...ets/javascripts/issuable/components/issuable_by_email.vue
+2
-8
app/assets/javascripts/issuable/components/status_box.vue
app/assets/javascripts/issuable/components/status_box.vue
+1
-5
spec/features/issues/csv_spec.rb
spec/features/issues/csv_spec.rb
+1
-3
spec/features/issues/user_resets_their_incoming_email_token_spec.rb
...res/issues/user_resets_their_incoming_email_token_spec.rb
+2
-2
spec/features/merge_requests/user_exports_as_csv_spec.rb
spec/features/merge_requests/user_exports_as_csv_spec.rb
+1
-7
spec/frontend/issuable/components/csv_export_modal_spec.js
spec/frontend/issuable/components/csv_export_modal_spec.js
+20
-24
spec/frontend/issuable/components/csv_import_export_buttons_spec.js
...end/issuable/components/csv_import_export_buttons_spec.js
+31
-27
spec/frontend/issuable/components/csv_import_modal_spec.js
spec/frontend/issuable/components/csv_import_modal_spec.js
+22
-26
spec/frontend/issuable/components/issuable_by_email_spec.js
spec/frontend/issuable/components/issuable_by_email_spec.js
+6
-5
spec/frontend/issuable/components/status_box_spec.js
spec/frontend/issuable/components/status_box_spec.js
+2
-2
No files found.
app/assets/javascripts/issuable/components/csv_export_modal.vue
View file @
885f3a75
...
...
@@ -51,7 +51,6 @@ export default {
</template>
<div
v-if=
"issuableCount > -1"
data-testid=
"issuable-count-note"
class=
"gl-justify-content-start gl-align-items-center gl-p-4 gl-border-b-solid gl-border-1 gl-border-gray-50"
>
<gl-icon
name=
"check"
class=
"gl-color-green-400"
/>
...
...
app/assets/javascripts/issuable/components/csv_import_export_buttons.vue
View file @
885f3a75
...
...
@@ -72,9 +72,6 @@ export default {
importModalId
()
{
return
`
${
this
.
issuableType
}
-import-modal`
;
},
importButtonText
()
{
return
this
.
showLabel
?
this
.
$options
.
i18n
.
importIssuesText
:
null
;
},
importButtonTooltipText
()
{
return
this
.
showLabel
?
null
:
this
.
$options
.
i18n
.
importIssuesText
;
},
...
...
@@ -90,29 +87,25 @@ export default {
<gl-button-group>
<gl-button
v-if=
"showExportButton"
v-gl-tooltip
.hover
=
"$options.i18n.exportAsCsvButtonText"
v-gl-tooltip=
"$options.i18n.exportAsCsvButtonText"
v-gl-modal=
"exportModalId"
icon=
"export"
:aria-label=
"$options.i18n.exportAsCsvButtonText"
data-qa-selector=
"export_as_csv_button"
data-testid=
"export-csv-button"
/>
<gl-dropdown
v-if=
"showImportButton"
v-gl-tooltip
.hover
=
"importButtonTooltipText"
v-gl-tooltip=
"importButtonTooltipText"
data-qa-selector=
"import_issues_dropdown"
data-testid=
"import-csv-dropdown
"
:text
=
"importButtonText
"
:text=
"$options.i18n.importIssuesText
"
:text
-sr-only=
"!showLabel
"
:icon=
"importButtonIcon"
>
<gl-dropdown-item
v-gl-modal=
"importModalId"
data-testid=
"import-csv-link"
>
{{
__
(
'
Import CSV
'
)
}}
</gl-dropdown-item>
<gl-dropdown-item
v-gl-modal=
"importModalId"
>
{{
__
(
'
Import CSV
'
)
}}
</gl-dropdown-item>
<gl-dropdown-item
v-if=
"canEdit"
:href=
"projectImportJiraPath"
data-qa-selector=
"import_from_jira_link"
data-testid=
"import-from-jira-link"
>
{{
__
(
'
Import from Jira
'
)
}}
</gl-dropdown-item
>
</gl-dropdown>
...
...
app/assets/javascripts/issuable/components/csv_import_modal.vue
View file @
885f3a75
...
...
@@ -48,13 +48,7 @@ export default {
<
template
>
<gl-modal
:modal-id=
"modalId"
:title=
"__('Import issues')"
>
<form
ref=
"form"
:action=
"importCsvIssuesPath"
enctype=
"multipart/form-data"
method=
"post"
data-testid=
"import-csv-form"
>
<form
ref=
"form"
:action=
"importCsvIssuesPath"
enctype=
"multipart/form-data"
method=
"post"
>
<input
:value=
"$options.csrf.token"
type=
"hidden"
name=
"authenticity_token"
/>
<p>
{{
...
...
app/assets/javascripts/issuable/components/issuable_by_email.vue
View file @
885f3a75
...
...
@@ -91,7 +91,7 @@ export default {
<
template
>
<div>
<gl-button
v-gl-modal=
"$options.modalId"
variant=
"link"
data-testid=
"issuable-email-modal-btn"
<gl-button
v-gl-modal=
"$options.modalId"
variant=
"link"
><gl-sprintf
:message=
"__('Email a new %
{name} to this project')"
>
<template
#name
>
{{
issuableName
}}
</
template
></gl-sprintf
></gl-button
...
...
@@ -122,7 +122,6 @@ export default {
:title=
"$options.i18n.sendEmail"
:aria-label=
"$options.i18n.sendEmail"
icon=
"mail"
data-testid=
"mail-to-btn"
/>
</
template
>
</gl-form-input-group>
...
...
@@ -156,12 +155,7 @@ export default {
/></gl-link>
</
template
>
<
template
#resetLink=
"{ content }"
>
<gl-button
variant=
"link"
data-testid=
"incoming-email-token-reset"
@
click=
"resetIncomingEmailToken"
>
{{
content
}}
</gl-button
>
<gl-button
variant=
"link"
@
click=
"resetIncomingEmailToken"
>
{{
content
}}
</gl-button>
</
template
>
</gl-sprintf>
</p>
...
...
app/assets/javascripts/issuable/components/status_box.vue
View file @
885f3a75
...
...
@@ -91,11 +91,7 @@ export default {
<
template
>
<div
:class=
"statusBoxClass"
class=
"issuable-status-box status-box"
>
<gl-icon
:name=
"statusIconName"
class=
"gl-display-block gl-sm-display-none!"
data-testid=
"status-icon"
/>
<gl-icon
:name=
"statusIconName"
class=
"gl-display-block gl-sm-display-none!"
/>
<span
class=
"gl-display-none gl-sm-display-block"
>
{{
statusHumanName
}}
</span>
...
...
spec/features/issues/csv_spec.rb
View file @
885f3a75
...
...
@@ -16,9 +16,7 @@ RSpec.describe 'Issues csv', :js do
def
request_csv
(
params
=
{})
visit
project_issues_path
(
project
,
params
)
page
.
within
(
'.nav-controls'
)
do
find
(
'[data-testid="export-csv-button"]'
).
click
end
click_button
'Export as CSV'
click_on
'Export issues'
end
...
...
spec/features/issues/user_resets_their_incoming_email_token_spec.rb
View file @
885f3a75
...
...
@@ -16,11 +16,11 @@ RSpec.describe 'Issues > User resets their incoming email token' do
end
it
'changes incoming email address token'
,
:js
do
page
.
find
(
'[data-testid="issuable-email-modal-btn"]'
).
click
click_button
'Email a new issue to this project'
page
.
within
'#issuable-email-modal'
do
previous_token
=
page
.
find
(
'input[type="text"]'
).
value
page
.
find
(
'[data-testid="incoming-email-token-reset"]'
).
click
click_button
'reset it'
wait_for_requests
...
...
spec/features/merge_requests/user_exports_as_csv_spec.rb
View file @
885f3a75
...
...
@@ -12,15 +12,9 @@ RSpec.describe 'Merge Requests > Exports as CSV', :js do
visit
(
project_merge_requests_path
(
project
))
end
subject
{
page
.
find
(
'.nav-controls'
)
}
it
{
is_expected
.
to
have_selector
'[data-testid="export-csv-button"]'
}
context
'button is clicked'
do
before
do
page
.
within
(
'.nav-controls'
)
do
find
(
'[data-testid="export-csv-button"]'
).
click
end
click_button
'Export as CSV'
end
it
'shows a success message'
do
...
...
spec/frontend/issuable/components/csv_export_modal_spec.js
View file @
885f3a75
import
{
GlModal
,
GlIcon
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
stubComponent
}
from
'
helpers/stub_component
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
CsvExportModal
from
'
~/issuable/components/csv_export_modal.vue
'
;
describe
(
'
CsvExportModal
'
,
()
=>
{
...
...
@@ -9,26 +8,24 @@ describe('CsvExportModal', () => {
function
createComponent
(
options
=
{})
{
const
{
injectedProperties
=
{},
props
=
{}
}
=
options
;
return
extendedWrapper
(
mount
(
CsvExportModal
,
{
propsData
:
{
modalId
:
'
csv-export-modal
'
,
exportCsvPath
:
'
export/csv/path
'
,
issuableCount
:
1
,
...
props
,
},
provide
:
{
issuableType
:
'
issues
'
,
...
injectedProperties
,
},
stubs
:
{
GlModal
:
stubComponent
(
GlModal
,
{
template
:
'
<div><slot name="modal-title"></slot><slot></slot><slot name="modal-footer"></slot></div>
'
,
}),
},
}),
);
return
mount
(
CsvExportModal
,
{
propsData
:
{
modalId
:
'
csv-export-modal
'
,
exportCsvPath
:
'
export/csv/path
'
,
issuableCount
:
1
,
...
props
,
},
provide
:
{
issuableType
:
'
issues
'
,
...
injectedProperties
,
},
stubs
:
{
GlModal
:
stubComponent
(
GlModal
,
{
template
:
'
<div><slot name="modal-title"></slot><slot></slot><slot name="modal-footer"></slot></div>
'
,
}),
},
});
}
afterEach
(()
=>
{
...
...
@@ -61,14 +58,13 @@ describe('CsvExportModal', () => {
describe
(
'
issuable count info text
'
,
()
=>
{
it
(
'
displays the info text when issuableCount is > -1
'
,
()
=>
{
wrapper
=
createComponent
({
props
:
{
issuableCount
:
10
}
});
expect
(
wrapper
.
findByTestId
(
'
issuable-count-note
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
findByTestId
(
'
issuable-count-note
'
).
text
()).
toContain
(
'
10 issues selected
'
);
expect
(
wrapper
.
text
()).
toContain
(
'
10 issues selected
'
);
expect
(
findIcon
().
exists
()).
toBe
(
true
);
});
it
(
"
doesn't display the info text when issuableCount is -1
"
,
()
=>
{
wrapper
=
createComponent
({
props
:
{
issuableCount
:
-
1
}
});
expect
(
wrapper
.
findByTestId
(
'
issuable-count-note
'
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
text
()).
not
.
toContain
(
'
issues selected
'
);
});
});
...
...
spec/frontend/issuable/components/csv_import_export_buttons_spec.js
View file @
885f3a75
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlButton
,
GlDropdown
}
from
'
@gitlab/ui
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
mountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
CsvExportModal
from
'
~/issuable/components/csv_export_modal.vue
'
;
import
CsvImportExportButtons
from
'
~/issuable/components/csv_import_export_buttons.vue
'
;
import
CsvImportModal
from
'
~/issuable/components/csv_import_modal.vue
'
;
...
...
@@ -14,35 +14,33 @@ describe('CsvImportExportButtons', () => {
function
createComponent
(
injectedProperties
=
{})
{
glModalDirective
=
jest
.
fn
();
return
extendedWrapper
(
shallowMount
(
CsvImportExportButtons
,
{
directives
:
{
GlTooltip
:
createMockDirective
(),
glModal
:
{
bind
(
_
,
{
value
})
{
glModalDirective
(
value
);
},
return
mountExtended
(
CsvImportExportButtons
,
{
directives
:
{
GlTooltip
:
createMockDirective
(),
glModal
:
{
bind
(
_
,
{
value
})
{
glModalDirective
(
value
);
},
},
provide
:
{
...
injectedProperties
,
}
,
propsData
:
{
exportCsvPath
,
issuableCount
,
}
,
}
)
,
);
},
provide
:
{
...
injectedProperties
,
},
propsData
:
{
exportCsvPath
,
issuableCount
,
},
}
);
}
afterEach
(()
=>
{
wrapper
.
destroy
();
});
const
findExportCsvButton
=
()
=>
wrapper
.
find
ByTestId
(
'
export-csv-button
'
);
const
findImportDropdown
=
()
=>
wrapper
.
find
ByTestId
(
'
import-csv-dropdown
'
);
const
findImportCsvButton
=
()
=>
wrapper
.
findBy
TestId
(
'
import-csv-dropdown
'
);
const
findImportFromJiraLink
=
()
=>
wrapper
.
findBy
TestId
(
'
import-from-jira-link
'
);
const
findExportCsvButton
=
()
=>
wrapper
.
find
Component
(
GlButton
);
const
findImportDropdown
=
()
=>
wrapper
.
find
Component
(
GlDropdown
);
const
findImportCsvButton
=
()
=>
wrapper
.
findBy
Role
(
'
menuitem
'
,
{
name
:
'
Import CSV
'
}
);
const
findImportFromJiraLink
=
()
=>
wrapper
.
findBy
Role
(
'
menuitem
'
,
{
name
:
'
Import from Jira
'
}
);
const
findExportCsvModal
=
()
=>
wrapper
.
findComponent
(
CsvExportModal
);
const
findImportCsvModal
=
()
=>
wrapper
.
findComponent
(
CsvImportModal
);
...
...
@@ -97,7 +95,7 @@ describe('CsvImportExportButtons', () => {
expect
(
findImportDropdown
().
exists
()).
toBe
(
true
);
});
it
(
'
renders the import
button
'
,
()
=>
{
it
(
'
renders the import
csv menu item
'
,
()
=>
{
expect
(
findImportCsvButton
().
exists
()).
toBe
(
true
);
});
...
...
@@ -106,8 +104,11 @@ describe('CsvImportExportButtons', () => {
wrapper
=
createComponent
({
showImportButton
:
true
,
showLabel
:
false
});
});
it
(
'
does not have a button text
'
,
()
=>
{
expect
(
findImportCsvButton
().
props
(
'
text
'
)).
toBe
(
null
);
it
(
'
hides button text
'
,
()
=>
{
expect
(
findImportDropdown
().
props
()).
toMatchObject
({
text
:
'
Import issues
'
,
textSrOnly
:
true
,
});
});
it
(
'
import button has a tooltip
'
,
()
=>
{
...
...
@@ -124,7 +125,10 @@ describe('CsvImportExportButtons', () => {
});
it
(
'
displays a button text
'
,
()
=>
{
expect
(
findImportCsvButton
().
props
(
'
text
'
)).
toBe
(
'
Import issues
'
);
expect
(
findImportDropdown
().
props
()).
toMatchObject
({
text
:
'
Import issues
'
,
textSrOnly
:
false
,
});
});
it
(
'
import button has no tooltip
'
,
()
=>
{
...
...
spec/frontend/issuable/components/csv_import_modal_spec.js
View file @
885f3a75
import
{
GlModal
}
from
'
@gitlab/ui
'
;
import
{
getByRole
,
getByLabelText
}
from
'
@testing-library/dom
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
GlButton
,
GlModal
}
from
'
@gitlab/ui
'
;
import
{
stubComponent
}
from
'
helpers/stub_component
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
mountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
CsvImportModal
from
'
~/issuable/components/csv_import_modal.vue
'
;
jest
.
mock
(
'
~/lib/utils/csrf
'
,
()
=>
({
token
:
'
mock-csrf-token
'
}));
...
...
@@ -13,23 +11,21 @@ describe('CsvImportModal', () => {
function
createComponent
(
options
=
{})
{
const
{
injectedProperties
=
{},
props
=
{}
}
=
options
;
return
extendedWrapper
(
mount
(
CsvImportModal
,
{
propsData
:
{
modalId
:
'
csv-import-modal
'
,
...
props
,
},
provide
:
{
issuableType
:
'
issues
'
,
...
injectedProperties
,
},
stubs
:
{
GlModal
:
stubComponent
(
GlModal
,
{
template
:
'
<div><slot></slot><slot name="modal-footer"></slot></div>
'
,
}),
},
}),
);
return
mountExtended
(
CsvImportModal
,
{
propsData
:
{
modalId
:
'
csv-import-modal
'
,
...
props
,
},
provide
:
{
issuableType
:
'
issues
'
,
...
injectedProperties
,
},
stubs
:
{
GlModal
:
stubComponent
(
GlModal
,
{
template
:
'
<div><slot></slot><slot name="modal-footer"></slot></div>
'
,
}),
},
});
}
beforeEach
(()
=>
{
...
...
@@ -41,9 +37,9 @@ describe('CsvImportModal', () => {
});
const
findModal
=
()
=>
wrapper
.
findComponent
(
GlModal
);
const
findPrimaryButton
=
()
=>
getByRole
(
wrapper
.
element
,
'
button
'
,
{
name
:
'
Import issues
'
}
);
const
findForm
=
()
=>
wrapper
.
find
ByTestId
(
'
import-csv-
form
'
);
const
findFileInput
=
()
=>
getByLabelText
(
wrapper
.
element
,
'
Upload CSV file
'
);
const
findPrimaryButton
=
()
=>
wrapper
.
findComponent
(
GlButton
);
const
findForm
=
()
=>
wrapper
.
find
(
'
form
'
);
const
findFileInput
=
()
=>
wrapper
.
findByLabelText
(
'
Upload CSV file
'
);
const
findAuthenticityToken
=
()
=>
new
FormData
(
findForm
().
element
).
get
(
'
authenticity_token
'
);
describe
(
'
template
'
,
()
=>
{
...
...
@@ -76,8 +72,8 @@ describe('CsvImportModal', () => {
expect
(
findPrimaryButton
()).
toExist
();
});
it
(
'
submits the form when the primary action is clicked
'
,
async
()
=>
{
findPrimaryButton
().
click
(
);
it
(
'
submits the form when the primary action is clicked
'
,
()
=>
{
findPrimaryButton
().
trigger
(
'
click
'
);
expect
(
formSubmitSpy
).
toHaveBeenCalled
();
});
...
...
spec/frontend/issuable/components/issuable_by_email_spec.js
View file @
885f3a75
...
...
@@ -58,10 +58,11 @@ describe('IssuableByEmail', () => {
mockAxios
.
restore
();
});
const
findFormInputGroup
=
()
=>
wrapper
.
find
(
GlFormInputGroup
);
const
findButton
=
()
=>
wrapper
.
findComponent
(
GlButton
);
const
findFormInputGroup
=
()
=>
wrapper
.
findComponent
(
GlFormInputGroup
);
const
clickResetEmail
=
async
()
=>
{
wrapper
.
find
ByTestId
(
'
incoming-email-token-reset
'
).
vm
.
$emit
(
'
click
'
);
wrapper
.
find
AllComponents
(
GlButton
).
at
(
2
).
trigger
(
'
click
'
);
await
waitForPromises
();
};
...
...
@@ -75,14 +76,14 @@ describe('IssuableByEmail', () => {
'
renders a link with "$buttonText" when type is "$issuableType"
'
,
({
issuableType
,
buttonText
})
=>
{
wrapper
=
createComponent
({
issuableType
});
expect
(
wrapper
.
findByTestId
(
'
issuable-email-modal-btn
'
).
text
()).
toBe
(
buttonText
);
expect
(
findButton
(
).
text
()).
toBe
(
buttonText
);
},
);
it
(
'
opens the modal when the user clicks the button
'
,
()
=>
{
wrapper
=
createComponent
();
wrapper
.
findByTestId
(
'
issuable-email-modal-btn
'
).
vm
.
$emit
(
'
click
'
);
findButton
().
trigger
(
'
click
'
);
expect
(
glModalDirective
).
toHaveBeenCalled
();
});
...
...
@@ -105,7 +106,7 @@ describe('IssuableByEmail', () => {
initialEmail
,
});
expect
(
wrapper
.
find
ByTestId
(
'
mail-to-btn
'
).
attributes
(
'
href
'
)).
toBe
(
expect
(
wrapper
.
find
AllComponents
(
GlButton
).
at
(
1
).
attributes
(
'
href
'
)).
toBe
(
`mailto:
${
initialEmail
}
?subject=
${
subject
}
&body=
${
body
}
`
,
);
});
...
...
spec/frontend/issuable/components/status_box_spec.js
View file @
885f3a75
import
{
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
Gl
Icon
,
Gl
Sprintf
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
StatusBox
from
'
~/issuable/components/status_box.vue
'
;
...
...
@@ -64,7 +64,7 @@ describe('Merge request status box component', () => {
initialState
:
testCase
.
state
,
});
expect
(
wrapper
.
find
(
'
[data-testid="status-icon"]
'
).
props
(
'
name
'
)).
toBe
(
testCase
.
icon
);
expect
(
wrapper
.
find
Component
(
GlIcon
).
props
(
'
name
'
)).
toBe
(
testCase
.
icon
);
});
});
});
...
...
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