Skip to content

Commit

Permalink
feat: getting footer and its test suite working in the shell!
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjoy committed Jul 31, 2024
1 parent a2bc5f2 commit f1e3754
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 248 deletions.
320 changes: 99 additions & 221 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"@fullhuman/postcss-purgecss": "5.0.0",
"@module-federation/runtime": "^0.2.6",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"autoprefixer": "10.4.19",
"axios": "^0.28.1",
"axios-cache-interceptor": "^0.10.7",
Expand Down Expand Up @@ -93,6 +93,7 @@
"localforage": "^1.10.0",
"localforage-memoryStorageDriver": "^0.9.2",
"lodash.camelcase": "^4.3.0",
"lodash.isempty": "^4.4.0",
"lodash.memoize": "^4.1.2",
"lodash.merge": "^4.6.2",
"lodash.snakecase": "^4.1.1",
Expand Down
1 change: 1 addition & 0 deletions shell/__mocks__/env.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
1 change: 1 addition & 0 deletions shell/__mocks__/file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'FileMock';
1 change: 1 addition & 0 deletions shell/__mocks__/svg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'SvgURL';
6 changes: 6 additions & 0 deletions shell/__mocks__/universal-cookie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const mockCookiesImplementation = {
get: jest.fn(),
remove: jest.fn(),
};

module.exports = () => mockCookiesImplementation;
2 changes: 2 additions & 0 deletions shell/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
subscribe,
} from '../runtime';

import Footer from './footer';
import Header from './header';

const messages = [];
Expand All @@ -18,6 +19,7 @@ subscribe(APP_READY, () => {
<AppProvider>
<Header />
{getConfig().app ? createElement(getConfig().app, {}) : null}
<Footer />
</AppProvider>,
document.getElementById('root'),
);
Expand Down
14 changes: 9 additions & 5 deletions shell/footer/components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { ensureConfig } from '@edx/frontend-platform';
import { AppContext } from '@edx/frontend-platform/react';
import React from 'react';

import {
AppContext,
ensureConfig,
injectIntl,
intlShape,
sendTrackEvent
} from '../../../runtime';

import messages from './Footer.messages';
import LanguageSelector from './LanguageSelector';
Expand Down
2 changes: 1 addition & 1 deletion shell/footer/components/Footer.messages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineMessages } from '@edx/frontend-platform/i18n';
import { defineMessages } from '../../../runtime';

const messages = defineMessages({
'footer.socialLinks.srText.facebook': {
Expand Down
8 changes: 4 additions & 4 deletions shell/footer/components/Footer.test.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable react/prop-types */
import React, { useMemo } from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import { useMemo } from 'react';
import renderer from 'react-test-renderer';
import { render, fireEvent, screen } from '@testing-library/react';
import { IntlProvider } from '@edx/frontend-platform/i18n';
import { AppContext } from '@edx/frontend-platform/react';

import { AppContext, IntlProvider } from '../../../runtime';

import Footer from './Footer';

Expand Down
3 changes: 1 addition & 2 deletions shell/footer/components/LanguageSelector.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n';
import { FormattedMessage, injectIntl, intlShape } from '../../../runtime';

const LanguageSelector = ({
intl, options, onSubmit, ...props
Expand Down
20 changes: 12 additions & 8 deletions shell/footer/components/studio-footer/StudioFooter.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import React, { useContext, useState } from 'react';
import _ from 'lodash';
import { intlShape, injectIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
import { ensureConfig } from '@edx/frontend-platform';
import { AppContext } from '@edx/frontend-platform/react';
import {
ActionRow,
Button,
Expand All @@ -12,6 +7,15 @@ import {
TransitionReplace,
} from '@openedx/paragon';
import { ExpandLess, ExpandMore, Help } from '@openedx/paragon/icons';
import isEmpty from 'lodash.isempty';
import { useContext, useState } from 'react';

import {
AppContext, ensureConfig,
FormattedMessage,
injectIntl,
intlShape
} from '../../../../runtime';
import messages from './messages';

ensureConfig([
Expand Down Expand Up @@ -79,7 +83,7 @@ const StudioFooter = ({
>
<FormattedMessage {...messages.studioXButtonLabel} />
</Button>
{!_.isEmpty(config.SUPPORT_EMAIL) && (
{!isEmpty(config.SUPPORT_EMAIL) && (
<Button
as="a"
href={`mailto:${config.SUPPORT_EMAIL}`}
Expand All @@ -96,11 +100,11 @@ const StudioFooter = ({
<ActionRow className="pt-3 m-0 x-small">
© {new Date().getFullYear()} <Hyperlink destination={config.MARKETING_SITE_BASE_URL} target="_blank" className="ml-2">{config.SITE_NAME}</Hyperlink>
<ActionRow.Spacer />
{!_.isEmpty(config.TERMS_OF_SERVICE_URL) && (
{!isEmpty(config.TERMS_OF_SERVICE_URL) && (
<Hyperlink destination={config.TERMS_OF_SERVICE_URL} data-testid="termsOfService">
{intl.formatMessage(messages.termsOfServiceLinkLabel)}
</Hyperlink>
)}{!_.isEmpty(config.PRIVACY_POLICY_URL) && (
)}{!isEmpty(config.PRIVACY_POLICY_URL) && (
<Hyperlink destination={config.PRIVACY_POLICY_URL} data-testid="privacyPolicy">
{intl.formatMessage(messages.privacyPolicyLinkLabel)}
</Hyperlink>
Expand Down
7 changes: 3 additions & 4 deletions shell/footer/components/studio-footer/StudioFooter.test.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* eslint-disable react/prop-types */
import React, { useMemo } from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { IntlProvider } from '@edx/frontend-platform/i18n';
import { AppContext } from '@edx/frontend-platform/react';
import { useMemo } from 'react';

import { AppContext, IntlProvider } from '../../../../runtime';
import StudioFooter from './StudioFooter';
import messages from './messages';

Expand Down
2 changes: 1 addition & 1 deletion shell/footer/components/studio-footer/messages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineMessages } from '@edx/frontend-platform/i18n';
import { defineMessages } from '../../../../runtime';

const messages = defineMessages({
openHelpButtonLabel: {
Expand Down

0 comments on commit f1e3754

Please sign in to comment.