• 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

81.25
/src/js/components/settings/roles.js
1
// Copyright 2020 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, { useEffect, useMemo, useState } from 'react';
15
import { useDispatch, useSelector } from 'react-redux';
16

17
// material ui
18
import { Add as AddIcon, ArrowRightAlt as ArrowRightAltIcon } from '@mui/icons-material';
19
import { Chip } from '@mui/material';
20

21
import { getDynamicGroups, getGroups } from '../../actions/deviceActions';
22
import { createRole, editRole, getRoles, removeRole } from '../../actions/userActions';
23
import { emptyRole, rolesById } from '../../constants/userConstants';
24
import { getFeatures, getGroupsByIdWithoutUngrouped, getReleaseTagsById, getRolesList } from '../../selectors';
25
import DetailsTable from '../common/detailstable';
26
import RoleDefinition from './roledefinition';
27

28
const columns = [
5✔
29
  { key: 'name', title: 'Role', render: ({ name }) => name },
59✔
30
  { key: 'description', title: 'Description', render: ({ description }) => description || '-' },
59✔
31
  {
32
    key: 'manage',
33
    title: 'Manage',
34
    render: () => (
35
      <div className="bold flexbox center-aligned link-color margin-right-small uppercased" style={{ whiteSpace: 'nowrap' }}>
59✔
36
        view details <ArrowRightAltIcon />
37
      </div>
38
    )
39
  }
40
];
41

42
export const RoleManagement = () => {
5✔
43
  const [adding, setAdding] = useState(false);
8✔
44
  const [editing, setEditing] = useState(false);
8✔
45
  const [role, setRole] = useState({ ...emptyRole });
8✔
46
  const dispatch = useDispatch();
8✔
47
  const features = useSelector(getFeatures);
8✔
48
  const groups = useSelector(getGroupsByIdWithoutUngrouped);
8✔
49
  const releaseTags = useSelector(getReleaseTagsById);
8✔
50
  const roles = useSelector(getRolesList);
8✔
51

52
  useEffect(() => {
8✔
53
    if (Object.keys(groups).length) {
2!
54
      return;
2✔
55
    }
56
    dispatch(getDynamicGroups());
×
57
    dispatch(getGroups());
×
58
    dispatch(getRoles());
×
59
  }, []);
60

61
  const addRole = () => {
8✔
62
    setAdding(true);
×
63
    setEditing(false);
×
64
    setRole({ ...emptyRole });
×
65
  };
66

67
  const onEditRole = editedRole => {
8✔
68
    setAdding(false);
2✔
69
    setEditing(true);
2✔
70
    setRole(editedRole);
2✔
71
  };
72

73
  const onCancel = () => {
8✔
74
    setAdding(false);
2✔
75
    setEditing(false);
2✔
76
  };
77

78
  const onSubmit = submittedRole => {
8✔
79
    if (adding) {
1!
80
      dispatch(createRole(submittedRole));
×
81
    } else {
82
      dispatch(editRole(submittedRole));
1✔
83
    }
84
    onCancel();
1✔
85
  };
86

87
  const items = useMemo(
8✔
88
    () =>
89
      Object.keys(rolesById)
4✔
90
        .reverse()
91
        .reduce((accu, key) => {
92
          const index = accu.findIndex(({ id }) => id === key);
100✔
93
          accu = [accu[index], ...accu.filter((item, itemIndex) => index !== itemIndex)];
145✔
94
          return accu;
20✔
95
        }, roles),
96
    [JSON.stringify(roles)]
97
  );
98

99
  return (
8✔
100
    <div>
101
      <h2 style={{ marginLeft: 20 }}>Roles</h2>
102
      <DetailsTable columns={columns} items={items} onItemClick={onEditRole} />
103
      <Chip color="primary" icon={<AddIcon />} label="Add a role" onClick={addRole} />
104
      <RoleDefinition
105
        adding={adding}
106
        editing={editing}
107
        features={features}
108
        onCancel={onCancel}
109
        onSubmit={onSubmit}
110
        removeRole={name => dispatch(removeRole(name))}
1✔
111
        selectedRole={role}
112
        stateGroups={groups}
113
        stateReleaseTags={releaseTags}
114
      />
115
    </div>
116
  );
117
};
118

119
export default RoleManagement;
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