Skip to content

Commit

Permalink
fix: fix check for $0 billing limit (#24506)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
zlwaterfield and github-actions[bot] authored Aug 21, 2024
1 parent 888fca6 commit 1eea80b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
32 changes: 32 additions & 0 deletions cypress/e2e/billing-limits.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,38 @@ describe('Billing Limits', () => {
)
})

it('Show existing limit and allow user to change set to $0', () => {
cy.intercept('GET', '/api/billing/', (req) => {
req.reply({
statusCode: 200,
body: {
...require('../fixtures/api/billing/billing.json'),
custom_limits_usd: { product_analytics: 100 },
},
})
}).as('getBilling')
cy.visit('/organization/billing')
cy.wait('@getBilling')

cy.intercept('PATCH', '/api/billing/', (req) => {
req.reply({
statusCode: 200,
body: {
...require('../fixtures/api/billing/billing.json'),
custom_limits_usd: { product_analytics: 0 },
},
})
}).as('patchBilling')

cy.get('[data-attr="billing-limit-input-wrapper-product_analytics"]').scrollIntoView()
cy.get('[data-attr="billing-limit-set-product_analytics"]').should('be.visible')
cy.contains('Edit limit').click()
cy.get('[data-attr="billing-limit-input-product_analytics"]').clear().type('0')
cy.get('[data-attr="save-billing-limit-product_analytics"]').click()
cy.wait('@patchBilling')
cy.get('[data-attr="billing-limit-set-product_analytics"]').should('contain', 'You have a $0 billing limit set')
})

it('Show existing limit and allow user to remove it', () => {
cy.intercept('GET', '/api/billing/', (req) => {
req.reply({
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/__snapshots__/scenes-app-dashboards--edit--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion frontend/src/scenes/billing/billingProductLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ export const billingProductLogic = kea<billingProductLogicType>([
return product.usage_key ? billing?.custom_limits_usd?.[product.usage_key] ?? null : null
},
],
hasCustomLimitSet: [(s) => [s.customLimitUsd], (customLimitUsd) => !!customLimitUsd && customLimitUsd >= 0],
hasCustomLimitSet: [
(s) => [s.customLimitUsd],
(customLimitUsd) => (!!customLimitUsd || customLimitUsd === 0) && customLimitUsd >= 0,
],
currentAndUpgradePlans: [
(_s, p) => [p.product],
(product) => {
Expand Down

0 comments on commit 1eea80b

Please sign in to comment.