Skip to content

Commit

Permalink
Revert "frontend-build updated to v12 (#277)"
Browse files Browse the repository at this point in the history
This reverts commit 403db9f.
  • Loading branch information
BilalQamar95 authored Dec 1, 2022
1 parent 403db9f commit 469f77d
Show file tree
Hide file tree
Showing 14 changed files with 5,927 additions and 4,795 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@edx/frontend-build');

module.exports = createConfig('eslint');
module.exports = createConfig('eslint');
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ jobs:
strategy:
matrix:
node: [16]
npm: [8.5.x]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -16,7 +15,6 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: npm install -g npm@${{ matrix.npm }}
- name: Install dependencies
run: npm ci
- name: Validate package-lock.json changes
Expand Down
10,395 changes: 5,733 additions & 4,662 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"homepage": "https://github.com/edx/frontend-component-header-edx#readme",
"devDependencies": {
"@edx/brand": "npm:@edx/brand-edx.org@2.0.8",
"@edx/frontend-build": "12.3.0",
"@edx/frontend-build": "11.0.2",
"@edx/frontend-platform": "^2.0.0 || ^3.0.0",
"@edx/paragon": "19.9.0",
"@edx/reactifex": "2.1.1",
Expand Down
6 changes: 3 additions & 3 deletions src/Avatar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import PropTypes from 'prop-types';

import { AvatarIcon } from './Icons';

const Avatar = ({
function Avatar({
size,
src,
alt,
className,
}) => {
}) {
const avatar = src ? (
<img className="d-block w-100 h-100" src={src} alt={alt} />
) : (
Expand All @@ -23,7 +23,7 @@ const Avatar = ({
{avatar}
</span>
);
};
}

Avatar.propTypes = {
src: PropTypes.string,
Expand Down
4 changes: 2 additions & 2 deletions src/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ subscribe(APP_CONFIG_INITIALIZED, () => {
}, 'Header additional config');
});

const Header = ({ intl }) => {
function Header({ intl }) {
const { authenticatedUser, config } = useContext(AppContext);
const {
enterpriseLearnerPortalLink,
Expand Down Expand Up @@ -165,7 +165,7 @@ const Header = ({ intl }) => {
</Responsive>
</>
);
};
}

Header.propTypes = {
intl: intlShape.isRequired,
Expand Down
186 changes: 118 additions & 68 deletions src/Header.test.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/prop-types */
import React from 'react';
import { act } from 'react-dom/test-utils';
import { IntlProvider } from '@edx/frontend-platform/i18n';
Expand All @@ -25,18 +24,6 @@ const APP_CONTEXT_CONFIG = {
LOGO_URL: process.env.LOGO_URL,
};

const HeaderContext = ({ width, contextValue }) => (
<ResponsiveContext.Provider value={width}>
<IntlProvider locale="en" messages={{}}>
<AppContext.Provider
value={contextValue}
>
<Header />
</AppContext.Provider>
</IntlProvider>
</ResponsiveContext.Provider>
);

describe('<Header />', () => {
beforeEach(() => {
useEnterpriseConfig.mockReturnValue({});
Expand All @@ -58,45 +45,72 @@ describe('<Header />', () => {
};

it('renders correctly for unauthenticated users on desktop', () => {
const contextValue = {
authenticatedUser: null,
config: APP_CONTEXT_CONFIG,
};
const component = <HeaderContext width={{ width: 1280 }} contextValue={contextValue} />;
const component = (
<ResponsiveContext.Provider value={{ width: 1280 }}>
<IntlProvider locale="en" messages={{}}>
<AppContext.Provider
value={{
authenticatedUser: null,
config: APP_CONTEXT_CONFIG,
}}
>
<Header />
</AppContext.Provider>
</IntlProvider>
</ResponsiveContext.Provider>
);

const wrapper = TestRenderer.create(component);

expect(wrapper.toJSON()).toMatchSnapshot();
});

it('renders correctly for authenticated users on desktop', () => {
const contextValue = {
authenticatedUser: {
userId: 'abc123',
username: 'edX',
roles: [],
administrator: false,
},
config: APP_CONTEXT_CONFIG,
};
const component = <HeaderContext width={{ width: 1280 }} contextValue={contextValue} />;
const component = (
<ResponsiveContext.Provider value={{ width: 1280 }}>
<IntlProvider locale="en" messages={{}}>
<AppContext.Provider
value={{
authenticatedUser: {
userId: 'abc123',
username: 'edX',
roles: [],
administrator: false,
},
config: APP_CONTEXT_CONFIG,
}}
>
<Header />
</AppContext.Provider>
</IntlProvider>
</ResponsiveContext.Provider>
);

const wrapper = TestRenderer.create(component);

expect(wrapper.toJSON()).toMatchSnapshot();
});

it('renders correctly for authenticated users on desktop with or without learner portal links', async () => {
const contextValue = {
authenticatedUser: {
userId: 'abc123',
username: 'edX',
roles: [],
administrator: false,
},
config: APP_CONTEXT_CONFIG,
};
const component = <HeaderContext width={{ width: 1280 }} contextValue={contextValue} />;
const component = (
<ResponsiveContext.Provider value={{ width: 1280 }}>
<IntlProvider locale="en" messages={{}}>
<AppContext.Provider
value={{
authenticatedUser: {
userId: 'abc123',
username: 'edX',
roles: [],
administrator: false,
},
config: APP_CONTEXT_CONFIG,
}}
>
<Header />
</AppContext.Provider>
</IntlProvider>
</ResponsiveContext.Provider>
);

// When learner portal links are not present, Order History should be a dropdown item
let wrapper = mount(component);
Expand Down Expand Up @@ -126,28 +140,46 @@ describe('<Header />', () => {
});

it('renders correctly for unauthenticated users on mobile', () => {
const contextValue = {
authenticatedUser: null,
config: APP_CONTEXT_CONFIG,
};
const component = <HeaderContext width={{ width: 500 }} contextValue={contextValue} />;
const component = (
<ResponsiveContext.Provider value={{ width: 500 }}>
<IntlProvider locale="en" messages={{}}>
<AppContext.Provider
value={{
authenticatedUser: null,
config: APP_CONTEXT_CONFIG,
}}
>
<Header />
</AppContext.Provider>
</IntlProvider>
</ResponsiveContext.Provider>
);

const wrapper = TestRenderer.create(component);

expect(wrapper.toJSON()).toMatchSnapshot();
});

it('renders correctly for authenticated users on mobile', () => {
const contextValue = {
authenticatedUser: {
userId: 'abc123',
username: 'edX',
roles: [],
administrator: false,
},
config: APP_CONTEXT_CONFIG,
};
const component = <HeaderContext width={{ width: 500 }} contextValue={contextValue} />;
const component = (
<ResponsiveContext.Provider value={{ width: 500 }}>
<IntlProvider locale="en" messages={{}}>
<AppContext.Provider
value={{
authenticatedUser: {
userId: 'abc123',
username: 'edX',
roles: [],
administrator: false,
},
config: APP_CONTEXT_CONFIG,
}}
>
<Header />
</AppContext.Provider>
</IntlProvider>
</ResponsiveContext.Provider>
);

const wrapper = TestRenderer.create(component);

Expand All @@ -168,28 +200,46 @@ describe('<Header />', () => {
});

it('renders correctly for unauthenticated users when minimal', () => {
const contextValue = {
authenticatedUser: null,
config: APP_CONTEXT_CONFIG,
};
const component = <HeaderContext width={{ width: 1280 }} contextValue={contextValue} />;
const component = (
<ResponsiveContext.Provider value={{ width: 1280 }}>
<IntlProvider locale="en" messages={{}}>
<AppContext.Provider
value={{
authenticatedUser: null,
config: APP_CONTEXT_CONFIG,
}}
>
<Header />
</AppContext.Provider>
</IntlProvider>
</ResponsiveContext.Provider>
);

const wrapper = TestRenderer.create(component);

expect(wrapper.toJSON()).toMatchSnapshot();
});

it('renders correctly for authenticated users when minimal', () => {
const contextValue = {
authenticatedUser: {
userId: 'abc123',
username: 'edX',
roles: [],
administrator: false,
},
config: APP_CONTEXT_CONFIG,
};
const component = <HeaderContext width={{ width: 1280 }} contextValue={contextValue} />;
const component = (
<ResponsiveContext.Provider value={{ width: 1280 }}>
<IntlProvider locale="en" messages={{}}>
<AppContext.Provider
value={{
authenticatedUser: {
userId: 'abc123',
username: 'edX',
roles: [],
administrator: false,
},
config: APP_CONTEXT_CONFIG,
}}
>
<Header />
</AppContext.Provider>
</IntlProvider>
</ResponsiveContext.Provider>
);

const wrapper = TestRenderer.create(component);

Expand Down
6 changes: 3 additions & 3 deletions src/Icons.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

export const MenuIcon = (props) => (
export const MenuIcon = props => (
<svg
width="24px"
height="24px"
Expand All @@ -14,7 +14,7 @@ export const MenuIcon = (props) => (
</svg>
);

export const AvatarIcon = (props) => (
export const AvatarIcon = props => (
<svg
width="24px"
height="24px"
Expand All @@ -29,7 +29,7 @@ export const AvatarIcon = (props) => (
</svg>
);

export const CaretIcon = (props) => (
export const CaretIcon = props => (
<svg
width="16px"
height="16px"
Expand Down
22 changes: 13 additions & 9 deletions src/Logo.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
import React from 'react';
import PropTypes from 'prop-types';

const Logo = ({ src, alt, ...attributes }) => (
<img src={src} alt={alt} {...attributes} />
);
function Logo({ src, alt, ...attributes }) {
return (
<img src={src} alt={alt} {...attributes} />
);
}

Logo.propTypes = {
src: PropTypes.string.isRequired,
alt: PropTypes.string.isRequired,
};

const LinkedLogo = ({
function LinkedLogo({
href,
src,
alt,
...attributes
}) => (
<a href={href} {...attributes}>
<img className="d-block" src={src} alt={alt} />
</a>
);
}) {
return (
<a href={href} {...attributes}>
<img className="d-block" src={src} alt={alt} />
</a>
);
}

LinkedLogo.propTypes = {
href: PropTypes.string.isRequired,
Expand Down
Loading

0 comments on commit 469f77d

Please sign in to comment.