2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2016-11-03 12:29:30 +05:30
2023-03-04 22:38:38 +05:30
RSpec . describe 'New/edit issue' , :js , feature_category : :team_planning do
2017-08-17 22:00:37 +05:30
include ActionView :: Helpers :: JavaScriptHelper
2023-06-20 00:43:36 +05:30
include ListboxHelpers
2017-08-17 22:00:37 +05:30
2022-05-07 20:08:51 +05:30
let_it_be ( :project ) { create ( :project , :repository ) }
2021-12-11 22:18:48 +05:30
let_it_be ( :user ) { create ( :user ) }
let_it_be ( :user2 ) { create ( :user ) }
2022-05-07 20:08:51 +05:30
let_it_be ( :guest ) { create ( :user ) }
2021-10-27 15:23:28 +05:30
let_it_be ( :milestone ) { create ( :milestone , project : project ) }
let_it_be ( :label ) { create ( :label , project : project ) }
let_it_be ( :label2 ) { create ( :label , project : project ) }
let_it_be ( :issue ) { create ( :issue , project : project , assignees : [ user ] , milestone : milestone ) }
2023-05-27 22:25:52 +05:30
let_it_be ( :issue2 ) { create ( :issue , project : project , assignees : [ user ] , milestone : milestone ) }
2022-05-07 20:08:51 +05:30
let_it_be ( :confidential_issue ) { create ( :issue , project : project , assignees : [ user ] , milestone : milestone , confidential : true ) }
2016-11-03 12:29:30 +05:30
2021-12-11 22:18:48 +05:30
let ( :current_user ) { user }
2023-07-09 08:55:56 +05:30
let ( :visible_label_selection_on_metadata ) { false }
2019-07-31 22:56:46 +05:30
2021-12-11 22:18:48 +05:30
before_all do
2018-11-18 11:00:15 +05:30
project . add_maintainer ( user )
project . add_maintainer ( user2 )
2022-05-07 20:08:51 +05:30
project . add_guest ( guest )
2016-11-03 12:29:30 +05:30
end
2021-12-11 22:18:48 +05:30
before do
stub_licensed_features ( multiple_issue_assignees : false , issue_weights : false )
2023-07-09 08:55:56 +05:30
stub_feature_flags ( visible_label_selection_on_metadata : visible_label_selection_on_metadata )
2021-12-11 22:18:48 +05:30
sign_in ( current_user )
end
describe 'new issue' do
2016-11-03 12:29:30 +05:30
before do
2017-09-10 17:25:29 +05:30
visit new_project_issue_path ( project )
2016-11-03 12:29:30 +05:30
end
2017-08-17 22:00:37 +05:30
describe 'shorten users API pagination limit' do
before do
2017-09-10 17:25:29 +05:30
# Using `allow_any_instance_of`/`and_wrap_original`, `original` would
# somehow refer to the very block we defined to _wrap_ that method, instead of
2019-02-15 15:39:39 +05:30
# the original method, resulting in infinite recursion when called.
2017-09-10 17:25:29 +05:30
# This is likely a bug with helper modules included into dynamically generated view classes.
# To work around this, we have to hold on to and call to the original implementation manually.
2019-07-31 22:56:46 +05:30
original_issue_dropdown_options = FormHelper . instance_method ( :assignees_dropdown_options )
allow_any_instance_of ( FormHelper ) . to receive ( :assignees_dropdown_options ) . and_wrap_original do | original , * args |
2023-03-04 22:38:38 +05:30
options = original_issue_dropdown_options . bind_call ( original . receiver , * args )
2017-09-10 17:25:29 +05:30
options [ :data ] [ :per_page ] = 2
2017-08-17 22:00:37 +05:30
options
end
2017-09-10 17:25:29 +05:30
visit new_project_issue_path ( project )
2017-08-17 22:00:37 +05:30
click_button 'Unassigned'
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
end
2019-07-07 11:18:12 +05:30
it 'displays selected users even if they are not part of the original API call' do
2017-08-17 22:00:37 +05:30
find ( '.dropdown-input-field' ) . native . send_keys user2 . name
page . within '.dropdown-menu-user' do
expect ( page ) . to have_content user2 . name
click_link user2 . name
end
2017-09-10 17:25:29 +05:30
find ( '.js-assignee-search' ) . click
2017-08-17 22:00:37 +05:30
find ( '.js-dropdown-input-clear' ) . click
page . within '.dropdown-menu-user' do
expect ( page ) . to have_content user . name
expect ( find ( '.dropdown-menu-user a.is-active' ) . first ( :xpath , '..' ) [ 'data-user-id' ] ) . to eq ( user2 . id . to_s )
end
end
end
describe 'single assignee' do
before do
click_button 'Unassigned'
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
end
it 'unselects other assignees when unassigned is selected' do
page . within '.dropdown-menu-user' do
click_link user2 . name
end
click_button user2 . name
page . within '.dropdown-menu-user' do
click_link 'Unassigned'
end
expect ( find ( 'input[name="issue[assignee_ids][]"]' , visible : false ) . value ) . to match ( '0' )
end
it 'toggles assign to me when current user is selected and unselected' do
page . within '.dropdown-menu-user' do
click_link user . name
end
expect ( find ( 'a' , text : 'Assign to me' , visible : false ) ) . not_to be_visible
click_button user . name
page . within ( '.dropdown-menu-user' ) do
click_link user . name
end
expect ( page . find ( '.dropdown-menu-user' , visible : false ) ) . not_to be_visible
end
end
2023-07-09 08:55:56 +05:30
context 'with the visible_label_selection_on_metadata feature flag enabled' do
let ( :visible_label_selection_on_metadata ) { true }
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
it 'allows user to create new issue' do
fill_in 'issue_title' , with : 'title'
fill_in 'issue_description' , with : 'title'
2017-09-10 17:25:29 +05:30
2023-07-09 08:55:56 +05:30
expect ( find ( 'a' , text : 'Assign to me' ) ) . to be_visible
click_button 'Unassigned'
2017-09-10 17:25:29 +05:30
2023-07-09 08:55:56 +05:30
wait_for_requests
page . within '.dropdown-menu-user' do
click_link user2 . name
end
expect ( find ( 'input[name="issue[assignee_ids][]"]' , visible : false ) . value ) . to match ( user2 . id . to_s )
page . within '.js-assignee-search' do
expect ( page ) . to have_content user2 . name
end
expect ( find ( 'a' , text : 'Assign to me' ) ) . to be_visible
click_link 'Assign to me'
assignee_ids = page . all ( 'input[name="issue[assignee_ids][]"]' , visible : false )
expect ( assignee_ids [ 0 ] . value ) . to match ( user . id . to_s )
page . within '.js-assignee-search' do
expect ( page ) . to have_content user . name
end
expect ( find ( 'a' , text : 'Assign to me' , visible : false ) ) . not_to be_visible
click_button 'Select milestone'
click_button milestone . title
expect ( find ( 'input[name="issue[milestone_id]"]' , visible : false ) . value ) . to match ( milestone . id . to_s )
expect ( page ) . to have_button milestone . title
click_button _ ( 'Select label' )
wait_for_all_requests
page . within '[data-testid="sidebar-labels"]' do
click_button label . title
click_button label2 . title
click_button _ ( 'Close' )
wait_for_requests
page . within ( '[data-testid="embedded-labels-list"]' ) do
expect ( page ) . to have_content ( label . title )
expect ( page ) . to have_content ( label2 . title )
end
end
click_button 'Create issue'
2017-08-17 22:00:37 +05:30
2023-07-09 08:55:56 +05:30
page . within '.issuable-sidebar' do
page . within '.assignee' do
expect ( page ) . to have_content " Assignee "
end
2017-08-17 22:00:37 +05:30
2023-07-09 08:55:56 +05:30
page . within '.milestone' do
expect ( page ) . to have_content milestone . title
end
2017-08-17 22:00:37 +05:30
2023-07-09 08:55:56 +05:30
page . within '.labels' do
expect ( page ) . to have_content label . title
expect ( page ) . to have_content label2 . title
end
end
page . within '.breadcrumbs' do
issue = Issue . find_by ( title : 'title' )
expect ( page ) . to have_text ( " Issues #{ issue . to_reference } " )
end
2016-11-03 12:29:30 +05:30
end
2023-07-09 08:55:56 +05:30
it 'correctly updates the dropdown toggle when removing a label' do
click_button _ ( 'Select label' )
wait_for_all_requests
page . within '[data-testid="sidebar-labels"]' do
click_button label . title
click_button _ ( 'Close' )
wait_for_requests
page . within ( '[data-testid="embedded-labels-list"]' ) do
expect ( page ) . to have_content ( label . title )
end
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
expect ( page . find ( '.gl-dropdown-button-text' ) ) . to have_content ( label . title )
end
click_button label . title , class : 'gl-dropdown-toggle'
wait_for_all_requests
page . within '[data-testid="sidebar-labels"]' do
click_button label . title , class : 'dropdown-item'
click_button _ ( 'Close' )
wait_for_requests
expect ( page ) . not_to have_selector ( '[data-testid="embedded-labels-list"]' )
expect ( page . find ( '.gl-dropdown-button-text' ) ) . to have_content ( _ ( 'Select label' ) )
end
2016-11-03 12:29:30 +05:30
end
2018-11-08 19:23:39 +05:30
2023-07-09 08:55:56 +05:30
it 'clears label search input field when a label is selected' , :js do
click_button _ ( 'Select label' )
wait_for_all_requests
2018-11-08 19:23:39 +05:30
2023-07-09 08:55:56 +05:30
page . within '[data-testid="sidebar-labels"]' do
search_field = find ( 'input[type="search"]' )
search_field . native . send_keys ( label . title )
expect ( page ) . to have_css ( '.gl-search-box-by-type-clear' )
click_button label . title , class : 'dropdown-item'
expect ( page ) . not_to have_css ( '.gl-search-box-by-type-clear' )
expect ( search_field . value ) . to eq ''
end
2016-11-03 12:29:30 +05:30
end
2023-07-09 08:55:56 +05:30
end
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
context 'with the visible_label_selection_on_metadata feature flag disabled' do
let ( :visible_label_selection_on_metadata ) { false }
it 'allows user to create new issue' do
fill_in 'issue_title' , with : 'title'
fill_in 'issue_description' , with : 'title'
expect ( find ( 'a' , text : 'Assign to me' ) ) . to be_visible
click_button 'Unassigned'
wait_for_requests
page . within '.dropdown-menu-user' do
click_link user2 . name
end
expect ( find ( 'input[name="issue[assignee_ids][]"]' , visible : false ) . value ) . to match ( user2 . id . to_s )
page . within '.js-assignee-search' do
expect ( page ) . to have_content user2 . name
end
expect ( find ( 'a' , text : 'Assign to me' ) ) . to be_visible
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
click_link 'Assign to me'
assignee_ids = page . all ( 'input[name="issue[assignee_ids][]"]' , visible : false )
expect ( assignee_ids [ 0 ] . value ) . to match ( user . id . to_s )
page . within '.js-assignee-search' do
expect ( page ) . to have_content user . name
2016-11-03 12:29:30 +05:30
end
2023-07-09 08:55:56 +05:30
expect ( find ( 'a' , text : 'Assign to me' , visible : false ) ) . not_to be_visible
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
click_button 'Select milestone'
click_button milestone . title
expect ( find ( 'input[name="issue[milestone_id]"]' , visible : false ) . value ) . to match ( milestone . id . to_s )
expect ( page ) . to have_button milestone . title
click_button 'Labels'
page . within '.dropdown-menu-labels' do
click_link label . title
click_link label2 . title
2016-11-03 12:29:30 +05:30
end
2023-07-09 08:55:56 +05:30
find ( '.js-issuable-form-dropdown.js-label-select' ) . click
page . within '.js-label-select' do
2016-11-03 12:29:30 +05:30
expect ( page ) . to have_content label . title
end
2023-07-09 08:55:56 +05:30
expect ( page . all ( 'input[name="issue[label_ids][]"]' , visible : false ) [ 1 ] . value ) . to match ( label . id . to_s )
expect ( page . all ( 'input[name="issue[label_ids][]"]' , visible : false ) [ 2 ] . value ) . to match ( label2 . id . to_s )
2017-08-17 22:00:37 +05:30
2023-07-09 08:55:56 +05:30
click_button 'Create issue'
2017-08-17 22:00:37 +05:30
2023-07-09 08:55:56 +05:30
page . within '.issuable-sidebar' do
page . within '.assignee' do
expect ( page ) . to have_content " Assignee "
end
2017-08-17 22:00:37 +05:30
2023-07-09 08:55:56 +05:30
page . within '.milestone' do
expect ( page ) . to have_content milestone . title
end
2022-05-07 20:08:51 +05:30
2023-07-09 08:55:56 +05:30
page . within '.labels' do
expect ( page ) . to have_content label . title
expect ( page ) . to have_content label2 . title
end
end
2022-05-07 20:08:51 +05:30
2023-07-09 08:55:56 +05:30
page . within '.breadcrumbs' do
issue = Issue . find_by ( title : 'title' )
2017-08-17 22:00:37 +05:30
2023-07-09 08:55:56 +05:30
expect ( page ) . to have_text ( " Issues #{ issue . to_reference } " )
end
2017-08-17 22:00:37 +05:30
end
2023-07-09 08:55:56 +05:30
it 'correctly updates the dropdown toggle when removing a label' do
click_button 'Labels'
page . within '.dropdown-menu-labels' do
click_link label . title
end
2017-08-17 22:00:37 +05:30
2023-07-09 08:55:56 +05:30
expect ( find ( '.js-label-select' ) ) . to have_content ( label . title )
page . within '.dropdown-menu-labels' do
click_link label . title
end
expect ( find ( '.js-label-select' ) ) . to have_content ( 'Labels' )
2017-08-17 22:00:37 +05:30
end
2023-07-09 08:55:56 +05:30
it 'clears label search input field when a label is selected' do
click_button 'Labels'
2017-08-17 22:00:37 +05:30
2023-07-09 08:55:56 +05:30
page . within '.dropdown-menu-labels' do
search_field = find ( 'input[type="search"]' )
search_field . set ( label2 . title )
click_link label2 . title
expect ( search_field . value ) . to eq ''
end
end
end
2018-03-27 19:54:05 +05:30
2023-07-09 08:55:56 +05:30
it 'displays an error message when submitting an invalid form' do
click_button 'Create issue'
2018-03-27 19:54:05 +05:30
2023-07-09 08:55:56 +05:30
page . within ( '[data-testid="issue-title-input-field"]' ) do
expect ( page ) . to have_text ( _ ( 'This field is required.' ) )
2018-03-27 19:54:05 +05:30
end
end
2017-08-17 22:00:37 +05:30
it 'correctly updates the selected user when changing assignee' do
click_button 'Unassigned'
2017-09-10 17:25:29 +05:30
wait_for_requests
2017-08-17 22:00:37 +05:30
page . within '.dropdown-menu-user' do
click_link user . name
end
expect ( find ( '.js-assignee-search' ) ) . to have_content ( user . name )
click_button user . name
page . within '.dropdown-menu-user' do
click_link user2 . name
end
expect ( find ( '.js-assignee-search' ) ) . to have_content ( user2 . name )
2016-11-03 12:29:30 +05:30
end
2017-09-10 17:25:29 +05:30
it 'description has autocomplete' do
find ( '#issue_description' ) . native . send_keys ( '' )
fill_in 'issue_description' , with : '@'
expect ( page ) . to have_selector ( '.atwho-view' )
end
2018-04-05 14:03:07 +05:30
2021-10-27 15:23:28 +05:30
describe 'displays issue type options in the dropdown' do
2021-12-11 22:18:48 +05:30
shared_examples 'type option is visible' do | label : , identifier : |
it " shows #{ identifier } option " , :aggregate_failures do
2023-06-20 00:43:36 +05:30
wait_for_requests
expect_listbox_item ( label )
2021-12-11 22:18:48 +05:30
end
end
shared_examples 'type option is missing' do | label : , identifier : |
it " does not show #{ identifier } option " , :aggregate_failures do
2023-06-20 00:43:36 +05:30
wait_for_requests
expect_no_listbox_item ( label )
2021-12-11 22:18:48 +05:30
end
end
2021-10-27 15:23:28 +05:30
before do
page . within ( '.issue-form' ) do
click_button 'Issue'
end
end
2021-12-11 22:18:48 +05:30
context 'when user is guest' do
let_it_be ( :guest ) { create ( :user ) }
let ( :current_user ) { guest }
before_all do
project . add_guest ( guest )
2021-10-27 15:23:28 +05:30
end
2021-12-11 22:18:48 +05:30
it_behaves_like 'type option is visible' , label : 'Issue' , identifier : :issue
it_behaves_like 'type option is missing' , label : 'Incident' , identifier : :incident
2021-10-27 15:23:28 +05:30
end
2021-12-11 22:18:48 +05:30
context 'when user is reporter' do
let_it_be ( :reporter ) { create ( :user ) }
let ( :current_user ) { reporter }
before_all do
project . add_reporter ( reporter )
2021-10-27 15:23:28 +05:30
end
2021-12-11 22:18:48 +05:30
it_behaves_like 'type option is visible' , label : 'Issue' , identifier : :issue
it_behaves_like 'type option is visible' , label : 'Incident' , identifier : :incident
2021-10-27 15:23:28 +05:30
end
end
2018-04-05 14:03:07 +05:30
describe 'milestone' do
2021-12-11 22:18:48 +05:30
let! ( :milestone ) do
create ( :milestone , title : '"><img src=x onerror=alert(document.domain)>' , project : project )
end
2018-04-05 14:03:07 +05:30
it 'escapes milestone' do
2023-01-13 00:05:48 +05:30
click_button 'Select milestone'
click_button milestone . title
2018-04-05 14:03:07 +05:30
page . within '.issue-milestone' do
2023-01-13 00:05:48 +05:30
expect ( page ) . to have_button milestone . title
2018-04-05 14:03:07 +05:30
expect ( page ) . not_to have_selector 'img'
end
end
end
2022-08-27 11:52:29 +05:30
describe 'when repository contains CONTRIBUTING.md' do
it 'has contribution guidelines prompt' do
text = _ ( 'Please review the %{linkStart}contribution guidelines%{linkEnd} for this project.' ) % { linkStart : nil , linkEnd : nil }
expect ( find ( '#new_issue' ) ) . to have_text ( text )
end
end
2016-11-03 12:29:30 +05:30
end
2022-05-07 20:08:51 +05:30
describe 'new issue with query parameters' do
before do
project . repository . create_file (
current_user ,
'.gitlab/issue_templates/test_template.md' ,
'description from template' ,
message : 'Add test_template.md' ,
branch_name : project . default_branch_or_main
)
end
after do
project . repository . delete_file (
current_user ,
'.gitlab/issue_templates/test_template.md' ,
message : 'Remove test_template.md' ,
branch_name : project . default_branch_or_main
)
end
it 'leaves the description blank if no query parameters are specified' do
visit new_project_issue_path ( project )
expect ( find ( '#issue_description' ) . value ) . to be_empty
end
it 'fills the description from the issue[description] query parameter' do
visit new_project_issue_path ( project , issue : { description : 'description from query parameter' } )
expect ( find ( '#issue_description' ) . value ) . to match ( 'description from query parameter' )
end
2023-04-23 21:23:45 +05:30
it 'fills the description from the issuable_template query parameter' , quarantine : 'https://gitlab.com/gitlab-org/gitlab/-/issues/388728' do
2022-05-07 20:08:51 +05:30
visit new_project_issue_path ( project , issuable_template : 'test_template' )
wait_for_requests
expect ( find ( '#issue_description' ) . value ) . to match ( 'description from template' )
end
2023-04-23 21:23:45 +05:30
it 'fills the description from the issuable_template and issue[description] query parameters' , quarantine : 'https://gitlab.com/gitlab-org/gitlab/-/issues/388728' do
2022-05-07 20:08:51 +05:30
visit new_project_issue_path ( project , issuable_template : 'test_template' , issue : { description : 'description from query parameter' } )
wait_for_requests
expect ( find ( '#issue_description' ) . value ) . to match ( 'description from template\ndescription from query parameter' )
end
end
describe 'new issue from related issue' do
it 'does not offer to link the new issue to any other issues if the URL parameter is absent' do
visit new_project_issue_path ( project )
expect ( page ) . not_to have_selector '#add_related_issue'
expect ( page ) . not_to have_text " Relate to "
end
context 'guest' do
let ( :current_user ) { guest }
it 'does not offer to link the new issue to an issue that the user does not have access to' do
visit new_project_issue_path ( project , { add_related_issue : confidential_issue . iid } )
expect ( page ) . not_to have_selector '#add_related_issue'
expect ( page ) . not_to have_text " Relate to "
end
end
it 'links the new issue and the issue of origin' do
visit new_project_issue_path ( project , { add_related_issue : issue . iid } )
expect ( page ) . to have_selector '#add_related_issue'
expect ( page ) . to have_text " Relate to issue \# #{ issue . iid } "
expect ( page ) . to have_text 'Adds this issue as related to the issue it was created from'
fill_in 'issue_title' , with : 'title'
click_button 'Create issue'
page . within '#related-issues' do
expect ( page ) . to have_text " \# #{ issue . iid } "
end
end
it 'links the new incident and the incident of origin' do
incident = create ( :incident , project : project )
visit new_project_issue_path ( project , { add_related_issue : incident . iid } )
expect ( page ) . to have_selector '#add_related_issue'
expect ( page ) . to have_text " Relate to incident \# #{ incident . iid } "
expect ( page ) . to have_text 'Adds this incident as related to the incident it was created from'
fill_in 'issue_title' , with : 'title'
click_button 'Create issue'
page . within '#related-issues' do
expect ( page ) . to have_text " \# #{ incident . iid } "
end
end
it 'does not link the new issue to any other issues if the checkbox is not checked' do
visit new_project_issue_path ( project , { add_related_issue : issue . iid } )
expect ( page ) . to have_selector '#add_related_issue'
expect ( page ) . to have_text " Relate to issue \# #{ issue . iid } "
uncheck " Relate to issue \# #{ issue . iid } "
fill_in 'issue_title' , with : 'title'
click_button 'Create issue'
page . within '#related-issues' do
expect ( page ) . not_to have_text " \# #{ issue . iid } "
end
end
end
2021-12-11 22:18:48 +05:30
describe 'edit issue' do
2016-11-03 12:29:30 +05:30
before do
2017-09-10 17:25:29 +05:30
visit edit_project_issue_path ( project , issue )
2016-11-03 12:29:30 +05:30
end
2023-07-09 08:55:56 +05:30
context 'with the visible_label_selection_on_metadata feature flag enabled' do
let ( :visible_label_selection_on_metadata ) { true }
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
it 'allows user to update issue' do
expect ( find ( 'input[name="issue[assignee_ids][]"]' , visible : false ) . value ) . to match ( user . id . to_s )
expect ( find ( 'input[name="issue[milestone_id]"]' , visible : false ) . value ) . to match ( milestone . id . to_s )
expect ( find ( 'a' , text : 'Assign to me' , visible : false ) ) . not_to be_visible
page . within '.js-user-search' do
expect ( page ) . to have_content user . name
end
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
expect ( page ) . to have_button milestone . title
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
click_button _ ( 'Select label' )
wait_for_all_requests
page . within '[data-testid="sidebar-labels"]' do
click_button label . title
click_button label2 . title
click_button _ ( 'Close' )
wait_for_requests
page . within ( '[data-testid="embedded-labels-list"]' ) do
expect ( page ) . to have_content ( label . title )
expect ( page ) . to have_content ( label2 . title )
end
end
expect ( page . all ( 'input[name="issue[label_ids][]"]' , visible : false )
. map ( & :value ) )
. to contain_exactly ( label . id . to_s , label2 . id . to_s )
click_button 'Save changes'
page . within '.issuable-sidebar' do
page . within '.assignee' do
expect ( page ) . to have_content user . name
end
page . within '.milestone' do
expect ( page ) . to have_content milestone . title
end
page . within '.labels' do
expect ( page ) . to have_content label . title
expect ( page ) . to have_content label2 . title
end
end
2016-11-03 12:29:30 +05:30
end
2023-07-09 08:55:56 +05:30
end
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
context 'with the visible_label_selection_on_metadata feature flag disabled' do
let ( :visible_label_selection_on_metadata ) { false }
it 'allows user to update issue' do
expect ( find ( 'input[name="issue[assignee_ids][]"]' , visible : false ) . value ) . to match ( user . id . to_s )
expect ( find ( 'input[name="issue[milestone_id]"]' , visible : false ) . value ) . to match ( milestone . id . to_s )
expect ( find ( 'a' , text : 'Assign to me' , visible : false ) ) . not_to be_visible
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
page . within '.js-user-search' do
2016-11-03 12:29:30 +05:30
expect ( page ) . to have_content user . name
end
2023-07-09 08:55:56 +05:30
expect ( page ) . to have_button milestone . title
2016-11-03 12:29:30 +05:30
2023-07-09 08:55:56 +05:30
click_button 'Labels'
page . within '.dropdown-menu-labels' do
click_link label . title
click_link label2 . title
end
page . within '.js-label-select' do
2016-11-03 12:29:30 +05:30
expect ( page ) . to have_content label . title
2023-07-09 08:55:56 +05:30
end
expect ( page . all ( 'input[name="issue[label_ids][]"]' , visible : false ) [ 1 ] . value ) . to match ( label . id . to_s )
expect ( page . all ( 'input[name="issue[label_ids][]"]' , visible : false ) [ 2 ] . value ) . to match ( label2 . id . to_s )
click_button 'Save changes'
page . within '.issuable-sidebar' do
page . within '.assignee' do
expect ( page ) . to have_content user . name
end
page . within '.milestone' do
expect ( page ) . to have_content milestone . title
end
page . within '.labels' do
expect ( page ) . to have_content label . title
expect ( page ) . to have_content label2 . title
end
2016-11-03 12:29:30 +05:30
end
end
end
2017-09-10 17:25:29 +05:30
it 'description has autocomplete' do
find ( '#issue_description' ) . native . send_keys ( '' )
fill_in 'issue_description' , with : '@'
expect ( page ) . to have_selector ( '.atwho-view' )
end
end
2021-12-11 22:18:48 +05:30
describe 'inline edit' do
2023-05-27 22:25:52 +05:30
context 'within issue 1' do
before do
visit project_issue_path ( project , issue )
wait_for_requests
end
it 'opens inline edit form with shortcut' do
find ( 'body' ) . send_keys ( 'e' )
expect ( page ) . to have_selector ( '.detail-page-description form' )
end
describe 'when user has made no changes' do
it 'let user leave the page without warnings' do
expected_content = 'Issue created'
expect ( page ) . to have_content ( expected_content )
find ( 'body' ) . send_keys ( 'e' )
click_link 'Boards'
expect ( page ) . not_to have_content ( expected_content )
end
end
describe 'when user has made changes' do
2023-06-20 00:43:36 +05:30
it 'shows a warning and can stay on page' , quarantine : 'https://gitlab.com/gitlab-org/gitlab/-/issues/397683' do
2023-05-27 22:25:52 +05:30
content = 'new issue content'
find ( 'body' ) . send_keys ( 'e' )
fill_in 'issue-description' , with : content
click_link 'Boards'
page . driver . browser . switch_to . alert . dismiss
click_button 'Save changes'
wait_for_requests
expect ( page ) . to have_content ( content )
end
end
2018-03-17 18:26:18 +05:30
end
2023-05-27 22:25:52 +05:30
context 'within issue 2' do
before do
visit project_issue_path ( project , issue2 )
wait_for_requests
end
describe 'when user has made changes' do
2023-07-09 08:55:56 +05:30
it 'shows a warning and can leave page' , quarantine : 'https://gitlab.com/gitlab-org/gitlab/-/issues/410497' do
2023-05-27 22:25:52 +05:30
content = 'new issue content'
find ( 'body' ) . send_keys ( 'e' )
fill_in 'issue-description' , with : content
click_link 'Boards'
2018-03-17 18:26:18 +05:30
2023-05-27 22:25:52 +05:30
page . driver . browser . switch_to . alert . accept
expect ( page ) . not_to have_content ( content )
end
end
2018-03-17 18:26:18 +05:30
end
end
2017-09-10 17:25:29 +05:30
describe 'sub-group project' do
let ( :group ) { create ( :group ) }
let ( :nested_group_1 ) { create ( :group , parent : group ) }
let ( :sub_group_project ) { create ( :project , group : nested_group_1 ) }
before do
2018-11-18 11:00:15 +05:30
sub_group_project . add_maintainer ( user )
2017-09-10 17:25:29 +05:30
visit new_project_issue_path ( sub_group_project )
end
2023-07-09 08:55:56 +05:30
context 'with the visible_label_selection_on_metadata feature flag enabled' , :js do
let ( :visible_label_selection_on_metadata ) { true }
2017-09-10 17:25:29 +05:30
2023-07-09 08:55:56 +05:30
it 'creates project label from dropdown' do
find ( '[data-testid="labels-select-dropdown-contents"] button' ) . click
2017-09-10 17:25:29 +05:30
2023-07-09 08:55:56 +05:30
wait_for_all_requests
2017-09-10 17:25:29 +05:30
2023-07-09 08:55:56 +05:30
page . within '[data-testid="sidebar-labels"]' do
click_button _ ( 'Create project label' )
2017-09-10 17:25:29 +05:30
2023-07-09 08:55:56 +05:30
wait_for_requests
end
page . within '.js-labels-create' do
find ( '[data-testid="label-title-input"]' ) . fill_in with : 'test label'
first ( '.suggest-colors-dropdown a' ) . click
click_button 'Create'
wait_for_all_requests
end
page . within '.js-labels-list' do
expect ( page ) . to have_button 'test label'
end
2017-09-10 17:25:29 +05:30
end
2023-07-09 08:55:56 +05:30
end
context 'with the visible_label_selection_on_metadata feature flag disabled' do
let ( :visible_label_selection_on_metadata ) { false }
2017-09-10 17:25:29 +05:30
2023-07-09 08:55:56 +05:30
it 'creates project label from dropdown' do
click_button 'Labels'
click_link 'Create project label'
page . within '.dropdown-new-label' do
fill_in 'new_label_name' , with : 'test label'
first ( '.suggest-colors-dropdown a' ) . click
click_button 'Create'
wait_for_requests
end
page . within '.dropdown-menu-labels' do
expect ( page ) . to have_link 'test label'
end
2017-09-10 17:25:29 +05:30
end
end
2016-11-03 12:29:30 +05:30
end
2017-08-17 22:00:37 +05:30
def before_for_selector ( selector )
js = <<-JS.strip_heredoc
( function ( selector ) {
var el = document . querySelector ( selector ) ;
return window . getComputedStyle ( el , '::before' ) . getPropertyValue ( 'content' ) ;
} ) ( " #{ escape_javascript ( selector ) } " )
JS
page . evaluate_script ( js )
end
2016-11-03 12:29:30 +05:30
end