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

kiva / ui / 4380401906

pending completion
4380401906

Pull #4680

github

GitHub
Merge 390d27320 into 898354c4d
Pull Request #4680: Add to basket cookie error vue 1583

803 of 2093 branches covered (38.37%)

Branch coverage included in aggregate %.

15 of 15 new or added lines in 2 files covered. (100.0%)

1087 of 2812 relevant lines covered (38.66%)

5.16 hits per line

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

0.0
/src/util/basketUtils.js
1
import * as Sentry from '@sentry/vue';
2
import { gql } from '@apollo/client';
3
import numeral from 'numeral';
4
import logFormatter from '@/util/logFormatter';
5
import basketCountQuery from '@/graphql/query/basketCount.graphql';
6
import basketItemsQuery from '@/graphql/query/basketItems.graphql';
7
import basketLoansInfoQuery from '@/graphql/query/basketLoansInfo.graphql';
8

9
function logSetLendAmountError(loanId, err) {
10
        logFormatter(err, 'error');
×
11
        try {
×
12
                Sentry.withScope(scope => {
×
13
                        scope.setTag('loan_id', this.loanId);
×
14
                        scope.setTag('mutation', 'addToBasket');
×
15
                        Sentry.captureException(err);
×
16
                });
17
        } catch (e) {
18
                // no-op
19
        }
20
}
21

22
export function setLendAmount({ amount, apollo, loanId }) {
23
        return new Promise((resolve, reject) => {
×
24
                const price = numeral(amount).format('0.00');
×
25
                apollo.mutate({
×
26
                        mutation: gql`mutation addToBasket($loanId: Int!, $price: Money!, $basketId: String) {
27
                                shop (basketId: $basketId) {
28
                                        id
29
                                        updateLoanReservation (loanReservation: {
30
                                                id: $loanId
31
                                                price: $price
32
                                        }) {
33
                                                id
34
                                                price
35
                                        }
36
                                }
37
                        }`,
38
                        variables: {
39
                                loanId,
40
                                price,
41
                        },
42
                        optimisticResponse: {
43
                                __typename: 'Mutation',
44
                                shop: {
45
                                        id: '0',
46
                                        __typename: 'ShopMutation',
47
                                        updateLoanReservation: {
48
                                                __typename: 'LoanReservation',
49
                                                id: loanId,
50
                                                price,
51
                                        },
52
                                },
53
                        },
54
                        awaitRefetchQueries: true,
55
                        refetchQueries: [
56
                                { query: basketCountQuery },
57
                                { query: basketItemsQuery },
58
                                { query: basketLoansInfoQuery, variables: { id: loanId } }
59
                        ]
60
                }).then(result => {
61
                        if (result.errors) {
×
62
                                result.errors.forEach(error => {
×
63
                                        logSetLendAmountError(loanId, error);
×
64
                                });
65
                                reject(result.errors);
×
66
                        } else {
67
                                resolve();
×
68
                        }
69
                }).catch(errors => {
70
                        errors.forEach(error => {
×
71
                                logSetLendAmountError(loanId, error);
×
72
                        });
73
                        reject(errors);
×
74
                });
75
        });
76
}
77

78
export function setDonationAmount() {
79
        // TODO
80
}
81

82
export function handleInvalidBasket({ loan, cookieStore }) {
83
        cookieStore.remove('kvbskt', { path: '/', secure: true });
×
84
        cookieStore.set('kvatbid', JSON.stringify(loan));
×
85
        window.location.reload();
×
86
}
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