diff --git a/client/src/components/staging-warning-modal/index.tsx b/client/src/components/staging-warning-modal/index.tsx
index 26c5eae3003..3a0fd5a2430 100644
--- a/client/src/components/staging-warning-modal/index.tsx
+++ b/client/src/components/staging-warning-modal/index.tsx
@@ -1,7 +1,6 @@
import React, { useState } from 'react';
-import { Modal } from '@freecodecamp/react-bootstrap';
import { Trans, useTranslation } from 'react-i18next';
-import { Button } from '@freecodecamp/ui';
+import { Button, Modal } from '@freecodecamp/ui';
import store from 'store';
import { Spacer } from '../helpers';
@@ -17,23 +16,11 @@ function StagingWarningModal(): JSX.Element {
setShow(false);
};
return (
-
-
-
-
- {t('staging-warning.heading')}
-
-
+
+
+
+ {t('staging-warning.heading')}
+
{t('staging-warning.p1')}
diff --git a/client/src/components/staging-warning-modal/staging-warning-modal.test.tsx b/client/src/components/staging-warning-modal/staging-warning-modal.test.tsx
index 8c816e7e9d8..8d44ab00ea9 100644
--- a/client/src/components/staging-warning-modal/staging-warning-modal.test.tsx
+++ b/client/src/components/staging-warning-modal/staging-warning-modal.test.tsx
@@ -2,23 +2,40 @@ import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import store from 'store';
import StagingWarningModal from '.';
-
describe('StagingWarningModal', () => {
+ beforeAll(() => {
+ // The Modal component uses `ResizeObserver` under the hood.
+ // However, this property is not available in JSDOM, so we need to manually add it to the window object.
+ // Ref: https://github.com/jsdom/jsdom/issues/3368
+ Object.defineProperty(window, 'ResizeObserver', {
+ writable: true,
+ value: jest.fn(() => ({
+ observe: jest.fn(),
+ unobserve: jest.fn(),
+ disconnect: jest.fn()
+ }))
+ });
+ });
+
+ afterEach(() => {
+ jest.clearAllMocks();
+ });
+
it('renders the modal successfully', () => {
render();
- expect(screen.getByTestId('staging-warning-modal')).toBeInTheDocument();
- expect(screen.getByTestId('staging-warning-modal')).toHaveClass('in');
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
});
it('closes the modal when clicking the close button', () => {
render();
fireEvent.click(screen.getByText('Close'));
- expect(screen.getByTestId('staging-warning-modal')).not.toHaveClass('in');
+
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
});
it('displays the correct modal content', () => {
render();
- const modalContent = screen.getByTestId('staging-warning-modal');
+ const modalContent = screen.getByRole('dialog');
expect(modalContent).toHaveTextContent('staging-warning.heading');
expect(modalContent).toHaveTextContent('staging-warning.p1');
expect(modalContent).toHaveTextContent('staging-warning.p2');
@@ -27,8 +44,10 @@ describe('StagingWarningModal', () => {
it('accepts Warning, stores acceptance key in local storage, and closes the modal', () => {
render();
+
fireEvent.click(screen.getByTestId('accepts-warning'));
expect(store.get('acceptedStagingWarning')).toBe(true);
- expect(screen.queryByTestId('staging-warning-modal')).not.toHaveClass('in');
+
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
});
});
diff --git a/client/src/templates/Challenges/components/reset-modal.css b/client/src/templates/Challenges/components/reset-modal.css
deleted file mode 100644
index c5376551ad4..00000000000
--- a/client/src/templates/Challenges/components/reset-modal.css
+++ /dev/null
@@ -1,24 +0,0 @@
-.reset-modal p {
- color: var(--danger-color);
-}
-
-.reset-modal-header {
- color: var(--danger-color);
- background-color: var(--danger-background);
-}
-
-.reset-modal-header h4 {
- color: var(--danger-color);
-}
-
-.reset-modal-header .close {
- color: var(--danger-color);
- font-size: 28px;
- text-shadow: none;
-}
-
-@media screen and (max-width: 767px) {
- .reset-modal .btn-lg {
- font-size: 16px;
- }
-}
diff --git a/client/src/templates/Challenges/components/reset-modal.tsx b/client/src/templates/Challenges/components/reset-modal.tsx
index 5d7b29d3c12..353e6b8e6e4 100644
--- a/client/src/templates/Challenges/components/reset-modal.tsx
+++ b/client/src/templates/Challenges/components/reset-modal.tsx
@@ -1,28 +1,20 @@
-// Package Utilities
-import { Modal } from '@freecodecamp/react-bootstrap';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { connect } from 'react-redux';
import { bindActionCreators, Dispatch } from 'redux';
import { createSelector } from 'reselect';
-import { Button } from '@freecodecamp/ui';
+import { Button, Modal } from '@freecodecamp/ui';
-// Local Utilities
import { closeModal, resetChallenge } from '../redux/actions';
import { isResetModalOpenSelector } from '../redux/selectors';
import callGA from '../../../analytics/call-ga';
-// Styles
-import './reset-modal.css';
-
-// Types
interface ResetModalProps {
close: () => void;
isOpen: boolean;
reset: () => void;
}
-// Redux Setup
const mapStateToProps = createSelector(
isResetModalOpenSelector,
(isOpen: boolean) => ({
@@ -43,25 +35,17 @@ function withActions(...fns: Array<() => void>) {
return () => fns.forEach(fn => fn());
}
-// Component
function ResetModal({ reset, close, isOpen }: ResetModalProps): JSX.Element {
const { t } = useTranslation();
if (isOpen) {
callGA({ event: 'pageview', pagePath: '/reset-modal' });
}
return (
-
-
- {t('learn.reset')}
+
+
+ {t('learn.reset')}
-
+
{t('learn.reset-warn')}
@@ -69,7 +53,7 @@ function ResetModal({ reset, close, isOpen }: ResetModalProps): JSX.Element {
-
+