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

mendersoftware / gui / 897326496

pending completion
897326496

Pull #3752

gitlab-ci

mzedel
chore(e2e): made use of shared timeout & login checking values to remove code duplication

Signed-off-by: Manuel Zedel <manuel.zedel@northern.tech>
Pull Request #3752: chore(e2e-tests): slightly simplified log in test + separated log out test

4395 of 6392 branches covered (68.76%)

8060 of 9780 relevant lines covered (82.41%)

126.17 hits per line

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

60.87
/src/js/components/settings/organization/organizationpaymentsettings.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, useState } from 'react';
15
import { connect } from 'react-redux';
16

17
// material ui
18
import { Error as ErrorIcon } from '@mui/icons-material';
19

20
import { setSnackbar } from '../../../actions/appActions';
21
import { confirmCardUpdate, getCurrentCard, startCardUpdate } from '../../../actions/organizationActions';
22
import CardSection from '../cardsection';
23
import OrganizationSettingsItem from './organizationsettingsitem';
24

25
export const OrganizationPaymentSettings = ({ card, confirmCardUpdate, getCurrentCard, hasUnpaid, setSnackbar, startCardUpdate }) => {
7✔
26
  const [isUpdatingPaymentDetails, setIsUpdatingPaymentDetails] = useState(false);
1✔
27

28
  useEffect(() => {
1✔
29
    getCurrentCard();
1✔
30
  }, []);
31

32
  const onCardConfirm = async () => {
1✔
33
    await confirmCardUpdate();
×
34
    getCurrentCard();
×
35
    setIsUpdatingPaymentDetails(false);
×
36
  };
37

38
  // const invoiceDate = moment();
39
  const { last4, expiration, brand } = card;
1✔
40
  return (
1✔
41
    <>
42
      {/* <OrganizationSettingsItem
43
                  title="Next payment date"
44
                  content={{
45
                    action: { title: 'View invoices', internal: true, action: setShowInvoices },
46
                    description: invoiceDate.format('MMMM DD, YYYY')
47
                  }}
48
                  notification={<div className="text-muted">Your subscription will be charged automatically</div>}
49
                /> */}
50
      <OrganizationSettingsItem
51
        title="Payment card"
52
        content={{
53
          action: { title: `${last4 ? 'Update' : 'Enter'} payment card`, internal: true, action: () => setIsUpdatingPaymentDetails(true) },
×
54
          description: last4 ? (
1!
55
            <div>
56
              <div>
57
                {brand} ending in {last4}
58
              </div>
59
              <div>
60
                Expires {`0${expiration.month}`.slice(-2)}/{`${expiration.year}`.slice(-2)}
61
              </div>
62
            </div>
63
          ) : (
64
            <div>
65
              The introduction of the PSD2 regulation in Europe requires re-entering your card details before we can allow the modification of payment details
66
              or access to the payment history.
67
            </div>
68
          )
69
        }}
70
        secondary={
71
          isUpdatingPaymentDetails && (
1!
72
            <CardSection onCancel={() => setIsUpdatingPaymentDetails(false)} onComplete={onCardConfirm} onSubmit={startCardUpdate} setSnackbar={setSnackbar} />
×
73
          )
74
        }
75
        notification={
76
          hasUnpaid && (
1!
77
            <div className="red flexbox centered">
78
              <ErrorIcon fontSize="small" />
79
              <span className="margin-left-small">You have an unpaid invoice. Please check your payment card details</span>
80
            </div>
81
          )
82
        }
83
      />
84
    </>
85
  );
86
};
87

88
const actionCreators = { confirmCardUpdate, getCurrentCard, startCardUpdate, setSnackbar };
7✔
89

90
const mapStateToProps = state => {
7✔
91
  return {
1✔
92
    card: state.organization.card,
93
    hasUnpaid: state.organization.billing
94
  };
95
};
96

97
export default connect(mapStateToProps, actionCreators)(OrganizationPaymentSettings);
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