Commit f5ed9b7c authored by Simon Knox's avatar Simon Knox Committed by Natalia Tepluhina

Fix some apollo cache issues moving between pages

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