Commit 5b5e6837 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch '356578-upgrade-apollo-client-to-3-5-x' into 'master'

Resolve "Upgrade Apollo Client to 3.5.x"

See merge request gitlab-org/gitlab!83438
parents 32ef6268 5b05eb05
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
GlModalDirective, GlModalDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
import getStatesQuery from '../graphql/queries/get_states.query.graphql';
import addDataToState from '../graphql/mutations/add_data_to_state.mutation.graphql'; import addDataToState from '../graphql/mutations/add_data_to_state.mutation.graphql';
import lockState from '../graphql/mutations/lock_state.mutation.graphql'; import lockState from '../graphql/mutations/lock_state.mutation.graphql';
import removeState from '../graphql/mutations/remove_state.mutation.graphql'; import removeState from '../graphql/mutations/remove_state.mutation.graphql';
...@@ -148,7 +149,7 @@ export default { ...@@ -148,7 +149,7 @@ export default {
variables: { variables: {
stateID: this.state.id, stateID: this.state.id,
}, },
refetchQueries: () => ['getStates'], refetchQueries: () => [{ query: getStatesQuery }],
awaitRefetchQueries: true, awaitRefetchQueries: true,
notifyOnNetworkStatusChange: true, notifyOnNetworkStatusChange: true,
}) })
......
...@@ -6,6 +6,7 @@ query devopsAdoptionEnabledNamespaces($displayNamespaceId: NamespaceID) { ...@@ -6,6 +6,7 @@ query devopsAdoptionEnabledNamespaces($displayNamespaceId: NamespaceID) {
nodes { nodes {
id id
latestSnapshot { latestSnapshot {
__typename
...LatestSnapshot ...LatestSnapshot
} }
namespace { namespace {
......
...@@ -20,6 +20,11 @@ mutation oncallScheduleUpdate( ...@@ -20,6 +20,11 @@ mutation oncallScheduleUpdate(
name name
description description
timezone timezone
rotations {
nodes {
id
}
}
} }
} }
} }
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
subscriptionActivationForm, subscriptionActivationForm,
} from 'ee/admin/subscriptions/show/constants'; } from 'ee/admin/subscriptions/show/constants';
import activateSubscriptionMutation from 'ee/admin/subscriptions/show/graphql/mutations/activate_subscription.mutation.graphql'; import activateSubscriptionMutation from 'ee/admin/subscriptions/show/graphql/mutations/activate_subscription.mutation.graphql';
import { stripTypenames } from 'helpers/graphql_helpers';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { stubComponent } from 'helpers/stub_component'; import { stubComponent } from 'helpers/stub_component';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
...@@ -197,7 +198,11 @@ describe('SubscriptionActivationForm', () => { ...@@ -197,7 +198,11 @@ describe('SubscriptionActivationForm', () => {
it('emits a successful event', () => { it('emits a successful event', () => {
expect(wrapper.emitted(SUBSCRIPTION_ACTIVATION_SUCCESS_EVENT)).toEqual([ expect(wrapper.emitted(SUBSCRIPTION_ACTIVATION_SUCCESS_EVENT)).toEqual([
[activateLicenseMutationResponse.SUCCESS.data.gitlabSubscriptionActivate.license], [
stripTypenames(
activateLicenseMutationResponse.SUCCESS.data.gitlabSubscriptionActivate.license,
),
],
]); ]);
}); });
}); });
......
...@@ -142,6 +142,7 @@ export const activateLicenseMutationResponse = { ...@@ -142,6 +142,7 @@ export const activateLicenseMutationResponse = {
data: { data: {
gitlabSubscriptionActivate: { gitlabSubscriptionActivate: {
license: { license: {
__typename: 'CurrentLicense',
id: 'gid://gitlab/License/3', id: 'gid://gitlab/License/3',
type: 'cloud', type: 'cloud',
plan: 'ultimate', plan: 'ultimate',
......
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
} from 'ee/analytics/devops_reports/devops_adoption/constants'; } from 'ee/analytics/devops_reports/devops_adoption/constants';
import bulkEnableDevopsAdoptionNamespacesMutation from 'ee/analytics/devops_reports/devops_adoption/graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql'; import bulkEnableDevopsAdoptionNamespacesMutation from 'ee/analytics/devops_reports/devops_adoption/graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql';
import disableDevopsAdoptionNamespaceMutation from 'ee/analytics/devops_reports/devops_adoption/graphql/mutations/disable_devops_adoption_namespace.mutation.graphql'; import disableDevopsAdoptionNamespaceMutation from 'ee/analytics/devops_reports/devops_adoption/graphql/mutations/disable_devops_adoption_namespace.mutation.graphql';
import { stripTypenames } from 'helpers/graphql_helpers';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
...@@ -173,9 +174,16 @@ describe('DevopsAdoptionAddDropdown', () => { ...@@ -173,9 +174,16 @@ describe('DevopsAdoptionAddDropdown', () => {
}); });
it('emits the enabledNamespacesAdded event', () => { it('emits the enabledNamespacesAdded event', () => {
const { latestSnapshot, namespace } = devopsAdoptionNamespaceData.nodes[0];
const [params] = wrapper.emitted().enabledNamespacesAdded[0]; const [params] = wrapper.emitted().enabledNamespacesAdded[0];
expect(params).toStrictEqual([devopsAdoptionNamespaceData.nodes[0]]); expect(params).toStrictEqual([
{
...devopsAdoptionNamespaceData.nodes[0],
latestSnapshot: stripTypenames(latestSnapshot),
namespace: stripTypenames(namespace),
},
]);
}); });
} else { } else {
it('makes a request to disable the selected group', () => { it('makes a request to disable the selected group', () => {
......
...@@ -17,6 +17,7 @@ import bulkEnableDevopsAdoptionNamespacesMutation from 'ee/analytics/devops_repo ...@@ -17,6 +17,7 @@ import bulkEnableDevopsAdoptionNamespacesMutation from 'ee/analytics/devops_repo
import devopsAdoptionEnabledNamespaces from 'ee/analytics/devops_reports/devops_adoption/graphql/queries/devops_adoption_enabled_namespaces.query.graphql'; import devopsAdoptionEnabledNamespaces from 'ee/analytics/devops_reports/devops_adoption/graphql/queries/devops_adoption_enabled_namespaces.query.graphql';
import getGroupsQuery from 'ee/analytics/devops_reports/devops_adoption/graphql/queries/get_groups.query.graphql'; import getGroupsQuery from 'ee/analytics/devops_reports/devops_adoption/graphql/queries/get_groups.query.graphql';
import { addEnabledNamespacesToCache } from 'ee/analytics/devops_reports/devops_adoption/utils/cache_updates'; import { addEnabledNamespacesToCache } from 'ee/analytics/devops_reports/devops_adoption/utils/cache_updates';
import { stripTypenames } from 'helpers/graphql_helpers';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
...@@ -256,10 +257,17 @@ describe('DevopsAdoptionApp', () => { ...@@ -256,10 +257,17 @@ describe('DevopsAdoptionApp', () => {
}); });
it('calls addEnabledNamespacesToCache with the correct variables', () => { it('calls addEnabledNamespacesToCache with the correct variables', () => {
const { latestSnapshot, namespace } = devopsAdoptionNamespaceData.nodes[0];
expect(addEnabledNamespacesToCache).toHaveBeenCalledTimes(1); expect(addEnabledNamespacesToCache).toHaveBeenCalledTimes(1);
expect(addEnabledNamespacesToCache).toHaveBeenCalledWith( expect(addEnabledNamespacesToCache).toHaveBeenCalledWith(
expect.anything(), expect.anything(),
[devopsAdoptionNamespaceData.nodes[0]], [
{
...devopsAdoptionNamespaceData.nodes[0],
latestSnapshot: stripTypenames(latestSnapshot),
namespace: stripTypenames(namespace),
},
],
{ {
displayNamespaceId: groupGid, displayNamespaceId: groupGid,
}, },
......
...@@ -67,13 +67,7 @@ describe('AddScheduleModal', () => { ...@@ -67,13 +67,7 @@ describe('AddScheduleModal', () => {
localVue.use(VueApollo); localVue.use(VueApollo);
updateScheduleHandler = updateHandler; updateScheduleHandler = updateHandler;
const requestHandlers = [ const requestHandlers = [[updateOncallScheduleMutation, updateScheduleHandler]];
[
getOncallSchedulesWithRotationsQuery,
jest.fn().mockResolvedValue(getOncallSchedulesQueryResponse),
],
[updateOncallScheduleMutation, updateScheduleHandler],
];
fakeApollo = createMockApollo(requestHandlers); fakeApollo = createMockApollo(requestHandlers);
......
...@@ -29,6 +29,26 @@ export const participants = [ ...@@ -29,6 +29,26 @@ export const participants = [
export const errorMsg = 'Something went wrong'; export const errorMsg = 'Something went wrong';
export const getOncallSchedulesQueryResponse = { export const getOncallSchedulesQueryResponse = {
data: {
project: {
id: 'project-1',
incidentManagementOncallSchedules: {
nodes: [
{
__typename: 'IncidentManagementOncallSchedule',
iid: '37',
name: 'Test schedule from query',
description: 'Description 1 lives here',
timezone: 'America/Los_Angeles',
rotations: { nodes: [{ id: 'gid://gitlab/IncidentManagement::OncallRotation/2' }] },
},
],
},
},
},
};
export const getOncallSchedulesQueryResponseWithRotations = {
data: { data: {
project: { project: {
id: 'project-1', id: 'project-1',
...@@ -110,7 +130,7 @@ export const updateScheduleResponseWithErrors = { ...@@ -110,7 +130,7 @@ export const updateScheduleResponseWithErrors = {
name: 'Test schedule 2', name: 'Test schedule 2',
description: 'Description 2 lives here', description: 'Description 2 lives here',
timezone: 'Pacific/Honolulu', timezone: 'Pacific/Honolulu',
rotations: { nodes: [mockRotations] }, rotations: { nodes: [{ id: 'gid://gitlab/IncidentManagement::OncallRotation/2' }] },
}, },
}, },
}, },
......
...@@ -14,7 +14,7 @@ import createMockApollo from 'helpers/mock_apollo_helper'; ...@@ -14,7 +14,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import * as dateTimeUtility from '~/lib/utils/datetime/date_calculation_utility'; import * as dateTimeUtility from '~/lib/utils/datetime/date_calculation_utility';
import { getOncallSchedulesQueryResponse } from './mocks/apollo_mock'; import { getOncallSchedulesQueryResponseWithRotations } from './mocks/apollo_mock';
Vue.use(VueApollo); Vue.use(VueApollo);
...@@ -46,7 +46,7 @@ describe('On-call schedule', () => { ...@@ -46,7 +46,7 @@ describe('On-call schedule', () => {
scheduleIndex = 0, scheduleIndex = 0,
getShiftsForRotationsQueryHandler = jest getShiftsForRotationsQueryHandler = jest
.fn() .fn()
.mockResolvedValue(getOncallSchedulesQueryResponse), .mockResolvedValue(getOncallSchedulesQueryResponseWithRotations),
props = {}, props = {},
provide = {}, provide = {},
} = {}) => { } = {}) => {
...@@ -282,8 +282,8 @@ describe('On-call schedule', () => { ...@@ -282,8 +282,8 @@ describe('On-call schedule', () => {
expect(findRotationsList().props('rotations')).toHaveLength(4); expect(findRotationsList().props('rotations')).toHaveLength(4);
expect(findRotationsList().props('rotations')).toEqual( expect(findRotationsList().props('rotations')).toEqual(
getOncallSchedulesQueryResponse.data.project.incidentManagementOncallSchedules.nodes[0] getOncallSchedulesQueryResponseWithRotations.data.project.incidentManagementOncallSchedules
.rotations.nodes, .nodes[0].rotations.nodes,
); );
}); });
......
...@@ -8,6 +8,7 @@ import ConfigurationForm from 'ee/security_configuration/sast/components/configu ...@@ -8,6 +8,7 @@ import ConfigurationForm from 'ee/security_configuration/sast/components/configu
import sastCiConfigurationQuery from 'ee/security_configuration/sast/graphql/sast_ci_configuration.query.graphql'; import sastCiConfigurationQuery from 'ee/security_configuration/sast/graphql/sast_ci_configuration.query.graphql';
import { stripTypenames } from 'helpers/graphql_helpers'; import { stripTypenames } from 'helpers/graphql_helpers';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { sastCiConfigurationQueryResponse } from '../mock_data'; import { sastCiConfigurationQueryResponse } from '../mock_data';
...@@ -118,6 +119,7 @@ describe('SAST Configuration App', () => { ...@@ -118,6 +119,7 @@ describe('SAST Configuration App', () => {
createComponent({ createComponent({
apolloProvider: createMockApolloProvider(failureHandler), apolloProvider: createMockApolloProvider(failureHandler),
}); });
return waitForPromises();
}); });
it('does not display a loading spinner', () => { it('does not display a loading spinner', () => {
......
import Vue, { nextTick } from 'vue'; import Vue from 'vue';
import { merge } from 'lodash'; import { merge } from 'lodash';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
...@@ -154,18 +154,15 @@ describe('Order Summary', () => { ...@@ -154,18 +154,15 @@ describe('Order Summary', () => {
orderPreviewQueryMock, orderPreviewQueryMock,
); );
createComponent(apolloProvider, { purchaseHasExpiration: true }); createComponent(apolloProvider, { purchaseHasExpiration: true });
return waitForPromises();
}); });
it('does not render amount', () => { it('does not render amount', () => {
expect(findAmount().text()).toBe('-'); expect(findAmount().text()).toBe('-');
}); });
it('should emit `alertError` event', async () => { it('should emit `alertError` event', () => {
jest.spyOn(wrapper.vm, '$emit'); expect(wrapper.emitted('alertError')).toEqual([[I18N_API_ERROR]]);
await nextTick();
expect(wrapper.vm.$emit).toHaveBeenCalledWith('alertError', I18N_API_ERROR);
}); });
}); });
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
"webpack-prod": "NODE_OPTIONS=\"--max-old-space-size=3584\" NODE_ENV=production webpack --config config/webpack.config.js" "webpack-prod": "NODE_OPTIONS=\"--max-old-space-size=3584\" NODE_ENV=production webpack --config config/webpack.config.js"
}, },
"dependencies": { "dependencies": {
"@apollo/client": "^3.3.11", "@apollo/client": "^3.5.10",
"@babel/core": "^7.10.1", "@babel/core": "^7.10.1",
"@babel/plugin-proposal-class-properties": "^7.10.1", "@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-proposal-json-strings": "^7.10.1", "@babel/plugin-proposal-json-strings": "^7.10.1",
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
"@tiptap/vue-2": "^2.0.0-beta.77", "@tiptap/vue-2": "^2.0.0-beta.77",
"@toast-ui/editor": "^2.5.2", "@toast-ui/editor": "^2.5.2",
"@toast-ui/vue-editor": "^2.5.2", "@toast-ui/vue-editor": "^2.5.2",
"apollo-upload-client": "^14.1.3", "apollo-upload-client": "15.0.0",
"autosize": "^5.0.1", "autosize": "^5.0.1",
"aws-sdk": "^2.637.0", "aws-sdk": "^2.637.0",
"axios": "^0.24.0", "axios": "^0.24.0",
...@@ -259,7 +259,6 @@ ...@@ -259,7 +259,6 @@
"bootstrap-vue": "https://docs.gitlab.com/ee/development/fe_guide/dependencies.html#bootstrapvue" "bootstrap-vue": "https://docs.gitlab.com/ee/development/fe_guide/dependencies.html#bootstrapvue"
}, },
"resolutions": { "resolutions": {
"@apollo/client/subscriptions-transport-ws": "0.11.0",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"@types/node": "14.17.5" "@types/node": "14.17.5"
}, },
......
...@@ -476,9 +476,6 @@ describe('AlertsSettingsWrapper', () => { ...@@ -476,9 +476,6 @@ describe('AlertsSettingsWrapper', () => {
destroyHttpIntegration(wrapper); destroyHttpIntegration(wrapper);
expect(destroyIntegrationHandler).toHaveBeenCalled(); expect(destroyIntegrationHandler).toHaveBeenCalled();
await waitForPromises();
expect(findIntegrations()).toHaveLength(3);
}); });
it('displays flash if mutation had a recoverable error', async () => { it('displays flash if mutation had a recoverable error', async () => {
......
...@@ -102,7 +102,7 @@ export const destroyIntegrationResponse = { ...@@ -102,7 +102,7 @@ export const destroyIntegrationResponse = {
httpIntegrationDestroy: { httpIntegrationDestroy: {
errors: [], errors: [],
integration: { integration: {
__typename: 'AlertManagementIntegration', __typename: 'AlertManagementHttpIntegration',
id: '37', id: '37',
type: 'HTTP', type: 'HTTP',
active: true, active: true,
......
const agent = { const agent = {
__typename: 'ClusterAgent',
id: 'agent-id', id: 'agent-id',
name: 'agent-name', name: 'agent-name',
webPath: 'agent-webPath', webPath: 'agent-webPath',
......
...@@ -183,7 +183,7 @@ describe('Design management index page', () => { ...@@ -183,7 +183,7 @@ describe('Design management index page', () => {
[moveDesignMutation, moveDesignHandler], [moveDesignMutation, moveDesignHandler],
]; ];
fakeApollo = createMockApollo(requestHandlers); fakeApollo = createMockApollo(requestHandlers, {}, { addTypename: true });
wrapper = shallowMount(Index, { wrapper = shallowMount(Index, {
apolloProvider: fakeApollo, apolloProvider: fakeApollo,
router, router,
......
...@@ -150,7 +150,8 @@ describe('app_index.vue', () => { ...@@ -150,7 +150,8 @@ describe('app_index.vue', () => {
expect(findEmptyState().exists()).toBe(emptyState); expect(findEmptyState().exists()).toBe(emptyState);
}); });
it(`${toDescription(flashMessage)} show a flash message`, () => { it(`${toDescription(flashMessage)} show a flash message`, async () => {
await waitForPromises();
if (flashMessage) { if (flashMessage) {
expect(createFlash).toHaveBeenCalledWith({ expect(createFlash).toHaveBeenCalledWith({
message: ReleasesIndexApp.i18n.errorMessage, message: ReleasesIndexApp.i18n.errorMessage,
......
...@@ -143,6 +143,12 @@ describe('Release show component', () => { ...@@ -143,6 +143,12 @@ describe('Release show component', () => {
describe('when the request succeeded, but the returned "project.release" key was null', () => { describe('when the request succeeded, but the returned "project.release" key was null', () => {
beforeEach(async () => { beforeEach(async () => {
// As we return a release as `null`, Apollo also throws an error to the console
// about the missing field. We need to suppress console.error in order to check
// that flash message was called
// eslint-disable-next-line no-console
console.error = jest.fn();
const apolloProvider = createMockApollo([ const apolloProvider = createMockApollo([
[ [
oneReleaseQuery, oneReleaseQuery,
......
export const getStatesResponse = {
data: {
project: {
id: 'project-1',
terraformStates: {
count: 1,
nodes: {
_showDetails: true,
errorMessages: [],
loadingLock: false,
loadingRemove: false,
id: 'state-1',
name: 'state',
lockedAt: '01-01-2022',
updatedAt: '01-01-2022',
lockedByUser: {
id: 'user-1',
avatarUrl: 'avatar',
name: 'User 1',
username: 'user-1',
webUrl: 'web',
},
latestVersion: null,
},
pageInfo: {
__typename: 'PageInfo',
hasNextPage: true,
hasPreviousPage: false,
startCursor: 'prev',
endCursor: 'next',
},
},
},
},
};
...@@ -9,6 +9,8 @@ import StateActions from '~/terraform/components/states_table_actions.vue'; ...@@ -9,6 +9,8 @@ import StateActions from '~/terraform/components/states_table_actions.vue';
import lockStateMutation from '~/terraform/graphql/mutations/lock_state.mutation.graphql'; import lockStateMutation from '~/terraform/graphql/mutations/lock_state.mutation.graphql';
import removeStateMutation from '~/terraform/graphql/mutations/remove_state.mutation.graphql'; import removeStateMutation from '~/terraform/graphql/mutations/remove_state.mutation.graphql';
import unlockStateMutation from '~/terraform/graphql/mutations/unlock_state.mutation.graphql'; import unlockStateMutation from '~/terraform/graphql/mutations/unlock_state.mutation.graphql';
import getStatesQuery from '~/terraform/graphql/queries/get_states.query.graphql';
import { getStatesResponse } from './mock_data';
Vue.use(VueApollo); Vue.use(VueApollo);
...@@ -49,6 +51,7 @@ describe('StatesTableActions', () => { ...@@ -49,6 +51,7 @@ describe('StatesTableActions', () => {
[lockStateMutation, lockResponse], [lockStateMutation, lockResponse],
[removeStateMutation, removeResponse], [removeStateMutation, removeResponse],
[unlockStateMutation, unlockResponse], [unlockStateMutation, unlockResponse],
[getStatesQuery, jest.fn().mockResolvedValue(getStatesResponse)],
], ],
{ {
Mutation: { Mutation: {
......
This diff is collapsed.
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