Skip to content

Commit

Permalink
chore: PR test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brobro10000 committed Dec 9, 2024
1 parent 3ff18ac commit 495f87f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useContext, useState } from 'react';
import { useContext, useState } from 'react';
import PropTypes from 'prop-types';
import { useQueryClient } from '@tanstack/react-query';
import {
ActionRow, Alert, AlertModal, Button, StatefulButton,
} from '@openedx/paragon';
import { logError, logInfo } from '@edx/frontend-platform/logging';

import { useParams } from 'react-router-dom';
import { ToastsContext } from '../../../../../Toasts';
import { unenrollFromCourse } from './data';
import {
Expand All @@ -28,7 +27,6 @@ const UnenrollModal = ({
onSuccess,
}) => {
const { data: enterpriseCustomer } = useEnterpriseCustomer();
const params = useParams();
const { addToast } = useContext(ToastsContext);
const queryClient = useQueryClient();
const [btnState, setBtnState] = useState('default');
Expand All @@ -47,7 +45,7 @@ const UnenrollModal = ({
if (isBFFEnabled) {
// Determine which BFF queries need to be updated after unenrolling.
const dashboardBFFQueryKey = queryEnterpriseLearnerDashboardBFF({
enterpriseSlug: params.enterpriseSlug,
enterpriseSlug: enterpriseCustomer.slug,
}).queryKey;
const bffQueryKeysToUpdate = [dashboardBFFQueryKey];
// Update the enterpriseCourseEnrollments data in the cache for each BFF query.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ jest.mock('../../../../../app/data', () => ({
fetchEnterpriseLearnerDashboard: jest.fn(),
}));

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useParams: () => ({ enterpriseSlug: 'test-enterprise-slug' }),
}));

jest.mock('@edx/frontend-platform/logging', () => ({
logInfo: jest.fn(),
}));
Expand Down Expand Up @@ -80,7 +75,7 @@ const UnenrollModalWrapper = ({
}
if (existingBFFDashboardQueryData) {
mockQueryClient.setQueryData(
queryEnterpriseLearnerDashboardBFF({ enterpriseSlug: 'test-enterprise-slug' }).queryKey,
queryEnterpriseLearnerDashboardBFF({ enterpriseSlug: mockEnterpriseCustomer.slug }).queryKey,
existingBFFDashboardQueryData,
);
}
Expand Down Expand Up @@ -191,7 +186,7 @@ describe('<UnenrollModal />', () => {

await waitFor(() => {
const bffDashboardData = mockQueryClient.getQueryData(
queryEnterpriseLearnerDashboardBFF({ enterpriseSlug: 'test-enterprise-slug' }).queryKey,
queryEnterpriseLearnerDashboardBFF({ enterpriseSlug: mockEnterpriseCustomer.slug }).queryKey,
);
let expectedLogInfoCalls = 0;
if (isBFFEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,6 @@ describe('useUpdateCourseEnrollmentStatus', () => {
useEnterpriseCustomer.mockReturnValue({ data: mockEnterpriseCustomer });
});

afterEach(() => {
mockQueryClient = undefined;
});

it.each([
// BFF enabled && course run id matches
{
Expand Down

0 comments on commit 495f87f

Please sign in to comment.