diff --git a/src/feedback/AlertList.test.jsx b/src/feedback/AlertList.test.jsx
index 3372fdc43..05e19b00e 100644
--- a/src/feedback/AlertList.test.jsx
+++ b/src/feedback/AlertList.test.jsx
@@ -13,6 +13,27 @@ jest.mock('@edx/frontend-platform/logging', () => ({
logError: jest.fn(),
}));
+// Mock IntersectionObserver
+global.IntersectionObserver = class {
+ constructor(callback) {
+ this.callback = callback;
+ this.observedElements = new Set();
+ }
+
+ observe(element) {
+ this.callback([{ isIntersecting: true }]);
+ this.observedElements.add(element);
+ }
+
+ unobserve(element) {
+ this.observedElements.delete(element);
+ }
+
+ disconnect() {
+ this.observedElements.clear();
+ }
+};
+
describe('AlertList', () => {
let store;
diff --git a/src/feedback/AlertMessage.test.jsx b/src/feedback/AlertMessage.test.jsx
index 978c7b067..0b0e7ad75 100644
--- a/src/feedback/AlertMessage.test.jsx
+++ b/src/feedback/AlertMessage.test.jsx
@@ -1,24 +1,61 @@
import React from 'react';
+import { Provider } from 'react-redux';
+import configureMockStore from 'redux-mock-store';
import { fireEvent, render } from '@testing-library/react';
import { IntlProvider } from '@edx/frontend-platform/i18n';
import AlertMessage from './AlertMessage';
import { MESSAGE_TYPES } from './data/constants';
+const mockStore = configureMockStore();
+
+// Mock IntersectionObserver
+global.IntersectionObserver = class {
+ constructor(callback) {
+ this.callback = callback;
+ this.observedElements = new Set();
+ }
+
+ observe(element) {
+ this.callback([{ isIntersecting: true }]);
+ this.observedElements.add(element);
+ }
+
+ unobserve(element) {
+ this.observedElements.delete(element);
+ }
+
+ disconnect() {
+ this.observedElements.clear();
+ }
+};
+
describe('AlertMessage', () => {
// The AlertList test covers most of AlertMessage testing.
+ let store;
+ let state;
+
+ beforeEach(() => {
+ state = {
+ hasBeenShown: {},
+ };
+
+ store = mockStore(state);
+ });
it('should handle closing', () => {
const closeHandlerMock = jest.fn();
const component = (
-
+
+
+
);
@@ -34,12 +71,14 @@ describe('AlertMessage', () => {
const component = (
-
+
+
+
);
@@ -51,11 +90,13 @@ describe('AlertMessage', () => {
it('should render a userMessage function', () => {
const component = (
- 'Wondrous message!'}
- closeHandler={jest.fn()}
- />
+
+ 'Wondrous message!'}
+ closeHandler={jest.fn()}
+ />
+
);
@@ -66,11 +107,13 @@ describe('AlertMessage', () => {
it('should render a userMessage element', () => {
const component = (
- Wondrous message!}
- closeHandler={jest.fn()}
- />
+
+ Wondrous message!}
+ closeHandler={jest.fn()}
+ />
+
);
diff --git a/src/payment/PaymentPage.test.jsx b/src/payment/PaymentPage.test.jsx
index b2fe28c65..dbd5bcfd4 100644
--- a/src/payment/PaymentPage.test.jsx
+++ b/src/payment/PaymentPage.test.jsx
@@ -1,3 +1,4 @@
+/* eslint-disable max-classes-per-file */
/* eslint-disable react/jsx-no-constructed-context-values */
/* eslint-disable global-require */
import React from 'react';
@@ -80,6 +81,27 @@ configureI18n({
const authenticatedUser = Factory.build('userAccount');
+// Mock IntersectionObserver
+global.IntersectionObserver = class {
+ constructor(callback) {
+ this.callback = callback;
+ this.observedElements = new Set();
+ }
+
+ observe(element) {
+ this.callback([{ isIntersecting: true }]);
+ this.observedElements.add(element);
+ }
+
+ unobserve(element) {
+ this.observedElements.delete(element);
+ }
+
+ disconnect() {
+ this.observedElements.clear();
+ }
+};
+
describe('', () => {
let store;
diff --git a/src/payment/checkout/Checkout.test.jsx b/src/payment/checkout/Checkout.test.jsx
index f153eda09..95a99166e 100644
--- a/src/payment/checkout/Checkout.test.jsx
+++ b/src/payment/checkout/Checkout.test.jsx
@@ -55,6 +55,27 @@ const applePaySession = { begin: jest.fn() };
global.ApplePaySession = jest.fn().mockImplementation(() => applePaySession);
global.ApplePaySession.canMakePayments = () => true;
+// Mock IntersectionObserver
+global.IntersectionObserver = class {
+ constructor(callback) {
+ this.callback = callback;
+ this.observedElements = new Set();
+ }
+
+ observe(element) {
+ this.callback([{ isIntersecting: true }]);
+ this.observedElements.add(element);
+ }
+
+ unobserve(element) {
+ this.observedElements.delete(element);
+ }
+
+ disconnect() {
+ this.observedElements.clear();
+ }
+};
+
describe('', () => {
let wrapper;
let store;