Commit 5b502776 authored by Eulyeon Ko's avatar Eulyeon Ko Committed by Kushal Pandya

Use IterationCadenceID

Convert to use IterationCadenceID instead of ID.

Fix the typo in the spec filename.
parent a6cbb088
......@@ -2,6 +2,8 @@
// We are using gl-breadcrumb only at the last child of the handwritten breadcrumb
// until this gitlab-ui issue is resolved: https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1079
import { GlBreadcrumb, GlIcon, GlSkeletonLoader } from '@gitlab/ui';
import { TYPE_ITERATIONS_CADENCE } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import readCadence from '../queries/iteration_cadence.query.graphql';
const cadencePath = '/:cadenceId';
......@@ -22,7 +24,7 @@ export default {
variables() {
return {
fullPath: this.groupPath,
id: this.cadenceId,
id: convertToGraphQLId(TYPE_ITERATIONS_CADENCE, this.cadenceId),
};
},
result({ data: { group, errors }, error }) {
......
......@@ -168,7 +168,7 @@ export default {
variables() {
return {
fullPath: this.fullPath,
id: this.cadenceId,
cadenceId: convertToGraphQLId(TYPE_ITERATIONS_CADENCE, this.cadenceId),
};
},
result({ data: { group, errors }, error }) {
......
......@@ -158,7 +158,7 @@ export default {
query: readCadence,
variables: {
fullPath: this.fullPath,
id: this.cadenceId,
id: convertToGraphQLId(TYPE_ITERATIONS_CADENCE, this.cadenceId),
},
});
......
#import "./iteration_cadence.fragment.graphql"
query IterationCadence($fullPath: ID!, $id: ID!) {
query IterationCadence($fullPath: ID!, $id: IterationsCadenceID) {
group(fullPath: $fullPath) {
id
iterationCadences(id: $id, includeAncestorGroups: true) {
......
......@@ -11,9 +11,9 @@ RSpec.describe 'User views iteration' do
let_it_be(:user) { create(:group_member, :maintainer, user: create(:user), group: group).user }
let_it_be(:guest_user) { create(:group_member, :guest, user: create(:user), group: group).user }
let_it_be(:manual_cadence) { build(:iterations_cadence, group: group, automatic: false).tap { |cadence| cadence.save!(validate: false) } }
let_it_be(:iteration) { create(:iteration, :skip_future_date_validation, iterations_cadence: manual_cadence, iid: 1, id: 2, group: group, title: 'Correct Iteration', description: 'iteration description', start_date: now - 1.day, due_date: now) }
let_it_be(:other_iteration) { create(:iteration, :skip_future_date_validation, iid: 2, id: 1, group: group, title: 'Wrong Iteration', start_date: now - 4.days, due_date: now - 3.days) }
let_it_be(:sub_group_iteration) { create(:iteration, id: 3, group: sub_group) }
let_it_be(:other_iteration) { create(:iteration, :with_due_date, iterations_cadence: manual_cadence, title: 'Wrong Iteration', start_date: 1.week.ago) }
let_it_be(:iteration) { create(:iteration, :with_due_date, iterations_cadence: manual_cadence, title: 'Correct Iteration', description: 'iteration description', start_date: Date.today) }
let_it_be(:sub_group_iteration) { create(:iteration, group: sub_group) }
let_it_be(:label1) { create(:label, project: project) }
let_it_be(:issue) { create(:issue, project: project, iteration: iteration, labels: [label1]) }
let_it_be(:assigned_issue) { create(:issue, project: project, iteration: iteration, assignees: [user], labels: [label1]) }
......@@ -27,12 +27,6 @@ RSpec.describe 'User views iteration' do
end
shared_examples 'shows iteration info' do
before do
sign_in(current_user)
visit group_iteration_path(iteration.group, iteration.id)
end
it 'shows iteration info' do
aggregate_failures 'expect Iterations highlighted on left sidebar' do
page.within '.sidebar-top-level-items' do
......@@ -43,8 +37,7 @@ RSpec.describe 'User views iteration' do
aggregate_failures 'expect title, description, and dates' do
expect(page).to have_content(iteration.title)
expect(page).to have_content(iteration.description)
expect(page).to have_content(iteration.start_date.strftime('%b %-d, %Y'))
expect(page).to have_content(iteration.due_date.strftime('%b %-d, %Y'))
expect(page).to have_content(iteration.period)
end
aggregate_failures 'expect summary information' do
......@@ -75,15 +68,25 @@ RSpec.describe 'User views iteration' do
end
context 'when user has edit permissions' do
before do
stub_feature_flags(iteration_cadences: false)
end
it_behaves_like 'shows iteration info' do
let(:current_user) { user }
let(:shows_actions) { true }
before do
sign_in(current_user)
visit_iteration(iteration)
end
end
it 'can delete iteration' do
sign_in(user)
visit group_iteration_path(iteration.group, iteration.id)
visit_iteration(iteration)
click_button 'Actions'
click_button 'Delete'
......@@ -102,19 +105,96 @@ RSpec.describe 'User views iteration' do
it_behaves_like 'shows iteration info' do
let(:current_user) { guest_user }
let(:shows_actions) { false }
before do
sign_in(current_user)
visit_iteration(iteration)
end
end
end
context 'when grouping by label' do
before do
stub_feature_flags(iteration_cadences: false)
sign_in(user)
visit group_iteration_path(iteration.group, iteration.id)
wait_for_requests
visit_iteration(iteration)
end
it_behaves_like 'iteration report group by label'
end
context 'when iteration_cadences FF is enabled' do
before do
stub_feature_flags(iteration_cadences: true)
end
context 'when user has edit permissions' do
let(:current_user) { user }
let(:shows_actions) { true }
before do
sign_in(current_user)
visit_iteration(iteration, true)
end
it 'shows iteration cadence title in the breadcrumb' do
page.within '[aria-label="Breadcrumbs"]' do
expect(page).to have_content(manual_cadence.title)
end
end
it_behaves_like 'shows iteration info'
context 'when iteration cadence is manually scheduled' do
it 'can delete iteration' do
click_button 'Actions'
click_button 'Delete'
page.within '.gl-modal' do
click_button 'Delete'
end
wait_for_requests
click_button manual_cadence.title
expect(page).not_to have_content(iteration.period)
end
end
context 'when iteration cadence is automatically scheduled' do
let_it_be(:auto_cadence) { create(:iterations_cadence, group: group) }
let_it_be(:iteration) { create(:iteration, iterations_cadence: auto_cadence, description: 'iteration description', start_date: Date.today) }
it 'cannot delete iteration' do
click_button 'Actions'
expect(page).not_to have_button('Delete')
end
end
end
context 'when user does not have edit permissions' do
let(:current_user) { guest_user }
let(:shows_actions) { false }
before do
sign_in(current_user)
visit_iteration(iteration, true)
end
it_behaves_like 'shows iteration info'
context 'when iteration cadence is manually scheduled' do
it 'cannot edit iteration' do
expect(page).not_to have_button('Actions')
end
end
end
end
end
context 'without license' do
......@@ -123,11 +203,30 @@ RSpec.describe 'User views iteration' do
sign_in(user)
end
it 'shows page not found' do
visit group_iteration_path(iteration.group, iteration.id)
[true, false].each do |iteration_cadences_ff|
context "when iteration_cadences FF is %{iteration_cadences_ff}" do
before do
stub_feature_flags(iteration_cadences: iteration_cadences_ff)
end
it 'shows page not found' do
visit_iteration(iteration, iteration_cadences_ff)
expect(page).to have_title('Not Found')
expect(page).to have_content('Page Not Found')
expect(page).to have_title('Not Found')
expect(page).to have_content('Page Not Found')
end
end
end
end
def visit_iteration(iteration, with_cadence_feature = false)
if with_cadence_feature
cadence = iteration.iterations_cadence
visit group_iteration_cadence_iteration_path(cadence.group, iteration_cadence_id: cadence.id, id: iteration.id)
else
visit group_iteration_path(iteration.group, iteration.id)
end
wait_for_requests
end
end
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