Commit 95d0e0db authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'psi-missing-iteration-ids' into 'master'

Fix some apollo cache issues moving between pages

See merge request gitlab-org/gitlab!66345
parents b7a8f3d2 f5ed9b7c
...@@ -13,7 +13,7 @@ import BurnCharts from 'ee/burndown_chart/components/burn_charts.vue'; ...@@ -13,7 +13,7 @@ import BurnCharts from 'ee/burndown_chart/components/burn_charts.vue';
import { TYPE_ITERATION } from '~/graphql_shared/constants'; import { TYPE_ITERATION } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
import { __ } from '~/locale'; import { __, s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { Namespace } from '../constants'; import { Namespace } from '../constants';
import query from '../queries/iteration.query.graphql'; import query from '../queries/iteration.query.graphql';
...@@ -51,7 +51,9 @@ export default { ...@@ -51,7 +51,9 @@ export default {
return data[this.namespaceType]?.iterations?.nodes[0] || {}; return data[this.namespaceType]?.iterations?.nodes[0] || {};
}, },
error(err) { error(err) {
this.error = err.message; this.error = s__('Iterations|Unable to find iteration.');
// eslint-disable-next-line no-console
console.error(err.message);
}, },
}, },
}, },
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
query Iteration($fullPath: ID!, $id: ID!, $isGroup: Boolean = true) { query Iteration($fullPath: ID!, $id: ID!, $isGroup: Boolean = true) {
group(fullPath: $fullPath) @include(if: $isGroup) { group(fullPath: $fullPath) @include(if: $isGroup) {
id
iterations(id: $id, first: 1, includeAncestors: true) { iterations(id: $id, first: 1, includeAncestors: true) {
nodes { nodes {
...IterationReport ...IterationReport
...@@ -10,6 +11,7 @@ query Iteration($fullPath: ID!, $id: ID!, $isGroup: Boolean = true) { ...@@ -10,6 +11,7 @@ query Iteration($fullPath: ID!, $id: ID!, $isGroup: Boolean = true) {
} }
project(fullPath: $fullPath) @skip(if: $isGroup) { project(fullPath: $fullPath) @skip(if: $isGroup) {
id
iterations(id: $id, first: 1, includeAncestors: true) { iterations(id: $id, first: 1, includeAncestors: true) {
nodes { nodes {
...IterationReport ...IterationReport
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# todo: should this use IterationsCadenceID! ? # todo: should this use IterationsCadenceID! ?
query IterationCadence($fullPath: ID!, $id: ID!) { query IterationCadence($fullPath: ID!, $id: ID!) {
group(fullPath: $fullPath) { group(fullPath: $fullPath) {
id
iterationCadences(id: $id) { iterationCadences(id: $id) {
nodes { nodes {
...IterationCadence ...IterationCadence
......
...@@ -10,6 +10,7 @@ query IterationIssues( ...@@ -10,6 +10,7 @@ query IterationIssues(
$lastPageSize: Int $lastPageSize: Int
) { ) {
group(fullPath: $fullPath) @include(if: $isGroup) { group(fullPath: $fullPath) @include(if: $isGroup) {
id
issues( issues(
iterationId: [$id] iterationId: [$id]
before: $beforeCursor before: $beforeCursor
...@@ -22,6 +23,7 @@ query IterationIssues( ...@@ -22,6 +23,7 @@ query IterationIssues(
} }
} }
project(fullPath: $fullPath) @skip(if: $isGroup) { project(fullPath: $fullPath) @skip(if: $isGroup) {
id
issues( issues(
iterationId: [$id] iterationId: [$id]
before: $beforeCursor before: $beforeCursor
......
...@@ -11,6 +11,7 @@ query IterationIssuesWithLabelFilter( ...@@ -11,6 +11,7 @@ query IterationIssuesWithLabelFilter(
$lastPageSize: Int $lastPageSize: Int
) { ) {
group(fullPath: $fullPath) @include(if: $isGroup) { group(fullPath: $fullPath) @include(if: $isGroup) {
id
issues( issues(
iterationId: [$id] iterationId: [$id]
labelName: $labelName labelName: $labelName
...@@ -24,6 +25,7 @@ query IterationIssuesWithLabelFilter( ...@@ -24,6 +25,7 @@ query IterationIssuesWithLabelFilter(
} }
} }
project(fullPath: $fullPath) @skip(if: $isGroup) { project(fullPath: $fullPath) @skip(if: $isGroup) {
id
issues( issues(
iterationId: [$id] iterationId: [$id]
labelName: $labelName labelName: $labelName
......
...@@ -11,6 +11,7 @@ query Iterations( ...@@ -11,6 +11,7 @@ query Iterations(
$lastPageSize: Int $lastPageSize: Int
) { ) {
group(fullPath: $fullPath) @include(if: $isGroup) { group(fullPath: $fullPath) @include(if: $isGroup) {
id
iterations( iterations(
state: $state state: $state
before: $beforeCursor before: $beforeCursor
...@@ -27,6 +28,7 @@ query Iterations( ...@@ -27,6 +28,7 @@ query Iterations(
} }
} }
project(fullPath: $fullPath) @skip(if: $isGroup) { project(fullPath: $fullPath) @skip(if: $isGroup) {
id
iterations( iterations(
state: $state state: $state
before: $beforeCursor before: $beforeCursor
......
...@@ -51,6 +51,7 @@ describe('Iteration cadence form', () => { ...@@ -51,6 +51,7 @@ describe('Iteration cadence form', () => {
const getCadenceSuccess = { const getCadenceSuccess = {
data: { data: {
group: { group: {
id: 'gid://gitlab/Group/114',
iterationCadences: { iterationCadences: {
nodes: [iterationCadence], nodes: [iterationCadence],
}, },
......
...@@ -38,7 +38,9 @@ describe('Iteration Form', () => { ...@@ -38,7 +38,9 @@ describe('Iteration Form', () => {
}; };
const readMutationSuccess = { const readMutationSuccess = {
data: { group: { iterations: { nodes: [iteration] }, errors: [] } }, data: {
group: { id: 'gid://gitlab/Group/114', iterations: { nodes: [iteration] }, errors: [] },
},
}; };
const createMutationSuccess = { data: { iterationCreate: { iteration, errors: [] } } }; const createMutationSuccess = { data: { iterationCreate: { iteration, errors: [] } } };
const createMutationFailure = { const createMutationFailure = {
......
...@@ -56,7 +56,6 @@ describe('Iterations report issues', () => { ...@@ -56,7 +56,6 @@ describe('Iterations report issues', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
it('shows spinner while loading', () => { it('shows spinner while loading', () => {
......
...@@ -39,7 +39,8 @@ describe('Iterations report', () => { ...@@ -39,7 +39,8 @@ describe('Iterations report', () => {
const mountComponent = ({ const mountComponent = ({
props = defaultProps, props = defaultProps,
iterationQueryHandler = jest.fn().mockResolvedValue(mockGroupIterations), mockQueryResponse = mockGroupIterations,
iterationQueryHandler = jest.fn().mockResolvedValue(mockQueryResponse),
} = {}) => { } = {}) => {
localVue.use(VueApollo); localVue.use(VueApollo);
mockApollo = createMockApollo([[query, iterationQueryHandler]]); mockApollo = createMockApollo([[query, iterationQueryHandler]]);
...@@ -104,7 +105,7 @@ describe('Iterations report', () => { ...@@ -104,7 +105,7 @@ describe('Iterations report', () => {
], ],
])('when viewing an iteration in a %s', (_, props, mockIteration, expectedParams) => { ])('when viewing an iteration in a %s', (_, props, mockIteration, expectedParams) => {
it('calls a query with correct parameters', () => { it('calls a query with correct parameters', () => {
const iterationQueryHandler = jest.fn(); const iterationQueryHandler = jest.fn().mockResolvedValue(mockIteration);
mountComponent({ mountComponent({
props, props,
iterationQueryHandler, iterationQueryHandler,
...@@ -128,7 +129,6 @@ describe('Iterations report', () => { ...@@ -128,7 +129,6 @@ describe('Iterations report', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
describe('empty state', () => { describe('empty state', () => {
...@@ -137,6 +137,7 @@ describe('Iterations report', () => { ...@@ -137,6 +137,7 @@ describe('Iterations report', () => {
iterationQueryHandler: jest.fn().mockResolvedValue({ iterationQueryHandler: jest.fn().mockResolvedValue({
data: { data: {
group: { group: {
id: 'gid://gitlab/Group/1',
iterations: { iterations: {
nodes: [], nodes: [],
}, },
...@@ -212,12 +213,18 @@ describe('Iterations report', () => { ...@@ -212,12 +213,18 @@ describe('Iterations report', () => {
'when user $description and they are viewing an iteration within a $namespaceType', 'when user $description and they are viewing an iteration within a $namespaceType',
({ canEdit, namespaceType, canEditIteration }) => { ({ canEdit, namespaceType, canEditIteration }) => {
beforeEach(() => { beforeEach(() => {
const mockQueryResponse = {
[Namespace.Group]: mockGroupIterations,
[Namespace.Project]: mockProjectIterations,
}[namespaceType];
mountComponent({ mountComponent({
props: { props: {
...defaultProps, ...defaultProps,
canEditIteration, canEditIteration,
namespaceType, namespaceType,
}, },
mockQueryResponse,
}); });
}); });
......
...@@ -14,6 +14,7 @@ export const mockIterationNode = { ...@@ -14,6 +14,7 @@ export const mockIterationNode = {
export const mockGroupIterations = { export const mockGroupIterations = {
data: { data: {
group: { group: {
id: 'gid://gitlab/Group/114',
iterations: { iterations: {
nodes: [mockIterationNode], nodes: [mockIterationNode],
__typename: 'IterationConnection', __typename: 'IterationConnection',
...@@ -26,6 +27,7 @@ export const mockGroupIterations = { ...@@ -26,6 +27,7 @@ export const mockGroupIterations = {
export const mockProjectIterations = { export const mockProjectIterations = {
data: { data: {
project: { project: {
id: 'gid://gitlab/Project/114',
iterations: { iterations: {
nodes: [mockIterationNode], nodes: [mockIterationNode],
__typename: 'IterationConnection', __typename: 'IterationConnection',
......
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