Skip to content

Commit 666c266

Browse files
authored
Merge pull request #108 from TaloDev/develop
Release 0.23.2
2 parents 98891c5 + 81faa67 commit 666c266

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+712
-85
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- uses: actions/checkout@v3
1111
- uses: actions/setup-node@v3
1212
with:
13-
node-version: 18
13+
node-version: 16
1414

1515
- uses: actions/cache@v3
1616
with:
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install deps
2121
run: yarn --prefer-offline
2222

23-
- run: yarn test --silent
23+
- run: yarn test --silent --coverage
2424

2525
- uses: codecov/codecov-action@v3
2626
with:
@@ -33,15 +33,15 @@ jobs:
3333
- uses: actions/checkout@v3
3434
- uses: actions/setup-node@v3
3535
with:
36-
node-version: 18
36+
node-version: 16
3737

3838
- name: Run Cypress
3939
uses: cypress-io/github-action@v5
4040
with:
4141
cache-key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
4242
install-command: yarn --prefer-offline
4343
start: yarn dev:e2e
44-
wait-on: 'http://[::1]:8080'
44+
wait-on: 'http://127.0.0.1:8080'
4545
env:
4646
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4747

@@ -52,7 +52,7 @@ jobs:
5252
- uses: actions/checkout@v3
5353
- uses: actions/setup-node@v3
5454
with:
55-
node-version: 18
55+
node-version: 16
5656

5757
- uses: actions/cache@v3
5858
with:
@@ -72,7 +72,7 @@ jobs:
7272
- uses: actions/checkout@v3
7373
- uses: actions/setup-node@v3
7474
with:
75-
node-version: 18
75+
node-version: 16
7676

7777
- uses: actions/cache@v3
7878
with:

.github/workflows/create-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
- uses: actions/setup-node@v3
1616
with:
17-
node-version: 18
17+
node-version: 16
1818

1919
- uses: actions/cache@v3
2020
with:
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/// <reference types='cypress' />
2+
3+
describe('Billing', () => {
4+
function stubBillingCalls() {
5+
cy.intercept('GET', 'http://talo.api/billing/organisation-plan', {
6+
statusCode: 200,
7+
fixture: 'responses/billing/free-plan'
8+
})
9+
10+
cy.intercept('GET', 'http://talo.api/billing/plans', {
11+
statusCode: 200,
12+
fixture: 'responses/billing/plans'
13+
})
14+
15+
cy.intercept('GET', 'http://talo.api/billing/usage', {
16+
statusCode: 200,
17+
fixture: 'responses/billing/usage'
18+
})
19+
}
20+
21+
it('should show the correct usages', () => {
22+
stubBillingCalls()
23+
24+
cy.login('owner', '/billing')
25+
cy.findByTestId('User seats-usage').should('contain.text', '0/2')
26+
cy.findByTestId('Data exports-usage').should('contain.text', '1/3')
27+
})
28+
29+
it('should open the billing portal', () => {
30+
stubBillingCalls()
31+
32+
cy.intercept('POST', 'http://talo.api/billing/portal-session', {
33+
statusCode: 200,
34+
body: {
35+
redirect: 'https://trytalo.com'
36+
}
37+
}).as('portalSession')
38+
39+
cy.login('owner', '/billing')
40+
cy.findByText('Billing Portal').click()
41+
42+
cy.wait('@portalSession').then(() => {
43+
cy.on('url:changed', (newUrl) => {
44+
expect(newUrl).to.eq('https://trytalo.com')
45+
})
46+
})
47+
})
48+
49+
it('should open the checkout portal', () => {
50+
stubBillingCalls()
51+
52+
cy.intercept('POST', 'http://talo.api/billing/checkout-session', {
53+
statusCode: 200,
54+
body: {
55+
redirect: 'https://trytalo.com'
56+
}
57+
}).as('checkoutSession')
58+
59+
cy.login('owner', '/billing')
60+
cy.findAllByText('Upgrade').spread((button) => button.click())
61+
62+
cy.wait('@checkoutSession').then(() => {
63+
cy.on('url:changed', (newUrl) => {
64+
expect(newUrl).to.eq('https://trytalo.com')
65+
})
66+
})
67+
})
68+
69+
it('should show the confirm plan change modal', () => {
70+
stubBillingCalls()
71+
72+
cy.intercept('POST', 'http://talo.api/billing/checkout-session', {
73+
statusCode: 200,
74+
fixture: 'responses/billing/invoice'
75+
})
76+
77+
cy.intercept('POST', 'http://talo.api/billing/confirm-plan', {
78+
statusCode: 204
79+
})
80+
81+
cy.login('owner', '/billing')
82+
cy.findAllByText('Upgrade').spread((button) => button.click())
83+
84+
cy.findByText('This is a preview of the invoice that will be billed on 12 Aug 2022:').should('exist')
85+
cy.findByText('12 Jun 2022 - 12 Jul 2022').should('exist')
86+
cy.findByText('Team plan usage').should('exist')
87+
cy.findByText('Team plan proration').should('exist')
88+
cy.findByText('13 Jul 2022 - 12 Aug 2022').should('exist')
89+
cy.findByText('Business plan usage').should('exist')
90+
91+
cy.findByTestId('confirm-plan-change').click()
92+
cy.findByText('Confirm plan change').should('not.exist')
93+
cy.findByText('Current plan').should('exist')
94+
})
95+
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"accessToken": "ey...",
3+
"user": {
4+
"id": 1,
5+
"type": 0,
6+
"username": "Owner",
7+
"organisation": {
8+
"games": [
9+
{
10+
"id": 1,
11+
"name": "Superstatic",
12+
"props": [],
13+
"playerCount": 0,
14+
"createdAt": "2023-01-01 00:00:00"
15+
}
16+
],
17+
"pricingPlan": {
18+
"status": "active"
19+
}
20+
}
21+
}
22+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"pricingPlan": {
3+
"pricingPlan": {
4+
"id": 1,
5+
"hidden": false,
6+
"default": true,
7+
"actions": []
8+
},
9+
"status": "active",
10+
"endDate": null,
11+
"canViewBillingPortal": true
12+
}
13+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"invoice": {
3+
"lines": [
4+
{
5+
"id": 1,
6+
"period": {
7+
"start": 1655024400,
8+
"end": 1657616400
9+
},
10+
"description": "Team plan usage",
11+
"amount": 5000
12+
},
13+
{
14+
"id": 2,
15+
"period": {
16+
"start": 1655024400,
17+
"end": 1657666799
18+
},
19+
"description": "Team plan proration",
20+
"amount": -300
21+
},
22+
{
23+
"id": 3,
24+
"period": {
25+
"start": 1657670400,
26+
"end": 1660345199
27+
},
28+
"description": "Business plan usage",
29+
"amount": 8000
30+
}
31+
],
32+
"total": 13300,
33+
"prorationDate": 1655024400,
34+
"collectionDate": 1660345199
35+
}
36+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"pricingPlans": [
3+
{
4+
"id": 1,
5+
"stripeId": "prod_LsNS1zRKy9PNkn",
6+
"hidden": false,
7+
"default": true,
8+
"createdAt": "2022-06-14T17:13:12.000Z",
9+
"updatedAt": "2022-06-14T17:13:12.000Z",
10+
"actions": [
11+
{
12+
"id": 1,
13+
"type": 0,
14+
"limit": 2,
15+
"trackedMonthly": false
16+
},
17+
{
18+
"id": 2,
19+
"type": 1,
20+
"limit": 2,
21+
"trackedMonthly": true
22+
}
23+
],
24+
"name": "Indie Plan",
25+
"prices": [
26+
{
27+
"amount": 0,
28+
"currency": "usd",
29+
"interval": "month",
30+
"current": true
31+
},
32+
{
33+
"amount": 0,
34+
"currency": "usd",
35+
"interval": "year",
36+
"current": false
37+
}
38+
]
39+
},
40+
{
41+
"id": 2,
42+
"stripeId": "prod_LsNTl1tTzZa1LI",
43+
"hidden": false,
44+
"default": false,
45+
"createdAt": "2022-06-14T17:13:34.000Z",
46+
"updatedAt": "2022-06-14T17:13:34.000Z",
47+
"actions": [
48+
{
49+
"id": 3,
50+
"type": 0,
51+
"limit": 10,
52+
"trackedMonthly": false
53+
},
54+
{
55+
"id": 4,
56+
"type": 1,
57+
"limit": 4,
58+
"trackedMonthly": true
59+
}
60+
],
61+
"name": "Team Plan",
62+
"prices": [
63+
{
64+
"amount": 599,
65+
"currency": "usd",
66+
"interval": "month",
67+
"current": false
68+
},
69+
{
70+
"amount": 6399,
71+
"currency": "usd",
72+
"interval": "year",
73+
"current": false
74+
}
75+
]
76+
},
77+
{
78+
"id": 3,
79+
"stripeId": "prod_LsNTee1kaFQNSU",
80+
"hidden": false,
81+
"default": false,
82+
"createdAt": "2022-06-14T17:13:55.000Z",
83+
"updatedAt": "2022-06-14T17:13:55.000Z",
84+
"actions": [
85+
{
86+
"id": 5,
87+
"type": 0,
88+
"limit": 50,
89+
"trackedMonthly": false
90+
},
91+
{
92+
"id": 6,
93+
"type": 1,
94+
"limit": 10,
95+
"trackedMonthly": true
96+
}
97+
],
98+
"name": "Business Plan",
99+
"prices": [
100+
{
101+
"amount": 1999,
102+
"currency": "usd",
103+
"interval": "month",
104+
"current": false
105+
},
106+
{
107+
"amount": 21499,
108+
"currency": "usd",
109+
"interval": "year",
110+
"current": false
111+
}
112+
]
113+
}
114+
]
115+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"usage": {
3+
"0": {
4+
"limit": 2,
5+
"used": 0
6+
},
7+
"1": {
8+
"limit": 3,
9+
"used": 1
10+
}
11+
}
12+
}

cypress/support/commands.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ Cypress.Commands.add('visitAsGuest', (url = '/') => {
2424
cy.visit(url)
2525
})
2626

27-
Cypress.Commands.add('login', (userType = 'dev') => {
27+
Cypress.Commands.add('login', (userType = 'dev', url = '/') => {
2828
cy.intercept('GET', 'http://talo.api/public/users/refresh', {
2929
statusCode: 200,
3030
fixture: `responses/auth/${userType}`
3131
})
3232

3333
cy.stubDashboardCalls()
3434

35-
cy.visit('/')
35+
cy.visit(url)
3636
})

0 commit comments

Comments
 (0)