Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update error message for new error thrown when free plan limit exceeded #8409

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 86 additions & 4 deletions packages/server/__snapshots__/7_record_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,9 @@ https://on.cypress.io/dashboard/organizations/org-id-1234/billing
exports['e2e record api interaction warnings create run warnings grace period - over tests limit warns when over test recordings 1'] = `
You've exceeded the limit of test recordings under your free plan this month. The limit is 500 test recordings.

Your plan is now in a grace period, which means your tests will still be recorded until 2999-12-31. Please upgrade your plan to continue recording tests on the Cypress Dashboard in the future.
Your plan is now in a grace period, which means you will have the full benefits of your current plan until 2999-12-31.

Please visit your billing to upgrade your plan.

https://on.cypress.io/dashboard/organizations/org-id-1234/billing

Expand Down Expand Up @@ -1917,9 +1919,9 @@ https://on.cypress.io/dashboard/organizations/org-id-1234/billing
`

exports['e2e record api interaction warnings create run warnings paid plan - over private tests limit warns when over private test recordings 1'] = `
You've exceeded the limit of private test recordings under your current billing plan this month. The limit is 500 private test recordings.
You've exceeded the limit of test recordings under your current billing plan this month. The limit is 500 private test recordings.

To upgrade your account, please visit your billing to upgrade to another billing plan.
To continue getting the full benefits of your current plan, please visit your billing to upgrade.

https://on.cypress.io/dashboard/organizations/org-id-1234/billing

Expand Down Expand Up @@ -1999,7 +2001,7 @@ https://on.cypress.io/dashboard/organizations/org-id-1234/billing
exports['e2e record api interaction warnings create run warnings paid plan - over tests limit warns when over test recordings 1'] = `
You've exceeded the limit of test recordings under your current billing plan this month. The limit is 500 test recordings.

To upgrade your account, please visit your billing to upgrade to another billing plan.
To continue getting the full benefits of your current plan, please visit your billing to upgrade.

https://on.cypress.io/dashboard/organizations/org-id-1234/billing

Expand Down Expand Up @@ -2424,3 +2426,83 @@ exports['e2e record passing passes 2'] = [
}
}
]

exports['e2e record api interaction warnings create run warnings free plan - over tests limit v2 warns when over test recordings 1'] = `
You've exceeded the limit of test recordings under your free billing plan this month. The limit is 500 test recordings.

To continue getting the full benefits of your current plan, please visit your billing to upgrade.

https://on.cypress.io/dashboard/organizations/org-id-1234/billing

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 1.2.3 │
│ Browser: FooBrowser 88 │
│ Specs: 1 found (record_pass_spec.coffee) │
│ Searched: cypress/integration/record_pass* │
│ Params: Tag: false, Group: false, Parallel: false │
│ Run URL: https://dashboard.cypress.io/projects/cjvoj7/runs/12 │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: record_pass_spec.coffee (1 of 1)
Estimated: 8 seconds


record pass
✓ passes
- is pending


1 passing
1 pending


(Results)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Tests: 2 │
│ Passing: 1 │
│ Failing: 0 │
│ Pending: 1 │
│ Skipped: 0 │
│ Screenshots: 1 │
│ Video: true │
│ Duration: X seconds │
│ Estimated: 8 seconds │
│ Spec Ran: record_pass_spec.coffee │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


(Screenshots)

- /XXX/XXX/XXX/cypress/screenshots/record_pass_spec.coffee/yay it passes.png (202x1002)


(Uploading Results)

- Done Uploading (1/1) /foo/bar/.projects/e2e/cypress/screenshots/record_pass_spec.coffee/yay it passes.png

====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✔ record_pass_spec.coffee XX:XX 2 1 - 1 - │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✔ All specs passed! XX:XX 2 1 - 1 -


───────────────────────────────────────────────────────────────────────────────────────────────────────

Recorded Run: https://dashboard.cypress.io/projects/cjvoj7/runs/12


`
10 changes: 6 additions & 4 deletions packages/server/lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,16 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) {
return stripIndent`\
You've exceeded the limit of test recordings under your free plan this month. ${arg1.usedTestsMessage}

Your plan is now in a grace period, which means your tests will still be recorded until ${arg1.gracePeriodMessage}. Please upgrade your plan to continue recording tests on the Cypress Dashboard in the future.
Your plan is now in a grace period, which means you will have the full benefits of your current plan until ${arg1.gracePeriodMessage}.

Please visit your billing to upgrade your plan.

${arg1.link}`
case 'PAID_PLAN_EXCEEDS_MONTHLY_TESTS':
case 'PLAN_EXCEEDS_MONTHLY_TESTS':
return stripIndent`\
You've exceeded the limit of test recordings under your current billing plan this month. ${arg1.usedTestsMessage}
You've exceeded the limit of test recordings under your ${arg1.planType} billing plan this month. ${arg1.usedTestsMessage}

To upgrade your account, please visit your billing to upgrade to another billing plan.
To continue getting the full benefits of your current plan, please visit your billing to upgrade.

${arg1.link}`
case 'FREE_PLAN_IN_GRACE_PERIOD_PARALLEL_FEATURE':
Expand Down
12 changes: 10 additions & 2 deletions packages/server/lib/modes/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,21 @@ const createRun = Promise.method((options = {}) => {
gracePeriodMessage: gracePeriodMessage(warning.gracePeriodEnds),
link: billingLink(warning.orgId),
})
case 'FREE_PLAN_EXCEEDS_MONTHLY_TESTS_V2':
return errors.warning('PLAN_EXCEEDS_MONTHLY_TESTS', {
planType: 'free',
usedTestsMessage: usedTestsMessage(warning.limit, 'test'),
link: billingLink(warning.orgId),
})
case 'PAID_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS':
return errors.warning('PAID_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS', {
return errors.warning('PLAN_EXCEEDS_MONTHLY_TESTS', {
planType: 'current',
usedTestsMessage: usedTestsMessage(warning.limit, 'private test'),
link: billingLink(warning.orgId),
})
case 'PAID_PLAN_EXCEEDS_MONTHLY_TESTS':
return errors.warning('PAID_PLAN_EXCEEDS_MONTHLY_TESTS', {
return errors.warning('PLAN_EXCEEDS_MONTHLY_TESTS', {
planType: 'current',
usedTestsMessage: usedTestsMessage(warning.limit, 'test'),
link: billingLink(warning.orgId),
})
Expand Down
39 changes: 39 additions & 0 deletions packages/server/test/e2e/7_record_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1668,6 +1668,45 @@ describe('e2e record', () => {
})
})

describe('free plan - over tests limit v2', () => {
const routes = defaultRoutes.slice()

routes[0] = {
method: 'post',
url: '/runs',
req: 'postRunRequest@2.2.0',
resSchema: 'postRunResponse@2.2.0',
res (req, res) {
return res.status(200).json({
runId,
groupId,
machineId,
runUrl,
tags,
warnings: [{
name: 'FreePlanExceedsMonthlyTests',
message: 'Warning from Cypress Dashboard: Organization with free plan has exceeded monthly test recordings limit.',
code: 'FREE_PLAN_EXCEEDS_MONTHLY_TESTS_V2',
used: 700,
limit: 500,
orgId: 'org-id-1234',
}],
})
},
}

setup(routes)

it('warns when over test recordings', function () {
return e2e.exec(this, {
key: 'f858a2bc-b469-4e48-be67-0876339ee7e1',
spec: 'record_pass*',
record: true,
snapshot: true,
})
})
})

describe('unknown warning', () => {
const routes = defaultRoutes.slice()

Expand Down