Files
frontend-app-communications/src/setupTest.js
Thomas Tracy 5d88b19c07 feat: Add ScheduledBulkEmailTable (#42)
This PR refactors some of the code around the context store to be more in line with the project organization ADR in this repo. Essentially, it splits the reducers and actions into slices used by the components that need them to prevent pollution of data in the store.

This PR also handles most of the refactor around the BulkEmailTool making use of the BulkEmailToolProvider in order to share data between components. This allows for better copyToEditor functionality, amongst other changes, as the email form now handles its state within the context store.

The Provider and its store is purposefully tied to the BulkEmailTool as to prevent any bleeding of state information between tools that may be added to the comms MFE in the future.

This PR also adds the first iteration of the scheduled emails table. This table will allow for viewing, deleting, and editing emails in the future. For now, it only adds viewing. The viewing modal DOES support copy to editor functionality but it is NOT editing the original entry and WILL schedule a new email if submitted.
2022-06-06 10:27:31 -04:00

71 lines
2.1 KiB
JavaScript

import 'core-js/stable';
import 'regenerator-runtime/runtime';
import '@testing-library/jest-dom';
import React from 'react';
import { render as rtlRender } from '@testing-library/react';
import AppProvider from '@edx/frontend-platform/react/AppProvider';
import { configure as configureI18n, IntlProvider } from '@edx/frontend-platform/i18n';
import { configure as configureLogging, MockLoggingService } from '@edx/frontend-platform/logging';
import { getConfig, mergeConfig } from '@edx/frontend-platform';
import { configure as configureAuth, MockAuthService } from '@edx/frontend-platform/auth';
import appMessages from './i18n';
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
export function initializeMockApp() {
mergeConfig({
// MICROBA-1505: Remove this when we remove the flag from config
SCHEDULE_EMAIL_SECTION: true,
authenticatedUser: {
userId: 'abc123',
username: 'Mock User',
roles: [],
administrator: false,
},
});
const loggingService = configureLogging(MockLoggingService, {
config: getConfig(),
});
const i18nService = configureI18n({
config: getConfig(),
loggingService,
messages: [appMessages],
});
const authService = configureAuth(MockAuthService, { config: getConfig(), loggingService });
return { loggingService, i18nService, authService };
}
function render(ui, options) {
// eslint-disable-next-line react/prop-types
function Wrapper({ children }) {
return (
// eslint-disable-next-line react/jsx-filename-extension
<IntlProvider locale="en">
<AppProvider>{children}</AppProvider>
</IntlProvider>
);
}
return rtlRender(ui, { wrapper: Wrapper, ...options });
}
// Re-export everything.
export * from '@testing-library/react';
// Override `render` method.
export { render };