• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / gui / 951400782

pending completion
951400782

Pull #3900

gitlab-ci

web-flow
chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.16.5 to 5.17.0.
- [Release notes](https://github.com/testing-library/jest-dom/releases)
- [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/jest-dom/compare/v5.16.5...v5.17.0)

---
updated-dependencies:
- dependency-name: "@testing-library/jest-dom"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3900: chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

4446 of 6414 branches covered (69.32%)

8342 of 10084 relevant lines covered (82.73%)

186.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.8
/src/js/components/releases/releaseslist.js
1
// Copyright 2019 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import React, { useMemo, useRef } from 'react';
15

16
import { makeStyles } from 'tss-react/mui';
17

18
import { SORTING_OPTIONS, canAccess as canShow } from '../../constants/appConstants';
19
import { DEVICE_LIST_DEFAULTS } from '../../constants/deviceConstants';
20
import { onboardingSteps } from '../../constants/onboardingConstants';
21
import { getOnboardingComponentFor } from '../../utils/onboardingmanager';
22
import DetailsTable from '../common/detailstable';
23
import Loader from '../common/loader';
24
import Pagination from '../common/pagination';
25
import { RelativeTime } from '../common/time';
26

27
const columns = [
5✔
28
  {
29
    key: 'name',
30
    title: 'Name',
31
    render: ({ Name }) => Name,
199✔
32
    sortable: true,
33
    defaultSortDirection: SORTING_OPTIONS.asc,
34
    canShow
35
  },
36
  {
37
    key: 'artifacts-count',
38
    title: 'Number of artifacts',
39
    render: ({ Artifacts = [] }) => Artifacts.length,
199!
40
    canShow
41
  },
42
  {
43
    key: 'tags',
44
    title: 'Tags',
45
    render: ({ tags = [] }) => tags.join(', ') || '-',
×
46
    canShow: ({ features: { hasReleaseTags } }) => hasReleaseTags
5✔
47
  },
48
  {
49
    key: 'modified',
50
    title: 'Last modified',
51
    render: ({ modified }) => <RelativeTime updateTime={modified} />,
199✔
52
    defaultSortDirection: SORTING_OPTIONS.desc,
53
    sortable: true,
54
    canShow
55
  }
56
];
57

58
const useStyles = makeStyles()(() => ({
5✔
59
  container: { maxWidth: 1600 }
60
}));
61

62
const { page: defaultPage, perPage: defaultPerPage } = DEVICE_LIST_DEFAULTS;
5✔
63

64
export const ReleasesList = ({ artifactIncluded, features, onboardingState, onSelect, releasesListState, releases, setReleasesListState }) => {
5✔
65
  const { isLoading, page = defaultPage, perPage = defaultPerPage, searchTerm, sort = {}, searchTotal, total } = releasesListState;
30!
66
  const { key: attribute, direction } = sort;
30✔
67
  const repoRef = useRef();
30✔
68
  const { classes } = useStyles();
30✔
69

70
  const onChangeSorting = sortKey => {
30✔
71
    let sort = { key: sortKey, direction: direction === SORTING_OPTIONS.asc ? SORTING_OPTIONS.desc : SORTING_OPTIONS.asc };
×
72
    if (sortKey !== attribute) {
×
73
      sort = { ...sort, direction: columns.find(({ key }) => key === sortKey)?.defaultSortDirection ?? SORTING_OPTIONS.desc };
×
74
    }
75
    setReleasesListState({ page: 1, sort });
×
76
  };
77

78
  const onChangePagination = (page, currentPerPage = perPage) => setReleasesListState({ page, perPage: currentPerPage });
30!
79

80
  const applicableColumns = useMemo(
30✔
81
    () =>
82
      columns.reduce((accu, column) => {
5✔
83
        if (column.canShow({ features })) {
20✔
84
          accu.push(column);
15✔
85
        }
86
        return accu;
20✔
87
      }, []),
88
    [JSON.stringify(features)]
89
  );
90

91
  let onboardingComponent = null;
30✔
92
  if (repoRef.current?.lastChild?.lastChild) {
30✔
93
    const element = repoRef.current.lastChild.lastChild;
25✔
94
    const anchor = { left: element.offsetLeft + element.offsetWidth / 2, top: element.offsetTop + element.offsetParent?.offsetTop + element.offsetHeight };
25✔
95
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.ARTIFACT_INCLUDED_ONBOARDING, { ...onboardingState, artifactIncluded }, { anchor });
25✔
96
    onboardingComponent = getOnboardingComponentFor(onboardingSteps.DEPLOYMENTS_PAST_COMPLETED, onboardingState, { anchor }, onboardingComponent);
25✔
97
  }
98

99
  const potentialTotal = searchTerm ? searchTotal : total;
30✔
100
  return (
30✔
101
    <div className={classes.container}>
102
      {isLoading === undefined ? (
30!
103
        <Loader show />
104
      ) : !potentialTotal ? (
30✔
105
        <p className="margin-top muted align-center margin-right">There are no Releases {searchTerm ? `for ${searchTerm}` : 'yet'}</p>
2✔
106
      ) : (
107
        <>
108
          <DetailsTable columns={applicableColumns} items={releases} onItemClick={onSelect} sort={sort} onChangeSorting={onChangeSorting} tableRef={repoRef} />
109
          <div className="flexbox">
110
            <Pagination
111
              className="margin-top-none"
112
              count={potentialTotal}
113
              rowsPerPage={perPage}
114
              onChangePage={onChangePagination}
115
              onChangeRowsPerPage={newPerPage => onChangePagination(1, newPerPage)}
×
116
              page={page}
117
            />
118
            <Loader show={isLoading} small />
119
          </div>
120
          {onboardingComponent}
121
        </>
122
      )}
123
    </div>
124
  );
125
};
126

127
export default ReleasesList;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc