Commit 920e7f26 authored by Phil Hughes's avatar Phil Hughes

Merge branch '331416-devops-adoption-fe-remove-remaining-references-to-segments' into 'master'

DevOps Adoption - Remove remaining references to segments

See merge request gitlab-org/gitlab!65434
parents 10bf0ac7 b3a9c3af
...@@ -100,7 +100,7 @@ export default { ...@@ -100,7 +100,7 @@ export default {
bulkEnableDevopsAdoptionNamespaces: { enabledNamespaces, errors: requestErrors }, bulkEnableDevopsAdoptionNamespaces: { enabledNamespaces, errors: requestErrors },
} = data; } = data;
if (!requestErrors.length) this.$emit('segmentsAdded', enabledNamespaces); if (!requestErrors.length) this.$emit('enabledNamespacesAdded', enabledNamespaces);
}, },
}) })
.catch((error) => { .catch((error) => {
......
...@@ -19,7 +19,10 @@ import { ...@@ -19,7 +19,10 @@ import {
import bulkEnableDevopsAdoptionNamespacesMutation from '../graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql'; import bulkEnableDevopsAdoptionNamespacesMutation from '../graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql';
import devopsAdoptionEnabledNamespacesQuery from '../graphql/queries/devops_adoption_enabled_namespaces.query.graphql'; import devopsAdoptionEnabledNamespacesQuery from '../graphql/queries/devops_adoption_enabled_namespaces.query.graphql';
import getGroupsQuery from '../graphql/queries/get_groups.query.graphql'; import getGroupsQuery from '../graphql/queries/get_groups.query.graphql';
import { addSegmentsToCache, deleteSegmentsFromCache } from '../utils/cache_updates'; import {
addEnabledNamespacesToCache,
deleteEnabledNamespacesFromCache,
} from '../utils/cache_updates';
import { shouldPollTableData } from '../utils/helpers'; import { shouldPollTableData } from '../utils/helpers';
import DevopsAdoptionAddDropdown from './devops_adoption_add_dropdown.vue'; import DevopsAdoptionAddDropdown from './devops_adoption_add_dropdown.vue';
import DevopsAdoptionOverview from './devops_adoption_overview.vue'; import DevopsAdoptionOverview from './devops_adoption_overview.vue';
...@@ -69,15 +72,15 @@ export default { ...@@ -69,15 +72,15 @@ export default {
openModal: false, openModal: false,
errors: { errors: {
[DEVOPS_ADOPTION_ERROR_KEYS.groups]: false, [DEVOPS_ADOPTION_ERROR_KEYS.groups]: false,
[DEVOPS_ADOPTION_ERROR_KEYS.segments]: false, [DEVOPS_ADOPTION_ERROR_KEYS.enabledNamespaces]: false,
[DEVOPS_ADOPTION_ERROR_KEYS.addSegment]: false, [DEVOPS_ADOPTION_ERROR_KEYS.addEnabledNamespaces]: false,
}, },
groups: { groups: {
nodes: [], nodes: [],
pageInfo: null, pageInfo: null,
}, },
pollingTableData: null, pollingTableData: null,
segmentsQueryVariables: { enabledNamespaceQueryVariables: {
displayNamespaceId: this.isGroup ? this.groupGid : null, displayNamespaceId: this.isGroup ? this.groupGid : null,
}, },
adoptionTabClicked: false, adoptionTabClicked: false,
...@@ -92,7 +95,7 @@ export default { ...@@ -92,7 +95,7 @@ export default {
isSingleRequest: true, isSingleRequest: true,
}, },
variables() { variables() {
return this.segmentsQueryVariables; return this.enabledNamespaceQueryVariables;
}, },
result({ data }) { result({ data }) {
if (this.isGroup) { if (this.isGroup) {
...@@ -106,7 +109,7 @@ export default { ...@@ -106,7 +109,7 @@ export default {
} }
}, },
error(error) { error(error) {
this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.segments, error); this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.enabledNamespaces, error);
}, },
}, },
}, },
...@@ -117,7 +120,7 @@ export default { ...@@ -117,7 +120,7 @@ export default {
hasGroupData() { hasGroupData() {
return Boolean(this.groups?.nodes?.length); return Boolean(this.groups?.nodes?.length);
}, },
hasSegmentsData() { hasEnabledNamespaceData() {
return Boolean(this.devopsAdoptionEnabledNamespaces?.nodes?.length); return Boolean(this.devopsAdoptionEnabledNamespaces?.nodes?.length);
}, },
hasLoadingError() { hasLoadingError() {
...@@ -191,14 +194,14 @@ export default { ...@@ -191,14 +194,14 @@ export default {
} = data; } = data;
if (errors.length) { if (errors.length) {
this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.addSegment, errors); this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.addEnabledNamespaces, errors);
} else { } else {
this.addSegmentsToCache(enabledNamespaces); this.addEnabledNamespacesToCache(enabledNamespaces);
} }
}, },
}) })
.catch((error) => { .catch((error) => {
this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.addSegment, error); this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.addEnabledNamespaces, error);
}) })
.finally(() => { .finally(() => {
this.isLoadingEnableGroup = false; this.isLoadingEnableGroup = false;
...@@ -206,7 +209,7 @@ export default { ...@@ -206,7 +209,7 @@ export default {
}, },
pollTableData() { pollTableData() {
const shouldPoll = shouldPollTableData({ const shouldPoll = shouldPollTableData({
segments: this.devopsAdoptionEnabledNamespaces.nodes, enabledNamespaces: this.devopsAdoptionEnabledNamespaces.nodes,
timestamp: this.devopsAdoptionEnabledNamespaces?.nodes[0]?.latestSnapshot?.recordedAt, timestamp: this.devopsAdoptionEnabledNamespaces?.nodes[0]?.latestSnapshot?.recordedAt,
openModal: this.openModal, openModal: this.openModal,
}); });
...@@ -250,15 +253,15 @@ export default { ...@@ -250,15 +253,15 @@ export default {
}) })
.catch((error) => this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.groups, error)); .catch((error) => this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.groups, error));
}, },
addSegmentsToCache(segments) { addEnabledNamespacesToCache(enabledNamespaces) {
const { cache } = this.$apollo.getClient(); const { cache } = this.$apollo.getClient();
addSegmentsToCache(cache, segments, this.segmentsQueryVariables); addEnabledNamespacesToCache(cache, enabledNamespaces, this.enabledNamespaceQueryVariables);
}, },
deleteSegmentsFromCache(ids) { deleteEnabledNamespacesFromCache(ids) {
const { cache } = this.$apollo.getClient(); const { cache } = this.$apollo.getClient();
deleteSegmentsFromCache(cache, ids, this.segmentsQueryVariables); deleteEnabledNamespacesFromCache(cache, ids, this.enabledNamespaceQueryVariables);
}, },
selectTab() { selectTab() {
const [value] = getParameterValues('tab'); const [value] = getParameterValues('tab');
...@@ -327,18 +330,18 @@ export default { ...@@ -327,18 +330,18 @@ export default {
<devops-adoption-section <devops-adoption-section
v-else v-else
:is-loading="isLoadingAdoptionData" :is-loading="isLoadingAdoptionData"
:has-segments-data="hasSegmentsData" :has-enabled-namespace-data="hasEnabledNamespaceData"
:timestamp="timestamp" :timestamp="timestamp"
:has-group-data="hasGroupData" :has-group-data="hasGroupData"
:cols="tab.cols" :cols="tab.cols"
:segments="devopsAdoptionEnabledNamespaces" :enabled-namespaces="devopsAdoptionEnabledNamespaces"
:search-term="searchTerm" :search-term="searchTerm"
:disabled-group-nodes="disabledGroupNodes" :disabled-group-nodes="disabledGroupNodes"
:is-loading-groups="isLoadingGroups" :is-loading-groups="isLoadingGroups"
:has-subgroups="hasSubgroups" :has-subgroups="hasSubgroups"
@segmentsRemoved="deleteSegmentsFromCache" @enabledNamespacesRemoved="deleteEnabledNamespacesFromCache"
@fetchGroups="fetchGroups" @fetchGroups="fetchGroups"
@segmentsAdded="addSegmentsToCache" @enabledNamespacesAdded="addEnabledNamespacesToCache"
@trackModalOpenState="trackModalOpenState" @trackModalOpenState="trackModalOpenState"
/> />
</gl-tab> </gl-tab>
...@@ -359,7 +362,7 @@ export default { ...@@ -359,7 +362,7 @@ export default {
:is-loading-groups="isLoadingGroups" :is-loading-groups="isLoadingGroups"
:has-subgroups="hasSubgroups" :has-subgroups="hasSubgroups"
@fetchGroups="fetchGroups" @fetchGroups="fetchGroups"
@segmentsAdded="addSegmentsToCache" @enabledNamespacesAdded="addEnabledNamespacesToCache"
/> />
</span> </span>
</template> </template>
......
<script> <script>
import { GlModal, GlSprintf, GlAlert } from '@gitlab/ui'; import { GlModal, GlSprintf, GlAlert } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { DEVOPS_ADOPTION_STRINGS, DEVOPS_ADOPTION_SEGMENT_DELETE_MODAL_ID } from '../constants'; import { DEVOPS_ADOPTION_STRINGS, DEVOPS_ADOPTION_DELETE_MODAL_ID } from '../constants';
import disableDevopsAdoptionNamespaceMutation from '../graphql/mutations/disable_devops_adoption_namespace.mutation.graphql'; import disableDevopsAdoptionNamespaceMutation from '../graphql/mutations/disable_devops_adoption_namespace.mutation.graphql';
export default { export default {
name: 'DevopsAdoptionDeleteModal', name: 'DevopsAdoptionDeleteModal',
components: { GlModal, GlSprintf, GlAlert }, components: { GlModal, GlSprintf, GlAlert },
i18n: DEVOPS_ADOPTION_STRINGS.deleteModal, i18n: DEVOPS_ADOPTION_STRINGS.deleteModal,
devopsSegmentDeleteModalId: DEVOPS_ADOPTION_SEGMENT_DELETE_MODAL_ID, deleteModalId: DEVOPS_ADOPTION_DELETE_MODAL_ID,
props: { props: {
segment: { namespace: {
type: Object, type: Object,
required: true, required: true,
}, },
...@@ -43,14 +43,14 @@ export default { ...@@ -43,14 +43,14 @@ export default {
return this.errors[0]; return this.errors[0];
}, },
displayName() { displayName() {
return this.segment.namespace?.fullName; return this.namespace.namespace?.fullName;
}, },
}, },
methods: { methods: {
async deleteSegment() { async deleteEnabledNamespace() {
try { try {
const { const {
segment: { id }, namespace: { id },
} = this; } = this;
this.loading = true; this.loading = true;
...@@ -65,7 +65,7 @@ export default { ...@@ -65,7 +65,7 @@ export default {
id: [id], id: [id],
}, },
update: () => { update: () => {
this.$emit('segmentsRemoved', [id]); this.$emit('enabledNamespacesRemoved', [id]);
}, },
}); });
...@@ -90,11 +90,11 @@ export default { ...@@ -90,11 +90,11 @@ export default {
<template> <template>
<gl-modal <gl-modal
ref="modal" ref="modal"
:modal-id="$options.devopsSegmentDeleteModalId" :modal-id="$options.deleteModalId"
size="sm" size="sm"
:action-primary="primaryOptions" :action-primary="primaryOptions"
:action-cancel="cancelOptions" :action-cancel="cancelOptions"
@primary.prevent="deleteSegment" @primary.prevent="deleteEnabledNamespace"
@hide="$emit('trackModalOpenState', false)" @hide="$emit('trackModalOpenState', false)"
@show="$emit('trackModalOpenState', true)" @show="$emit('trackModalOpenState', true)"
> >
......
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
hasSegmentsData: { hasEnabledNamespaceData: {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
...@@ -37,7 +37,7 @@ export default { ...@@ -37,7 +37,7 @@ export default {
type: Array, type: Array,
required: true, required: true,
}, },
segments: { enabledNamespaces: {
type: Object, type: Object,
required: false, required: false,
default: () => {}, default: () => {},
...@@ -64,7 +64,7 @@ export default { ...@@ -64,7 +64,7 @@ export default {
</script> </script>
<template> <template>
<gl-loading-icon v-if="isLoading" size="md" class="gl-my-5" /> <gl-loading-icon v-if="isLoading" size="md" class="gl-my-5" />
<div v-else-if="hasSegmentsData" class="gl-mt-3"> <div v-else-if="hasEnabledNamespaceData" class="gl-mt-3">
<div class="gl-mb-3" data-testid="tableHeader"> <div class="gl-mb-3" data-testid="tableHeader">
<p class="gl-text-gray-400"> <p class="gl-text-gray-400">
<gl-sprintf :message="$options.i18n.tableHeaderText"> <gl-sprintf :message="$options.i18n.tableHeaderText">
...@@ -79,14 +79,14 @@ export default { ...@@ -79,14 +79,14 @@ export default {
:is-loading-groups="isLoadingGroups" :is-loading-groups="isLoadingGroups"
:has-subgroups="hasSubgroups" :has-subgroups="hasSubgroups"
@fetchGroups="$emit('fetchGroups', $event)" @fetchGroups="$emit('fetchGroups', $event)"
@segmentsAdded="$emit('segmentsAdded', $event)" @enabledNamespacesAdded="$emit('enabledNamespacesAdded', $event)"
@trackModalOpenState="$emit('trackModalOpenState', $event)" @trackModalOpenState="$emit('trackModalOpenState', $event)"
/> />
</div> </div>
<devops-adoption-table <devops-adoption-table
:cols="cols" :cols="cols"
:segments="segments.nodes" :enabled-namespaces="enabledNamespaces.nodes"
@segmentsRemoved="$emit('segmentsRemoved', $event)" @enabledNamespacesRemoved="$emit('enabledNamespacesRemoved', $event)"
@trackModalOpenState="$emit('trackModalOpenState', $event)" @trackModalOpenState="$emit('trackModalOpenState', $event)"
/> />
</div> </div>
......
...@@ -11,9 +11,9 @@ import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue'; ...@@ -11,9 +11,9 @@ import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import { import {
DEVOPS_ADOPTION_TABLE_TEST_IDS, DEVOPS_ADOPTION_TABLE_TEST_IDS,
DEVOPS_ADOPTION_STRINGS, DEVOPS_ADOPTION_STRINGS,
DEVOPS_ADOPTION_SEGMENT_DELETE_MODAL_ID, DEVOPS_ADOPTION_DELETE_MODAL_ID,
DEVOPS_ADOPTION_SEGMENTS_TABLE_SORT_BY_STORAGE_KEY, DEVOPS_ADOPTION_TABLE_SORT_BY_STORAGE_KEY,
DEVOPS_ADOPTION_SEGMENTS_TABLE_SORT_DESC_STORAGE_KEY, DEVOPS_ADOPTION_TABLE_SORT_DESC_STORAGE_KEY,
DEVOPS_ADOPTION_TABLE_REMOVE_BUTTON_DISABLED, DEVOPS_ADOPTION_TABLE_REMOVE_BUTTON_DISABLED,
DEVOPS_ADOPTION_GROUP_COL_LABEL, DEVOPS_ADOPTION_GROUP_COL_LABEL,
} from '../constants'; } from '../constants';
...@@ -70,12 +70,12 @@ export default { ...@@ -70,12 +70,12 @@ export default {
...i18n, ...i18n,
removeButtonDisabled: DEVOPS_ADOPTION_TABLE_REMOVE_BUTTON_DISABLED, removeButtonDisabled: DEVOPS_ADOPTION_TABLE_REMOVE_BUTTON_DISABLED,
}, },
devopsSegmentDeleteModalId: DEVOPS_ADOPTION_SEGMENT_DELETE_MODAL_ID, deleteModalId: DEVOPS_ADOPTION_DELETE_MODAL_ID,
testids: DEVOPS_ADOPTION_TABLE_TEST_IDS, testids: DEVOPS_ADOPTION_TABLE_TEST_IDS,
sortByStorageKey: DEVOPS_ADOPTION_SEGMENTS_TABLE_SORT_BY_STORAGE_KEY, sortByStorageKey: DEVOPS_ADOPTION_TABLE_SORT_BY_STORAGE_KEY,
sortDescStorageKey: DEVOPS_ADOPTION_SEGMENTS_TABLE_SORT_DESC_STORAGE_KEY, sortDescStorageKey: DEVOPS_ADOPTION_TABLE_SORT_DESC_STORAGE_KEY,
props: { props: {
segments: { enabledNamespaces: {
type: Array, type: Array,
required: true, required: true,
}, },
...@@ -88,7 +88,7 @@ export default { ...@@ -88,7 +88,7 @@ export default {
return { return {
sortBy: NAME_HEADER, sortBy: NAME_HEADER,
sortDesc: false, sortDesc: false,
selectedSegment: null, selectedNamespace: null,
}; };
}, },
computed: { computed: {
...@@ -113,8 +113,8 @@ export default { ...@@ -113,8 +113,8 @@ export default {
}, },
}, },
methods: { methods: {
setSelectedSegment(segment) { setSelectedNamespace(namespace) {
this.selectedSegment = segment; this.selectedNamespace = namespace;
}, },
headerSlotName(key) { headerSlotName(key) {
return `head(${key})`; return `head(${key})`;
...@@ -149,7 +149,7 @@ export default { ...@@ -149,7 +149,7 @@ export default {
/> />
<gl-table <gl-table
:fields="tableHeaderFields" :fields="tableHeaderFields"
:items="segments" :items="enabledNamespaces"
:sort-by.sync="sortBy" :sort-by.sync="sortBy"
:sort-desc.sync="sortDesc" :sort-desc.sync="sortDesc"
thead-class="gl-border-t-0 gl-border-b-solid gl-border-b-1 gl-border-b-gray-100" thead-class="gl-border-t-0 gl-border-b-solid gl-border-b-1 gl-border-b-gray-100"
...@@ -169,7 +169,7 @@ export default { ...@@ -169,7 +169,7 @@ export default {
</template> </template>
<template #cell(name)="{ item }"> <template #cell(name)="{ item }">
<div :data-testid="$options.testids.SEGMENT"> <div :data-testid="$options.testids.NAMESPACE">
<strong v-if="item.latestSnapshot">{{ item.namespace.fullName }}</strong> <strong v-if="item.latestSnapshot">{{ item.namespace.fullName }}</strong>
<template v-else> <template v-else>
<span class="gl-text-gray-400">{{ item.namespace.fullName }}</span> <span class="gl-text-gray-400">{{ item.namespace.fullName }}</span>
...@@ -196,20 +196,20 @@ export default { ...@@ -196,20 +196,20 @@ export default {
:data-testid="$options.testids.ACTIONS" :data-testid="$options.testids.ACTIONS"
> >
<gl-button <gl-button
v-gl-modal="$options.devopsSegmentDeleteModalId" v-gl-modal="$options.deleteModalId"
:disabled="isCurrentGroup(item)" :disabled="isCurrentGroup(item)"
category="tertiary" category="tertiary"
icon="remove" icon="remove"
:aria-label="$options.i18n.removeButton" :aria-label="$options.i18n.removeButton"
@click="setSelectedSegment(item)" @click="setSelectedNamespace(item)"
/> />
</span> </span>
</template> </template>
</gl-table> </gl-table>
<devops-adoption-delete-modal <devops-adoption-delete-modal
v-if="selectedSegment" v-if="selectedNamespace"
:segment="selectedSegment" :namespace="selectedNamespace"
@segmentsRemoved="$emit('segmentsRemoved', $event)" @enabledNamespacesRemoved="$emit('enabledNamespacesRemoved', $event)"
@trackModalOpenState="$emit('trackModalOpenState', $event)" @trackModalOpenState="$emit('trackModalOpenState', $event)"
/> />
</div> </div>
......
...@@ -8,14 +8,14 @@ export const DEBOUNCE_DELAY = 500; ...@@ -8,14 +8,14 @@ export const DEBOUNCE_DELAY = 500;
export const DEVOPS_ADOPTION_PROGRESS_BAR_HEIGHT = '8px'; export const DEVOPS_ADOPTION_PROGRESS_BAR_HEIGHT = '8px';
export const DEVOPS_ADOPTION_SEGMENT_DELETE_MODAL_ID = 'devopsSegmentDeleteModal'; export const DEVOPS_ADOPTION_DELETE_MODAL_ID = 'devopsDeleteModal';
export const DATE_TIME_FORMAT = 'yyyy-mm-dd HH:MM'; export const DATE_TIME_FORMAT = 'yyyy-mm-dd HH:MM';
export const DEVOPS_ADOPTION_ERROR_KEYS = { export const DEVOPS_ADOPTION_ERROR_KEYS = {
groups: 'groupsError', groups: 'groupsError',
segments: 'segmentsError', enabledNamespaces: 'enabledNamespacesError',
addSegment: 'addSegmentsError', addEnabledNamespaces: 'addEnabledNamespacesError',
}; };
export const TABLE_HEADER_TEXT = s__( export const TABLE_HEADER_TEXT = s__(
...@@ -46,10 +46,10 @@ export const DEVOPS_ADOPTION_STRINGS = { ...@@ -46,10 +46,10 @@ export const DEVOPS_ADOPTION_STRINGS = {
[DEVOPS_ADOPTION_ERROR_KEYS.groups]: s__( [DEVOPS_ADOPTION_ERROR_KEYS.groups]: s__(
'DevopsAdoption|There was an error fetching Groups. Please refresh the page.', 'DevopsAdoption|There was an error fetching Groups. Please refresh the page.',
), ),
[DEVOPS_ADOPTION_ERROR_KEYS.segments]: s__( [DEVOPS_ADOPTION_ERROR_KEYS.enabledNamespaces]: s__(
'DevopsAdoption|There was an error fetching Group adoption data. Please refresh the page.', 'DevopsAdoption|There was an error fetching Group adoption data. Please refresh the page.',
), ),
[DEVOPS_ADOPTION_ERROR_KEYS.addSegment]: s__( [DEVOPS_ADOPTION_ERROR_KEYS.addEnabledNamespaces]: s__(
'DevopsAdoption|There was an error enabling the current group. Please refresh the page.', 'DevopsAdoption|There was an error enabling the current group. Please refresh the page.',
), ),
tableHeader: { tableHeader: {
...@@ -92,17 +92,15 @@ export const DEVOPS_ADOPTION_STRINGS = { ...@@ -92,17 +92,15 @@ export const DEVOPS_ADOPTION_STRINGS = {
export const DEVOPS_ADOPTION_TABLE_TEST_IDS = { export const DEVOPS_ADOPTION_TABLE_TEST_IDS = {
TABLE_HEADERS: 'header', TABLE_HEADERS: 'header',
SEGMENT: 'segmentCol', NAMESPACE: 'namespaceCol',
ACTIONS: 'actionsCol', ACTIONS: 'actionsCol',
LOCAL_STORAGE_SORT_BY: 'localStorageSortBy', LOCAL_STORAGE_SORT_BY: 'localStorageSortBy',
LOCAL_STORAGE_SORT_DESC: 'localStorageSortDesc', LOCAL_STORAGE_SORT_DESC: 'localStorageSortDesc',
}; };
export const DEVOPS_ADOPTION_SEGMENTS_TABLE_SORT_BY_STORAGE_KEY = export const DEVOPS_ADOPTION_TABLE_SORT_BY_STORAGE_KEY = 'devops_adoption_table_sort_by';
'devops_adoption_segments_table_sort_by';
export const DEVOPS_ADOPTION_SEGMENTS_TABLE_SORT_DESC_STORAGE_KEY = export const DEVOPS_ADOPTION_TABLE_SORT_DESC_STORAGE_KEY = 'devops_adoption_table_sort_desc';
'devops_adoption_segments_table_sort_desc';
export const DEVOPS_ADOPTION_GROUP_COL_LABEL = __('Group'); export const DEVOPS_ADOPTION_GROUP_COL_LABEL = __('Group');
......
import produce from 'immer'; import produce from 'immer';
import devopsAdoptionEnabledNamespacesQuery from '../graphql/queries/devops_adoption_enabled_namespaces.query.graphql'; import devopsAdoptionEnabledNamespacesQuery from '../graphql/queries/devops_adoption_enabled_namespaces.query.graphql';
export const addSegmentsToCache = (store, segments, variables) => { export const addEnabledNamespacesToCache = (store, enabledNamespaces, variables) => {
const sourceData = store.readQuery({ const sourceData = store.readQuery({
query: devopsAdoptionEnabledNamespacesQuery, query: devopsAdoptionEnabledNamespacesQuery,
variables, variables,
...@@ -10,7 +10,7 @@ export const addSegmentsToCache = (store, segments, variables) => { ...@@ -10,7 +10,7 @@ export const addSegmentsToCache = (store, segments, variables) => {
const data = produce(sourceData, (draftData) => { const data = produce(sourceData, (draftData) => {
draftData.devopsAdoptionEnabledNamespaces.nodes = [ draftData.devopsAdoptionEnabledNamespaces.nodes = [
...draftData.devopsAdoptionEnabledNamespaces.nodes, ...draftData.devopsAdoptionEnabledNamespaces.nodes,
...segments, ...enabledNamespaces,
]; ];
}); });
...@@ -21,7 +21,7 @@ export const addSegmentsToCache = (store, segments, variables) => { ...@@ -21,7 +21,7 @@ export const addSegmentsToCache = (store, segments, variables) => {
}); });
}; };
export const deleteSegmentsFromCache = (store, segmentIds, variables) => { export const deleteEnabledNamespacesFromCache = (store, enabledNamespaceIds, variables) => {
const sourceData = store.readQuery({ const sourceData = store.readQuery({
query: devopsAdoptionEnabledNamespacesQuery, query: devopsAdoptionEnabledNamespacesQuery,
variables, variables,
...@@ -29,7 +29,7 @@ export const deleteSegmentsFromCache = (store, segmentIds, variables) => { ...@@ -29,7 +29,7 @@ export const deleteSegmentsFromCache = (store, segmentIds, variables) => {
const updatedData = produce(sourceData, (draftData) => { const updatedData = produce(sourceData, (draftData) => {
draftData.devopsAdoptionEnabledNamespaces.nodes = draftData.devopsAdoptionEnabledNamespaces.nodes.filter( draftData.devopsAdoptionEnabledNamespaces.nodes = draftData.devopsAdoptionEnabledNamespaces.nodes.filter(
({ id }) => !segmentIds.includes(id), ({ id }) => !enabledNamespaceIds.includes(id),
); );
}); });
......
import { isToday } from '~/lib/utils/datetime_utility'; import { isToday } from '~/lib/utils/datetime_utility';
/** /**
* A helper function which accepts the segments, * A helper function which accepts the enabledNamespaces,
* *
* @param {Object} params the segment data, timestamp and check for open modals * @param {Object} params the enabledNamespaces data, timestamp and check for open modals
* *
* @return {Boolean} a boolean to determine if table data should be polled * @return {Boolean} a boolean to determine if table data should be polled
*/ */
export const shouldPollTableData = ({ segments, timestamp, openModal }) => { export const shouldPollTableData = ({ enabledNamespaces, timestamp, openModal }) => {
if (openModal) { if (openModal) {
return false; return false;
} else if (!segments.length) { } else if (!enabledNamespaces.length) {
return true; return true;
} }
const anyPendingSegments = segments.some((node) => node.latestSnapshot === null); const anyPendingEnabledNamespaces = enabledNamespaces.some(
(node) => node.latestSnapshot === null,
);
const dataNotRefreshedToday = !isToday(new Date(timestamp)); const dataNotRefreshedToday = !isToday(new Date(timestamp));
return anyPendingSegments || dataNotRefreshedToday; return anyPendingEnabledNamespaces || dataNotRefreshedToday;
}; };
...@@ -149,8 +149,8 @@ describe('DevopsAdoptionAddDropdown', () => { ...@@ -149,8 +149,8 @@ describe('DevopsAdoptionAddDropdown', () => {
}); });
}); });
it('emits the segmentsAdded event', () => { it('emits the enabledNamespacesAdded event', () => {
const [params] = wrapper.emitted().segmentsAdded[0]; const [params] = wrapper.emitted().enabledNamespacesAdded[0];
expect(params).toStrictEqual([devopsAdoptionNamespaceData.nodes[0]]); expect(params).toStrictEqual([devopsAdoptionNamespaceData.nodes[0]]);
}); });
...@@ -174,8 +174,8 @@ describe('DevopsAdoptionAddDropdown', () => { ...@@ -174,8 +174,8 @@ describe('DevopsAdoptionAddDropdown', () => {
); );
}); });
it('does not emit the segmentsAdded event', () => { it('does not emit the enabledNamespacesAdded event', () => {
expect(wrapper.emitted().segmentsAdded).not.toBeDefined(); expect(wrapper.emitted().enabledNamespacesAdded).not.toBeDefined();
}); });
}); });
}); });
......
...@@ -15,7 +15,7 @@ import { ...@@ -15,7 +15,7 @@ import {
import bulkEnableDevopsAdoptionNamespacesMutation from 'ee/analytics/devops_report/devops_adoption/graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql'; import bulkEnableDevopsAdoptionNamespacesMutation from 'ee/analytics/devops_report/devops_adoption/graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql';
import devopsAdoptionEnabledNamespaces from 'ee/analytics/devops_report/devops_adoption/graphql/queries/devops_adoption_enabled_namespaces.query.graphql'; import devopsAdoptionEnabledNamespaces from 'ee/analytics/devops_report/devops_adoption/graphql/queries/devops_adoption_enabled_namespaces.query.graphql';
import getGroupsQuery from 'ee/analytics/devops_report/devops_adoption/graphql/queries/get_groups.query.graphql'; import getGroupsQuery from 'ee/analytics/devops_report/devops_adoption/graphql/queries/get_groups.query.graphql';
import { addSegmentsToCache } from 'ee/analytics/devops_report/devops_adoption/utils/cache_updates'; import { addEnabledNamespacesToCache } from 'ee/analytics/devops_report/devops_adoption/utils/cache_updates';
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';
...@@ -24,7 +24,7 @@ import API from '~/api'; ...@@ -24,7 +24,7 @@ import API from '~/api';
import { groupNodes, devopsAdoptionNamespaceData } from '../mock_data'; import { groupNodes, devopsAdoptionNamespaceData } from '../mock_data';
jest.mock('ee/analytics/devops_report/devops_adoption/utils/cache_updates', () => ({ jest.mock('ee/analytics/devops_report/devops_adoption/utils/cache_updates', () => ({
addSegmentsToCache: jest.fn(), addEnabledNamespacesToCache: jest.fn(),
})); }));
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -234,9 +234,9 @@ describe('DevopsAdoptionApp', () => { ...@@ -234,9 +234,9 @@ describe('DevopsAdoptionApp', () => {
); );
}); });
it('calls addSegmentsToCache with the correct variables', () => { it('calls addEnabledNamespacesToCache with the correct variables', () => {
expect(addSegmentsToCache).toHaveBeenCalledTimes(1); expect(addEnabledNamespacesToCache).toHaveBeenCalledTimes(1);
expect(addSegmentsToCache).toHaveBeenCalledWith( expect(addEnabledNamespacesToCache).toHaveBeenCalledWith(
expect.anything(), expect.anything(),
[devopsAdoptionNamespaceData.nodes[0]], [devopsAdoptionNamespaceData.nodes[0]],
{ {
...@@ -270,7 +270,7 @@ describe('DevopsAdoptionApp', () => { ...@@ -270,7 +270,7 @@ describe('DevopsAdoptionApp', () => {
it('displays the error message ', () => { it('displays the error message ', () => {
const alert = wrapper.findComponent(GlAlert); const alert = wrapper.findComponent(GlAlert);
expect(alert.exists()).toBe(true); expect(alert.exists()).toBe(true);
expect(alert.text()).toBe(DEVOPS_ADOPTION_STRINGS.app.addSegmentsError); expect(alert.text()).toBe(DEVOPS_ADOPTION_STRINGS.app.addEnabledNamespacesError);
}); });
it('calls Sentry', () => { it('calls Sentry', () => {
...@@ -301,7 +301,7 @@ describe('DevopsAdoptionApp', () => { ...@@ -301,7 +301,7 @@ describe('DevopsAdoptionApp', () => {
it('displays the error message ', () => { it('displays the error message ', () => {
const alert = wrapper.findComponent(GlAlert); const alert = wrapper.findComponent(GlAlert);
expect(alert.exists()).toBe(true); expect(alert.exists()).toBe(true);
expect(alert.text()).toBe(DEVOPS_ADOPTION_STRINGS.app.segmentsError); expect(alert.text()).toBe(DEVOPS_ADOPTION_STRINGS.app.enabledNamespacesError);
}); });
it('calls Sentry', () => { it('calls Sentry', () => {
......
...@@ -4,7 +4,7 @@ import { createLocalVue, shallowMount } from '@vue/test-utils'; ...@@ -4,7 +4,7 @@ import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import DevopsAdoptionDeleteModal from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_delete_modal.vue'; import DevopsAdoptionDeleteModal from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_delete_modal.vue';
import { DEVOPS_ADOPTION_SEGMENT_DELETE_MODAL_ID } from 'ee/analytics/devops_report/devops_adoption/constants'; import { DEVOPS_ADOPTION_DELETE_MODAL_ID } from 'ee/analytics/devops_report/devops_adoption/constants';
import disableDevopsAdoptionNamespaceMutation from 'ee/analytics/devops_report/devops_adoption/graphql/mutations/disable_devops_adoption_namespace.mutation.graphql'; import disableDevopsAdoptionNamespaceMutation from 'ee/analytics/devops_report/devops_adoption/graphql/mutations/disable_devops_adoption_namespace.mutation.graphql';
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';
...@@ -38,16 +38,16 @@ const mutateWithErrors = jest.fn().mockRejectedValue(genericDeleteErrorMessage); ...@@ -38,16 +38,16 @@ const mutateWithErrors = jest.fn().mockRejectedValue(genericDeleteErrorMessage);
describe('DevopsAdoptionDeleteModal', () => { describe('DevopsAdoptionDeleteModal', () => {
let wrapper; let wrapper;
const createComponent = ({ deleteSegmentsSpy = mutate, props = {} } = {}) => { const createComponent = ({ deleteEnabledNamespacesSpy = mutate, props = {} } = {}) => {
const mockApollo = createMockApollo([ const mockApollo = createMockApollo([
[disableDevopsAdoptionNamespaceMutation, deleteSegmentsSpy], [disableDevopsAdoptionNamespaceMutation, deleteEnabledNamespacesSpy],
]); ]);
wrapper = shallowMount(DevopsAdoptionDeleteModal, { wrapper = shallowMount(DevopsAdoptionDeleteModal, {
localVue, localVue,
apolloProvider: mockApollo, apolloProvider: mockApollo,
propsData: { propsData: {
segment: devopsAdoptionNamespaceData.nodes[0], namespace: devopsAdoptionNamespaceData.nodes[0],
...props, ...props,
}, },
stubs: { stubs: {
...@@ -63,7 +63,6 @@ describe('DevopsAdoptionDeleteModal', () => { ...@@ -63,7 +63,6 @@ describe('DevopsAdoptionDeleteModal', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
describe('default display', () => { describe('default display', () => {
...@@ -73,7 +72,7 @@ describe('DevopsAdoptionDeleteModal', () => { ...@@ -73,7 +72,7 @@ describe('DevopsAdoptionDeleteModal', () => {
const modal = findModal(); const modal = findModal();
expect(modal.exists()).toBe(true); expect(modal.exists()).toBe(true);
expect(modal.props('modalId')).toBe(DEVOPS_ADOPTION_SEGMENT_DELETE_MODAL_ID); expect(modal.props('modalId')).toBe(DEVOPS_ADOPTION_DELETE_MODAL_ID);
}); });
it('displays the confirmation message', () => { it('displays the confirmation message', () => {
...@@ -104,7 +103,7 @@ describe('DevopsAdoptionDeleteModal', () => { ...@@ -104,7 +103,7 @@ describe('DevopsAdoptionDeleteModal', () => {
describe('submitting the form', () => { describe('submitting the form', () => {
describe('while waiting for the mutation', () => { describe('while waiting for the mutation', () => {
beforeEach(() => createComponent({ deleteSegmentsSpy: mutateLoading })); beforeEach(() => createComponent({ deleteEnabledNamespacesSpy: mutateLoading }));
it('disables the cancel button', async () => { it('disables the cancel button', async () => {
expect(cancelButtonDisabledState()).toBe(false); expect(cancelButtonDisabledState()).toBe(false);
...@@ -142,8 +141,8 @@ describe('DevopsAdoptionDeleteModal', () => { ...@@ -142,8 +141,8 @@ describe('DevopsAdoptionDeleteModal', () => {
}); });
}); });
it('emits segmentsRemoved with the correct variables', () => { it('emits dNamespacesRemoved with the correct variables', () => {
const [params] = wrapper.emitted().segmentsRemoved[0]; const [params] = wrapper.emitted().enabledNamespacesRemoved[0];
expect(params).toStrictEqual([devopsAdoptionNamespaceData.nodes[0].id]); expect(params).toStrictEqual([devopsAdoptionNamespaceData.nodes[0].id]);
}); });
...@@ -161,7 +160,7 @@ describe('DevopsAdoptionDeleteModal', () => { ...@@ -161,7 +160,7 @@ describe('DevopsAdoptionDeleteModal', () => {
`( `(
'displays a $errorType error if the mutation has a $errorLocation error', 'displays a $errorType error if the mutation has a $errorLocation error',
async ({ mutationSpy, message }) => { async ({ mutationSpy, message }) => {
createComponent({ deleteSegmentsSpy: mutationSpy }); createComponent({ deleteEnabledNamespacesSpy: mutationSpy });
findModal().vm.$emit('primary', mockEvent); findModal().vm.$emit('primary', mockEvent);
...@@ -178,7 +177,7 @@ describe('DevopsAdoptionDeleteModal', () => { ...@@ -178,7 +177,7 @@ describe('DevopsAdoptionDeleteModal', () => {
it('calls sentry on top level error', async () => { it('calls sentry on top level error', async () => {
jest.spyOn(Sentry, 'captureException'); jest.spyOn(Sentry, 'captureException');
createComponent({ deleteSegmentsSpy: mutateWithErrors }); createComponent({ deleteEnabledNamespacesSpy: mutateWithErrors });
findModal().vm.$emit('primary', mockEvent); findModal().vm.$emit('primary', mockEvent);
......
...@@ -27,7 +27,6 @@ describe('DevopsAdoptionEmptyState', () => { ...@@ -27,7 +27,6 @@ describe('DevopsAdoptionEmptyState', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
it('contains the correct svg', () => { it('contains the correct svg', () => {
......
...@@ -17,11 +17,11 @@ describe('DevopsAdoptionSection', () => { ...@@ -17,11 +17,11 @@ describe('DevopsAdoptionSection', () => {
shallowMount(DevopsAdoptionSection, { shallowMount(DevopsAdoptionSection, {
propsData: { propsData: {
isLoading: false, isLoading: false,
hasSegmentsData: true, hasEnabledNamespaceData: true,
timestamp: '2020-10-31 23:59', timestamp: '2020-10-31 23:59',
hasGroupData: true, hasGroupData: true,
cols: DEVOPS_ADOPTION_TABLE_CONFIGURATION[0].cols, cols: DEVOPS_ADOPTION_TABLE_CONFIGURATION[0].cols,
segments: devopsAdoptionNamespaceData, enabledNamespaces: devopsAdoptionNamespaceData,
disabledGroupNodes: groupNodes, disabledGroupNodes: groupNodes,
searchTerm: '', searchTerm: '',
isLoadingGroups: false, isLoadingGroups: false,
...@@ -59,7 +59,7 @@ describe('DevopsAdoptionSection', () => { ...@@ -59,7 +59,7 @@ describe('DevopsAdoptionSection', () => {
}); });
}); });
describe('with segment data', () => { describe('with enabledNamespace data', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
}); });
...@@ -81,9 +81,9 @@ describe('DevopsAdoptionSection', () => { ...@@ -81,9 +81,9 @@ describe('DevopsAdoptionSection', () => {
}); });
}); });
describe('with no segment data', () => { describe('with no enabledNamespace data', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ hasSegmentsData: false }); createComponent({ hasEnabledNamespaceData: false });
}); });
it('displays an empty state', () => { it('displays an empty state', () => {
......
...@@ -21,7 +21,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -21,7 +21,7 @@ describe('DevopsAdoptionTable', () => {
wrapper = mount(DevopsAdoptionTable, { wrapper = mount(DevopsAdoptionTable, {
propsData: { propsData: {
cols: DEVOPS_ADOPTION_TABLE_CONFIGURATION[0].cols, cols: DEVOPS_ADOPTION_TABLE_CONFIGURATION[0].cols,
segments: devopsAdoptionNamespaceData.nodes, enabledNamespaces: devopsAdoptionNamespaceData.nodes,
}, },
provide, provide,
directives: { directives: {
...@@ -100,15 +100,15 @@ describe('DevopsAdoptionTable', () => { ...@@ -100,15 +100,15 @@ describe('DevopsAdoptionTable', () => {
}); });
describe('table fields', () => { describe('table fields', () => {
describe('segment name', () => { describe('enabled namespace name', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
}); });
it('displays the correct segment name', () => { it('displays the correct name', () => {
createComponent(); createComponent();
expect(findCol(TEST_IDS.SEGMENT).text()).toBe('Group 1'); expect(findCol(TEST_IDS.NAMESPACE).text()).toBe('Group 1');
}); });
describe('"This group" badge', () => { describe('"This group" badge', () => {
...@@ -122,7 +122,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -122,7 +122,7 @@ describe('DevopsAdoptionTable', () => {
`('$scenario', ({ expected, provide }) => { `('$scenario', ({ expected, provide }) => {
createComponent({ provide }); createComponent({ provide });
const badge = findColSubComponent(TEST_IDS.SEGMENT, GlBadge); const badge = findColSubComponent(TEST_IDS.NAMESPACE, GlBadge);
expect(badge.exists()).toBe(expected); expect(badge.exists()).toBe(expected);
}); });
...@@ -134,7 +134,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -134,7 +134,7 @@ describe('DevopsAdoptionTable', () => {
}); });
it('grays the text out', () => { it('grays the text out', () => {
const name = findColRowChild(TEST_IDS.SEGMENT, 1, 'span'); const name = findColRowChild(TEST_IDS.NAMESPACE, 1, 'span');
expect(name.classes()).toStrictEqual(['gl-text-gray-400']); expect(name.classes()).toStrictEqual(['gl-text-gray-400']);
}); });
...@@ -143,7 +143,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -143,7 +143,7 @@ describe('DevopsAdoptionTable', () => {
let icon; let icon;
beforeEach(() => { beforeEach(() => {
icon = findColRowChild(TEST_IDS.SEGMENT, 1, GlIcon); icon = findColRowChild(TEST_IDS.NAMESPACE, 1, GlIcon);
}); });
it('displays the icon', () => { it('displays the icon', () => {
...@@ -198,7 +198,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -198,7 +198,7 @@ describe('DevopsAdoptionTable', () => {
createComponent(); createComponent();
wrapper.setData({ wrapper.setData({
selectedSegment: devopsAdoptionNamespaceData.nodes[0], selectedNamespace: devopsAdoptionNamespaceData.nodes[0],
}); });
}); });
...@@ -217,14 +217,14 @@ describe('DevopsAdoptionTable', () => { ...@@ -217,14 +217,14 @@ describe('DevopsAdoptionTable', () => {
headers = findTable().findAll(`[data-testid="${TEST_IDS.TABLE_HEADERS}"]`); headers = findTable().findAll(`[data-testid="${TEST_IDS.TABLE_HEADERS}"]`);
}); });
it('sorts the segments by name', async () => { it('sorts the namespaces by name', async () => {
expect(findCol(TEST_IDS.SEGMENT).text()).toBe('Group 1'); expect(findCol(TEST_IDS.NAMESPACE).text()).toBe('Group 1');
headers.at(0).trigger('click'); headers.at(0).trigger('click');
await nextTick(); await nextTick();
expect(findCol(TEST_IDS.SEGMENT).text()).toBe('Group 2'); expect(findCol(TEST_IDS.NAMESPACE).text()).toBe('Group 2');
}); });
it('should update local storage when the sort column changes', async () => { it('should update local storage when the sort column changes', async () => {
......
...@@ -95,8 +95,6 @@ export const devopsAdoptionTableHeaders = [ ...@@ -95,8 +95,6 @@ export const devopsAdoptionTableHeaders = [
}, },
]; ];
export const segmentName = 'Foooo';
export const genericErrorMessage = 'An error occurred while saving changes. Please try again.'; export const genericErrorMessage = 'An error occurred while saving changes. Please try again.';
export const dataErrorMessage = 'Name already taken.'; export const dataErrorMessage = 'Name already taken.';
......
import { import {
deleteSegmentsFromCache, deleteEnabledNamespacesFromCache,
addSegmentsToCache, addEnabledNamespacesToCache,
} from 'ee/analytics/devops_report/devops_adoption/utils/cache_updates'; } from 'ee/analytics/devops_report/devops_adoption/utils/cache_updates';
import { devopsAdoptionNamespaceData } from '../mock_data'; import { devopsAdoptionNamespaceData } from '../mock_data';
describe('addSegmentsToCache', () => { describe('addEnabledNamespacesToCache', () => {
const store = { const store = {
readQuery: jest.fn(() => ({ devopsAdoptionEnabledNamespaces: { nodes: [] } })), readQuery: jest.fn(() => ({ devopsAdoptionEnabledNamespaces: { nodes: [] } })),
writeQuery: jest.fn(), writeQuery: jest.fn(),
}; };
it('calls writeQuery with the correct response', () => { it('calls writeQuery with the correct response', () => {
addSegmentsToCache(store, devopsAdoptionNamespaceData.nodes); addEnabledNamespacesToCache(store, devopsAdoptionNamespaceData.nodes);
expect(store.writeQuery).toHaveBeenCalledWith( expect(store.writeQuery).toHaveBeenCalledWith(
expect.objectContaining({ expect.objectContaining({
...@@ -25,7 +25,7 @@ describe('addSegmentsToCache', () => { ...@@ -25,7 +25,7 @@ describe('addSegmentsToCache', () => {
}); });
}); });
describe('deleteSegmentsFromCache', () => { describe('deleteEnabledNamespacesFromCache', () => {
const store = { const store = {
readQuery: jest.fn(() => ({ devopsAdoptionEnabledNamespaces: devopsAdoptionNamespaceData })), readQuery: jest.fn(() => ({ devopsAdoptionEnabledNamespaces: devopsAdoptionNamespaceData })),
writeQuery: jest.fn(), writeQuery: jest.fn(),
...@@ -33,7 +33,7 @@ describe('deleteSegmentsFromCache', () => { ...@@ -33,7 +33,7 @@ describe('deleteSegmentsFromCache', () => {
it('calls writeQuery with the correct response', () => { it('calls writeQuery with the correct response', () => {
// Remove the item at the first index // Remove the item at the first index
deleteSegmentsFromCache(store, [devopsAdoptionNamespaceData.nodes[0].id]); deleteEnabledNamespacesFromCache(store, [devopsAdoptionNamespaceData.nodes[0].id]);
expect(store.writeQuery).toHaveBeenCalledWith( expect(store.writeQuery).toHaveBeenCalledWith(
expect.not.objectContaining({ expect.not.objectContaining({
......
...@@ -8,15 +8,15 @@ describe('shouldPollTableData', () => { ...@@ -8,15 +8,15 @@ describe('shouldPollTableData', () => {
const previousDay = '2020-07-05T00:00:00.000Z'; const previousDay = '2020-07-05T00:00:00.000Z';
it.each` it.each`
scenario | segments | timestamp | openModal | expected scenario | enabledNamespaces | timestamp | openModal | expected
${'no segment data'} | ${[]} | ${mockDate} | ${false} | ${true} ${'no namespaces data'} | ${[]} | ${mockDate} | ${false} | ${true}
${'no timestamp'} | ${comepleteData} | ${null} | ${false} | ${true} ${'no timestamp'} | ${comepleteData} | ${null} | ${false} | ${true}
${'open modal'} | ${comepleteData} | ${mockDate} | ${true} | ${false} ${'open modal'} | ${comepleteData} | ${mockDate} | ${true} | ${false}
${'segment data, timestamp is today, modal is closed'} | ${comepleteData} | ${mockDate} | ${false} | ${false} ${'namespaces data, timestamp is today, modal is closed'} | ${comepleteData} | ${mockDate} | ${false} | ${false}
${'segment data, timestamp is yesterday, modal is closed'} | ${comepleteData} | ${previousDay} | ${false} | ${true} ${'namespaces data, timestamp is yesterday, modal is closed'} | ${comepleteData} | ${previousDay} | ${false} | ${true}
${'segment data, timestamp is today, modal is open'} | ${comepleteData} | ${mockDate} | ${true} | ${false} ${'namespaces data, timestamp is today, modal is open'} | ${comepleteData} | ${mockDate} | ${true} | ${false}
${'pending segment data, timestamp is today, modal is closed'} | ${pendingData} | ${mockDate} | ${false} | ${true} ${'pending namespaces data, timestamp is today, modal is closed'} | ${pendingData} | ${mockDate} | ${false} | ${true}
`('returns $expected when $scenario', ({ segments, timestamp, openModal, expected }) => { `('returns $expected when $scenario', ({ enabledNamespaces, timestamp, openModal, expected }) => {
expect(shouldPollTableData({ segments, timestamp, openModal })).toBe(expected); expect(shouldPollTableData({ enabledNamespaces, timestamp, openModal })).toBe(expected);
}); });
}); });
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