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

kiva / ui / 19147367510

06 Nov 2025 07:26PM UTC coverage: 91.443% (+41.5%) from 49.902%
19147367510

push

github

emuvente
test: refactor category-row-arrows-visible-mixin test with runner method

3722 of 3979 branches covered (93.54%)

Branch coverage included in aggregate %.

18923 of 20785 relevant lines covered (91.04%)

78.6 hits per line

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

97.71
/src/util/basketUtils.js
1
import * as Sentry from '@sentry/vue';
1✔
2
import numeral from 'numeral';
1✔
3
import logFormatter from '#src/util/logFormatter';
1✔
4
import basketCountQuery from '#src/graphql/query/basketCount.graphql';
1✔
5
import basketItemsQuery from '#src/graphql/query/basketItems.graphql';
1✔
6
import basketLoansInfoQuery from '#src/graphql/query/basketLoansInfo.graphql';
1✔
7
import createNewBasketMutation from '#src/graphql/mutation/shopCreateNewBsket.graphql';
1✔
8
import updateDonation from '#src/graphql/mutation/updateDonation.graphql';
1✔
9
import updateLoanReservation from '#src/graphql/mutation/updateLoanReservation.graphql';
1✔
10

11
export const INVALID_BASKET_ERROR = 'invalidBasket';
1✔
12

13
function logSetLendAmountError(loanId, err) {
7✔
14
        logFormatter(err, 'error');
7✔
15
        try {
7✔
16
                Sentry.withScope(scope => {
7✔
17
                        scope.setTag('loan_id', this.loanId);
×
18
                        scope.setTag('mutation', 'addToBasket');
×
19
                        Sentry.captureException(err);
×
20
                });
7✔
21
        } catch (e) {
7✔
22
                // no-op
4✔
23
        }
4✔
24
}
7✔
25

26
export async function createNewBasket({ apollo, cookieStore }) {
1✔
27
        // Create a new basket
4✔
28
        const { data } = await apollo.mutate({ mutation: createNewBasketMutation });
4✔
29
        const newBasketId = data?.shop?.createBasket;
4✔
30

31
        // Set the new basket ID in the cookie
4✔
32
        if (newBasketId) {
4✔
33
                cookieStore.set('kvbskt', newBasketId, { path: '/', secure: true });
1✔
34
        }
1✔
35

36
        return newBasketId;
4✔
37
}
4✔
38

39
export function setLendAmount({ amount, apollo, loanId }) {
1✔
40
        return new Promise((resolve, reject) => {
7✔
41
                const price = numeral(amount).format('0.00');
7✔
42
                apollo.mutate({
7✔
43
                        mutation: updateLoanReservation,
7✔
44
                        variables: {
7✔
45
                                loanId,
7✔
46
                                price,
7✔
47
                        },
7✔
48
                        optimisticResponse: {
7✔
49
                                __typename: 'Mutation',
7✔
50
                                shop: {
7✔
51
                                        id: '0',
7✔
52
                                        __typename: 'ShopMutation',
7✔
53
                                        updateLoanReservation: {
7✔
54
                                                __typename: 'LoanReservation',
7✔
55
                                                id: loanId,
7✔
56
                                                price,
7✔
57
                                        },
7✔
58
                                },
7✔
59
                        },
7✔
60
                        awaitRefetchQueries: true,
7✔
61
                        refetchQueries: [
7✔
62
                                { query: basketCountQuery },
7✔
63
                                { query: basketItemsQuery },
7✔
64
                                { query: basketLoansInfoQuery, variables: { id: loanId } }
7✔
65
                        ]
7✔
66
                }).then(result => {
7✔
67
                        if (result.errors) {
4✔
68
                                result.errors.forEach(error => {
3✔
69
                                        logSetLendAmountError(loanId, error);
3✔
70
                                });
3✔
71
                                reject(result.errors);
3✔
72
                        } else {
4✔
73
                                resolve();
1✔
74
                        }
1✔
75
                }).catch(errors => {
7✔
76
                        (Array.isArray(errors) ? errors : [errors]).forEach(error => {
3✔
77
                                logSetLendAmountError(loanId, error);
4✔
78
                        });
3✔
79
                        reject(errors);
3✔
80
                });
7✔
81
        });
7✔
82
}
7✔
83

84
export function setDonationAmount({ apollo, donationAmount }) {
1✔
85
        const formattedDonationAmount = numeral(donationAmount).format('0.00');
3✔
86
        return apollo.mutate({
3✔
87
                mutation: updateDonation,
3✔
88
                variables: {
3✔
89
                        price: formattedDonationAmount,
3✔
90
                        isTip: true
3✔
91
                }
3✔
92
        }).then(data => {
3✔
93
                if (data?.errors) {
2✔
94
                        data?.errors.forEach(error => {
1✔
95
                                logFormatter(error, 'error');
2✔
96
                        });
1✔
97
                }
1✔
98
                return data;
2✔
99
        }).catch(error => {
3✔
100
                logFormatter(error, 'error');
1✔
101
        });
3✔
102
}
3✔
103

104
export function handleInvalidBasket({ loan, cookieStore }) {
1✔
105
        cookieStore.remove('kvbskt', { path: '/', secure: true });
1✔
106
        cookieStore.set('kvatbid', JSON.stringify(loan));
1✔
107
        window.location.reload();
1✔
108
}
1✔
109
export function handleInvalidBasketForDonation({ cookieStore, donationAmount, navigateToCheckout = false }) {
1✔
110
        cookieStore.remove('kvbskt', { path: '/', secure: true });
2✔
111
        cookieStore.set('kvatbamt', JSON.stringify({ donationAmount, navigateToCheckout }));
2✔
112
        window.location.reload();
2✔
113
}
2✔
114

115
export function hasBasketExpired(errorCode) {
1✔
116
        return ['shop.invalidBasketId', 'shop.basketRequired'].includes(errorCode);
3✔
117
}
3✔
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

© 2026 Coveralls, Inc