• 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

75.0
/src/js/components/settings/webhooks/webhooks.js
1
// Copyright 2022 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 { ArrowRightAlt as ArrowRightAltIcon } from '@mui/icons-material';
19

20
import { changeIntegration, createIntegration, deleteIntegration, getIntegrations, getWebhookEvents } from '../../../actions/organizationActions';
21
import { EXTERNAL_PROVIDER } from '../../../constants/deviceConstants';
22
import { emptyWebhook } from '../../../constants/organizationConstants';
23
import DetailsTable from '../../common/detailstable';
24
import DocsLink from '../../common/docslink';
25
import Time from '../../common/time';
26
import WebhookManagement from './management';
27

28
const columns = [
6✔
29
  { key: 'url', title: 'URL', render: ({ url }) => url },
1✔
30
  { key: 'status', title: 'Status', render: ({ status }) => status },
1✔
31
  {
32
    key: 'updated_ts',
33
    title: 'Last activity',
34
    render: ({ updated_ts }) => <Time value={updated_ts} />
×
35
  },
36
  {
37
    key: 'manage',
38
    title: 'Manage',
39
    render: () => (
40
      <div className="bold flexbox center-aligned link-color margin-right-small uppercased" style={{ whiteSpace: 'nowrap' }}>
1✔
41
        view details <ArrowRightAltIcon />
42
      </div>
43
    )
44
  }
45
];
46

47
export const Webhooks = ({ webhook = { ...emptyWebhook } }) => {
6✔
48
  const [adding, setAdding] = useState(false);
2✔
49
  const [editing, setEditing] = useState(false);
2✔
50
  const [selectedWebhook, setSelectedWebhook] = useState(webhook);
2✔
51
  const dispatch = useDispatch();
2✔
52
  const { events, webhooks } = useSelector(state => {
2✔
53
    const webhooks = state.organization.externalDeviceIntegrations.filter(
4✔
54
      integration => integration.id && integration.provider === EXTERNAL_PROVIDER.webhook.provider
2✔
55
    );
56
    const events = webhooks.length ? state.organization.webhooks.events : [];
4✔
57
    return { events, webhooks };
4✔
58
  });
59
  const eventTotal = useSelector(state => state.organization.webhooks.eventTotal);
4✔
60

61
  useEffect(() => {
2✔
62
    dispatch(getIntegrations());
2✔
63
  }, []);
64

65
  useEffect(() => {
2✔
66
    setSelectedWebhook(webhook);
2✔
67
  }, [JSON.stringify(webhook)]);
68

69
  const onEdit = item => {
2✔
70
    setAdding(false);
×
71
    setEditing(true);
×
72
    setSelectedWebhook(item);
×
73
  };
74

75
  const onCancel = () => {
2✔
76
    setAdding(false);
×
77
    setEditing(false);
×
78
  };
79

80
  const onSubmit = item => {
2✔
81
    if (adding) {
×
82
      dispatch(createIntegration(item));
×
83
    } else {
84
      dispatch(changeIntegration(item));
×
85
    }
86
    setAdding(false);
×
87
    setEditing(false);
×
88
  };
89

90
  const onRemoveClick = () => dispatch(deleteIntegration(selectedWebhook));
2✔
91

92
  const { mappedWebhooks, relevantColumns } = useMemo(() => {
2✔
93
    const mappedWebhooks = webhooks.map(item => ({ ...item, url: item.credentials[EXTERNAL_PROVIDER.webhook.credentialsType].url, status: 'enabled' }));
2✔
94
    const relevantColumns = columns.reduce((accu, item) => {
2✔
95
      if (mappedWebhooks.some(hook => hook[item.key]) || item === columns[columns.length - 1]) {
8✔
96
        accu.push(item);
4✔
97
      }
98
      return accu;
8✔
99
    }, []);
100
    return { mappedWebhooks, relevantColumns };
2✔
101
  }, [JSON.stringify(webhooks)]);
102

103
  return (
2✔
104
    <div>
105
      <h2>Webhooks</h2>
106
      {webhooks.length ? (
2✔
107
        <DetailsTable columns={relevantColumns} items={mappedWebhooks} onItemClick={onEdit} />
108
      ) : (
109
        <div className="flexbox centered">
110
          No webhooks are configured yet. Learn more about webhooks in our <DocsLink path="server-integration" title="documentation" />
111
        </div>
112
      )}
113
      <WebhookManagement
114
        adding={adding}
115
        editing={editing}
116
        events={events}
117
        eventTotal={eventTotal}
118
        getWebhookEvents={options => dispatch(getWebhookEvents(options))}
×
119
        onCancel={onCancel}
120
        onSubmit={onSubmit}
121
        onRemove={onRemoveClick}
122
        webhook={selectedWebhook}
123
      />
124
    </div>
125
  );
126
};
127

128
export default Webhooks;
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