Skip to content

Commit

Permalink
OBPIH-5231 Add front-end unit tests for Wizard and Menu components (#…
Browse files Browse the repository at this point in the history
…3701)

* OBPIH-5231 add tests for menu and logo

* OBPIH-5231 add tests for logo, menu and wizard

* OBPIH-5231 add testing library

* OBPIH-5231 fix menu snapshots

* OBPIH-5231 fix tests formatting

* OBPIH-5231 remove version boosting

* OBPIH-5231 fixes after review

* OBPIH-5231 fix wizard snapshot
  • Loading branch information
alannadolny committed Dec 13, 2022
1 parent 3900ca9 commit 0c48a21
Show file tree
Hide file tree
Showing 23 changed files with 1,925 additions and 1,028 deletions.
343 changes: 330 additions & 13 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"@babel/eslint-parser": "7.19.1",
"@babel/preset-env": "7.19.1",
"@babel/preset-react": "7.18.6",
"@testing-library/react": "12.1.5",
"acorn": "6.4.2",
"babel": "6.23.0",
"babel-eslint": "8.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Layout/Logo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Link, withRouter } from 'react-router-dom';
const Logo = ({
logoUrl,
}) => (
<div className="d-flex align-items-center logo-wrapper">
<div className="d-flex align-items-center logo-wrapper" data-testid="logo-wrapper">
<div className="logo-square">
<Link to="/openboxes">
<img
Expand Down
4 changes: 2 additions & 2 deletions src/js/components/Layout/menu/MenuItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import { RiArrowDropDownLine } from 'react-icons/ri';

const DropdownMenuItem = ({ section, active }) => (
<li className={`nav-item dropdown d-none d-md-flex justify-content-center align-items-center ${active && 'active-section'}`} >
<li className={`nav-item dropdown d-none d-md-flex justify-content-center align-items-center ${active && 'active-section'}`} data-testid="dropdownMenuItem">
<a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" aria-haspopup="true" aria-expanded="false">
{section.label}
</a>
Expand All @@ -24,7 +24,7 @@ const DropdownMenuItem = ({ section, active }) => (
const CollapseMenuItem = ({ section, active }) => {
const id = `collapse-${section?.label?.replaceAll(' ', '-')}`;
return (
<li className="collapse-nav-item nav-item justify-content-center align-items-center d-flex d-md-none" >
<li className="collapse-nav-item nav-item justify-content-center align-items-center d-flex d-md-none" data-testid="collapseMenuItem">
<a
className={`nav-link d-flex justify-content-between align-items-center w-100 ${active && 'active-section'}`}
data-toggle="collapse"
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/wizard/Wizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Wizard extends Component {
} = this.props;

return (
<div className="content-wrap">
<div className="content-wrap" data-testid="content-wrap">
<WizardTitle title={title} additionalTitle={additionalTitle} values={values} />
<WizardSteps steps={stepList} currentStep={currentPage} showStepNumber={showStepNumber} />
<div className="panel panel-primary">
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/wizard/WizardPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
const WizardPage = (props) => {
const Component = props.pageList[props.currentPage - 1];
return (
<div className="panel-body m-4">
<div className="panel-body m-4" data-testid="wizardPage">
<Component
initialValues={props.initialValues}
nextPage={props.nextPage}
Expand Down
1 change: 1 addition & 0 deletions src/js/components/wizard/WizardSteps.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const WizardSteps = props => (
<div
key={index}
className={`step-container ${props.currentStep === index + 1 ? 'active' : ''}`}
data-testid={props.currentStep === index + 1 ? 'active' : 'inactive'}
>
<div
className={props.showStepNumber ? 'circle filled' : 'circle'}
Expand Down
4 changes: 2 additions & 2 deletions src/js/components/wizard/WizardTitle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const WizardTitle = (props) => {
}

return (
<div className="panel-heading movement-number">
<div className="panel-heading movement-number" data-testid="wizardTitle">
{props.title ?
(
<div>
{
_.map(props.title, element => (
<span style={{ color: element.color }}>
<span key={element.text} style={{ color: element.color }}>
{element.text}
<span style={{ color: 'black' }}>
{element.delimeter}
Expand Down
Loading

0 comments on commit 0c48a21

Please sign in to comment.