Skip to content

Commit

Permalink
fix(NoTicket): remove second update risk ff
Browse files Browse the repository at this point in the history
  • Loading branch information
AsToNlele committed May 10, 2024
1 parent eae9438 commit 76b43d1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 95 deletions.
41 changes: 0 additions & 41 deletions cypress/utils/interceptors.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,6 @@ export const featureFlagsInterceptors = {
enabled: true,
},
},
{
name: 'ocp-advisor-ui-upgrade-risks',
enabled: true,
variant: {
name: 'disabled',
enabled: true,
},
},
],
},
}).as('upgradeRisksFlag');
Expand All @@ -216,39 +208,6 @@ export const featureFlagsInterceptors = {
toggles: [
{
name: 'ocp-advisor.upgrade-risks.enable-in-stable',
enabled: true,
variant: {
name: 'disabled',
enabled: true,
},
},
{
name: 'ocp-advisor-ui-upgrade-risks',
enabled: false,
variant: {
name: 'disabled',
enabled: true,
},
},
],
},
}).as('upgradeRisksFlagDisabled');
},
upgradeRisksDisabled2: () => {
cy.intercept('/feature_flags*', {
statusCode: 200,
body: {
toggles: [
{
name: 'ocp-advisor.upgrade-risks.enable-in-stable',
enabled: false,
variant: {
name: 'disabled',
enabled: true,
},
},
{
name: 'ocp-advisor-ui-upgrade-risks',
enabled: false,
variant: {
name: 'disabled',
Expand Down
29 changes: 1 addition & 28 deletions src/Components/ClustersListTable/ClustersListTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ describe('update risk', () => {
});
});

describe('update risk enabled and ui flag disabled', () => {
describe('update risk flag disabled', () => {
beforeEach(() => {
featureFlagsInterceptors.upgradeRisksDisabled();
});
Expand All @@ -825,31 +825,4 @@ describe('update risk enabled and ui flag disabled', () => {
});
});

describe('both update risk flags disabled', () => {
beforeEach(() => {
featureFlagsInterceptors.upgradeRisksDisabled2();
});

describe('two clusters enabled', () => {
beforeEach(() => {
clustersUpdateRisksInterceptors['successful, two labels']();
mountLessClusters();
});

it("doesn't displays two labels", () => {
cy.wait('@upgradeRisksFlagDisabled');
// Expect no requests
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.get('@clustersUpdateRisksOKTwo.all').then((interceptions) => {
expect(interceptions).to.have.length(0);
});
cy.ouiaId('loading-skeleton').should('not.exist');
cy.get(
'span[class=pf-v5-c-label__content]:contains("Update risk")'
).should('have.length', 0);
});
});
});

// TODO tests for URL parameters and chips as in RecsListTable
20 changes: 3 additions & 17 deletions src/Components/ClustersListTable/ClustersListTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,12 @@ import {
import { coerce } from 'semver';
import { BASE_PATH } from '../../Routes';
import { useAxiosWithPlatformInterceptors } from '@redhat-cloud-services/frontend-components-utilities/interceptors';
import {
useUpdateRisksFeatureFlag,
useUpdateRisksUIFeatureFlag,
} from '../../Utilities/useFeatureFlag';
import { useUpdateRisksFeatureFlag } from '../../Utilities/useFeatureFlag';

const ClustersListTable = ({
query: { isError, isUninitialized, isFetching, isSuccess, data, refetch },
}) => {
const areUpdateRisksEnabled = useUpdateRisksFeatureFlag();
const areUpdateRisksUIEnabled = useUpdateRisksUIFeatureFlag();
const intl = useIntl();
const dispatch = useDispatch();
const updateFilters = (payload) =>
Expand Down Expand Up @@ -110,13 +106,7 @@ const ClustersListTable = ({
return () => {
controller.abort();
};
}, [
filteredRows,
filters.limit,
filters.offset,
areUpdateRisksEnabled,
areUpdateRisksUIEnabled,
]);
}, [filteredRows, filters.limit, filters.offset, areUpdateRisksEnabled]);

useEffect(() => {
setRowsFiltered(false);
Expand Down Expand Up @@ -218,11 +208,7 @@ const ClustersListTable = ({

const clusterArr = paginatedItems?.map((cluster) => cluster.it.cluster_id);
let upgradeArr = [];
if (
clusterArr?.length > 0 &&
areUpdateRisksEnabled &&
areUpdateRisksUIEnabled
) {
if (clusterArr?.length > 0 && areUpdateRisksEnabled) {
let res = null;
try {
res = await axios.post(
Expand Down
9 changes: 0 additions & 9 deletions src/Utilities/useFeatureFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export default useFeatureFlag;
export const UPDATE_RISKS_ENABLE_FLAG =
'ocp-advisor.upgrade-risks.enable-in-stable';

// Second feature flag for Update Risk Label in Clusters page
export const UPDATE_RISKS_UI_ENABLE_FLAG = 'ocp-advisor-ui-upgrade-risks';

export const WORKLOADS_ENABLE_FLAG = 'ocp-advisor-ui-workloads';

export const useUpdateRisksFeatureFlag = () => {
Expand All @@ -24,12 +21,6 @@ export const useUpdateRisksFeatureFlag = () => {
return chrome.isBeta() || updateRisksEnabled;
};

export const useUpdateRisksUIFeatureFlag = () => {
const updateRisksUIEnabled = useFeatureFlag(UPDATE_RISKS_UI_ENABLE_FLAG);

return updateRisksUIEnabled;
};

export const useWorkloadsFeatureFlag = () => {
const workloadsEnabled = useFeatureFlag(WORKLOADS_ENABLE_FLAG);
return workloadsEnabled;
Expand Down

0 comments on commit 76b43d1

Please sign in to comment.