Skip to content

Commit 91c75e8

Browse files
fix: fixing few buggy things and pushing the code now for it to be merged into the development
2 parents 7cc40e6 + f7b5313 commit 91c75e8

63 files changed

Lines changed: 1546 additions & 1772 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.development

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Development environment settings
2+
REACT_APP_APIENDPOINT="http://localhost:4500/api"
3+
SKIP_PREFLIGHT_CHECK=true
4+
DISABLE_ESLINT_PLUGIN=true
5+
REACT_APP_DEF_PWD=123Welcome!

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@
1010

1111
# misc
1212
.DS_Store
13+
14+
# Environment files
1315
.env
1416
.env.local
17+
.env.development
1518
.env.development.local
1619
.env.test.local
1720
.env.production.local
1821

22+
23+
1924
npm-debug.log*
2025
yarn-debug.log*
2126
yarn-error.log*

eslint.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ module.exports = [
3131
// Ignore test files inside /src/components
3232
'src/components/Reports/PeopleReport/components/PeopleTasksPieChart.test.jsx',
3333
// Ignore entire component folders
34-
'src/components/Badge/**',
3534
],
3635
},
3736

src/components/Badge/AssignBadge.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function AssignBadge(props) {
6363
}
6464
setError(null);
6565
} catch (err) {
66+
/* eslint-disable no-console */
6667
console.error('Error filtering users:', err);
6768
setError(err.message);
6869
setFilteredUsers([]);

src/components/Badge/AssignBadgePopup.jsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ function AssignBadgePopup(props) {
2323
);
2424
};
2525

26+
const { submit: submitCallback } = props;
27+
2628
const handleSubmit = () => {
27-
props.submit();
29+
if (typeof submitCallback === 'function') {
30+
submitCallback();
31+
}
2832
dispatch(clearSelected());
2933
};
3034

@@ -48,15 +52,16 @@ function AssignBadgePopup(props) {
4852
<th>Badge</th>
4953
<th>Name</th>
5054
<th>
51-
<i className="fa fa-info-circle" id="SelectInfo" />
55+
<i className="fa fa-info-circle" id="SelectInfo" data-testid="select-info-icon" />
5256
<UncontrolledTooltip
5357
placement="right"
5458
target="SelectInfo"
5559
className="bg-secondary text-light"
5660
>
5761
<p className="badge_info_icon_text">
5862
Check those boxes to select the badges you wish to assign a person. Click the
59-
"Confirm" button at the bottom when you've selected all you wish to add.
63+
&quot;Confirm&quot; button at the bottom when you&apos;ve selected all you wish
64+
to add.
6065
</p>
6166
<p className="badge_info_icon_text">
6267
Want to assign multiple of the same badge to a person? Repeat the process!

src/components/Badge/Badge.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ function Badge(props) {
9797
id="badgesearned"
9898
>
9999
<CardHeader tag="h3" onClick={toggleTypes} role="button" tabIndex={0}>
100-
Badges <i className="fa fa-info-circle" id="BadgeInfo" />
100+
Badges{' '}
101+
<i className="fa fa-info-circle" id="BadgeInfo" data-testid="badge-info-icon" />
101102
</CardHeader>
102103
<CardBody>
103104
<NewBadges
@@ -123,7 +124,7 @@ function Badge(props) {
123124
props.userProfile.badgeCollection,
124125
props.userProfile.personalBestMaxHrs,
125126
)}
126-
<i className="fa fa-info-circle" id="CountInfo" />
127+
<i className="fa fa-info-circle" id="CountInfo" data-testid="count-info-icon" />
127128
</CardText>
128129
<BadgeSummaryViz badges={props.userProfile.badgeCollection} dashboard />
129130
</CardBody>

src/components/Badge/BadgeDevelopmentTable.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ function BadgeDevelopmentTable(props) {
163163
};
164164

165165
const handleSortName = () => {
166-
console.log('here sort name');
167166
setSortRankState('default');
168167
setSortNameState(prevState => {
169168
// change the icon
@@ -187,7 +186,6 @@ function BadgeDevelopmentTable(props) {
187186

188187
const handleSortRank = () => {
189188
setSortNameState('default');
190-
console.log('sort rank');
191189
setSortRankState(prevState => {
192190
// Change the icon state
193191
let newState = 'ascending';
@@ -228,6 +226,7 @@ function BadgeDevelopmentTable(props) {
228226
toggleCheckbox(badgeValue._id);
229227
props.updateBadge(badgeValue._id, updatedValue);
230228
}}
229+
data-testid={`report-checkbox-${badgeValue._id}`}
231230
style={{
232231
display: 'inline-block',
233232
width: '20px',
@@ -288,7 +287,12 @@ function BadgeDevelopmentTable(props) {
288287
<tr key={value._id}>
289288
<td className="badge_image_sm">
290289
{' '}
291-
<img src={value.imageUrl} id={`popover_${value._id}`} alt="" />
290+
<img
291+
src={value.imageUrl}
292+
id={`popover_${value._id}`}
293+
alt=""
294+
data-testid={`badge-image-${value._id}`}
295+
/>
292296
<UncontrolledPopover trigger="hover" target={`popover_${value._id}`}>
293297
<Card className={`text-center ${darkMode ? 'bg-space-cadet text-light' : ''}`}>
294298
<CardImg className="badge_image_lg" src={value?.imageUrl} />

src/components/Badge/BadgeHistory.jsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ function BadgeHistory({ badges, personalBestMaxHrs }) {
55
const filterBadges = allBadges => {
66
if (!Array.isArray(allBadges)) return [];
77

8-
const filteredList = allBadges.filter(value =>
9-
value && value.lastModified &&
10-
(Date.now() - new Date(value.lastModified).getTime() > WEEK_DIFF)
8+
const filteredList = allBadges.filter(
9+
value =>
10+
value &&
11+
value.lastModified &&
12+
Date.now() - new Date(value.lastModified).getTime() > WEEK_DIFF,
1113
);
1214

1315
filteredList.sort((a, b) => {
@@ -30,7 +32,7 @@ function BadgeHistory({ badges, personalBestMaxHrs }) {
3032

3133
return (
3234
<div className="badge_history_container">
33-
{filteredBadges.map((value, index) => (
35+
{filteredBadges.map((value, index) =>
3436
value && value.badge ? (
3537
<BadgeImage
3638
personalBestMaxHrs={personalBestMaxHrs}
@@ -40,10 +42,10 @@ function BadgeHistory({ badges, personalBestMaxHrs }) {
4042
index={index}
4143
key={value.badge._id || index}
4244
/>
43-
) : null
44-
))}
45+
) : null,
46+
)}
4547
</div>
4648
);
4749
}
4850

49-
export default BadgeHistory;
51+
export default BadgeHistory;

src/components/Badge/BadgeTableHeader.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ function BadgeTableHeader({ darkMode }) {
88
<th className="d-xl-table-cell d-none">Description</th>
99
<th>Type</th>
1010
<th className="d-xl-table-cell d-none">Details</th>
11-
<th>Ranking{' '}
12-
<i className="fa fa-info-circle" id="SortRankingInfo" style={{ marginLeft: '5px' }} />
11+
<th>
12+
Ranking{' '}
13+
<i
14+
className="fa fa-info-circle"
15+
id="SortRankingInfo"
16+
data-testid="sort-ranking-info-icon"
17+
style={{ marginLeft: '5px' }}
18+
/>
1319
<UncontrolledTooltip
1420
placement="right"
1521
target="SortRankingInfo"
@@ -34,4 +40,4 @@ function BadgeTableHeader({ darkMode }) {
3440
);
3541
}
3642

37-
export default BadgeTableHeader;
43+
export default BadgeTableHeader;

src/components/Badge/NewBadges.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function NewBadges(props) {
2626

2727
return filteredList;
2828
} catch (error) {
29-
console.log(error);
29+
// Swallow errors from invalid data to keep UI resilient in tests
30+
return [];
3031
}
3132
};
3233

0 commit comments

Comments
 (0)