diff --git a/packages/server/__snapshots__/7_record_spec.coffee.js b/packages/server/__snapshots__/7_record_spec.coffee.js index b0ad0f250a2c..3473b3e1c2c9 100644 --- a/packages/server/__snapshots__/7_record_spec.coffee.js +++ b/packages/server/__snapshots__/7_record_spec.coffee.js @@ -1537,7 +1537,107 @@ StatusCodeError: 402 ` -exports['e2e record api interaction warnings create run warnings grace period - over limit warns when over private test recordings 1'] = ` + +exports['e2e record api interaction errors create run 402 - free plan exceeds monthly tests errors and exits when on free plan and over recorded tests limit 1'] = ` +You've exceeded the limit of test recordings under your free plan this month. The limit is 500 test recordings. + +To continue recording tests this month you must upgrade your account. Please visit your billing to upgrade to another billing plan. + +https://on.cypress.io/dashboard/organizations/org-id-1234/billing + +` + +exports['e2e record api interaction errors create run 402 - grouping feature not available in plan errors and exits when attempting parallel run when not available in plan 1'] = ` +Grouping is not included under your current billing plan. + +To run your tests with groups, please visit your billing and upgrade to another plan with grouping. + +https://on.cypress.io/dashboard/organizations/org-id-1234/billing + +` + + +exports['e2e record api interaction warnings create run warnings grace period - grouping feature warns when using parallel feature 1'] = ` +Grouping is not included under your free plan. + +Your plan is now in a grace period, which means your tests will still run with groups until 2999-12-31. Please upgrade your plan to continue running your tests with groups in the future. + +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: 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) + + - /foo/bar/.projects/e2e/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 + + +` + +exports['e2e record api interaction warnings create run warnings grace period - over private tests limit warns when over private test recordings 1'] = ` You've exceeded the limit of private test recordings under your free plan this month. The limit is 500 private 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. @@ -1617,10 +1717,10 @@ https://on.cypress.io/dashboard/organizations/org-id-1234/billing ` -exports['e2e record api interaction warnings create run warnings grace period - parallel feature warns when using parallel feature 1'] = ` -Parallelization is not included under your free plan. +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 run in parallel until 2999-12-31. Please upgrade your plan to continue running your tests in parallel in the future. +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. https://on.cypress.io/dashboard/organizations/org-id-1234/billing @@ -1697,10 +1797,10 @@ https://on.cypress.io/dashboard/organizations/org-id-1234/billing ` -exports['e2e record api interaction warnings create run warnings paid plan - over 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. +exports['e2e record api interaction warnings create run warnings grace period - parallel feature warns when using parallel feature 1'] = ` +Parallelization is not included under your free plan. -To upgrade your account, please visit your billing to upgrade to another billing plan. +Your plan is now in a grace period, which means your tests will still run in parallel until 2999-12-31. Please upgrade your plan to continue running your tests in parallel in the future. https://on.cypress.io/dashboard/organizations/org-id-1234/billing @@ -1777,19 +1877,90 @@ https://on.cypress.io/dashboard/organizations/org-id-1234/billing ` -exports['e2e record api interaction errors create run 402 - grouping feature not available in plan errors and exits when attempting parallel run when not available in plan 1'] = ` -Grouping is not included under your current billing plan. +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. -To run your tests with groups, please visit your billing and upgrade to another plan with grouping. +To upgrade your account, please visit your billing to upgrade to another billing plan. 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: 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) + + - /foo/bar/.projects/e2e/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 + + ` -exports['e2e record api interaction warnings create run warnings grace period - grouping feature warns when using parallel feature 1'] = ` -Grouping is not included under your free plan. +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. -Your plan is now in a grace period, which means your tests will still run with groups until 2999-12-31. Please upgrade your plan to continue running your tests with groups in the future. +To upgrade your account, please visit your billing to upgrade to another billing plan. https://on.cypress.io/dashboard/organizations/org-id-1234/billing diff --git a/packages/server/lib/errors.coffee b/packages/server/lib/errors.coffee index 78c34e16cad4..a125bfac5408 100644 --- a/packages/server/lib/errors.coffee +++ b/packages/server/lib/errors.coffee @@ -690,7 +690,7 @@ getMsgByType = (type, arg1 = {}, arg2) -> """ when "FREE_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS" """ - You've exceeded the limit of private test recordings under your free plan this month. #{arg1.usedMessage} + You've exceeded the limit of private test recordings under your free plan this month. #{arg1.usedTestsMessage} To continue recording tests this month you must upgrade your account. Please visit your billing to upgrade to another billing plan. @@ -698,7 +698,7 @@ getMsgByType = (type, arg1 = {}, arg2) -> """ when "FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_PRIVATE_TESTS" """ - You've exceeded the limit of private test recordings under your free plan this month. #{arg1.usedMessage} + You've exceeded the limit of private 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. @@ -706,7 +706,31 @@ getMsgByType = (type, arg1 = {}, arg2) -> """ when "PAID_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS" """ - You've exceeded the limit of private test recordings under your current billing plan this month. #{arg1.usedMessage} + You've exceeded the limit of private test recordings under your current billing plan this month. #{arg1.usedTestsMessage} + + To upgrade your account, please visit your billing to upgrade to another billing plan. + + #{arg1.link} + """ + when "FREE_PLAN_EXCEEDS_MONTHLY_TESTS" + """ + You've exceeded the limit of test recordings under your free plan this month. #{arg1.usedTestsMessage} + + To continue recording tests this month you must upgrade your account. Please visit your billing to upgrade to another billing plan. + + #{arg1.link} + """ + when "FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_TESTS" + """ + 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. + + #{arg1.link} + """ + when "PAID_PLAN_EXCEEDS_MONTHLY_TESTS" + """ + You've exceeded the limit of test recordings under your current billing plan this month. #{arg1.usedTestsMessage} To upgrade your account, please visit your billing to upgrade to another billing plan. diff --git a/packages/server/lib/modes/record.coffee b/packages/server/lib/modes/record.coffee index b43269d61b6a..b2f93bbf5baa 100644 --- a/packages/server/lib/modes/record.coffee +++ b/packages/server/lib/modes/record.coffee @@ -231,9 +231,9 @@ getCommitFromGitOrCi = (git) -> defaultBranch: null }) -usedMessage = (limit) -> +usedTestsMessage = (limit, phrase) -> if _.isFinite(limit) - "The limit is #{chalk.blue(limit)} private test recordings." + "The limit is #{chalk.blue(limit)} #{phrase} recordings." else "" @@ -307,7 +307,13 @@ createRun = (options = {}) -> switch warning.code when "FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_PRIVATE_TESTS" errors.warning("FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_PRIVATE_TESTS", { - usedMessage: usedMessage(warning.limit) + usedTestsMessage: usedTestsMessage(warning.limit, "private test") + gracePeriodMessage: gracePeriodMessage(warning.gracePeriodEnds) + link: billingLink(warning.orgId) + }) + when "FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_TESTS" + errors.warning("FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_TESTS", { + usedTestsMessage: usedTestsMessage(warning.limit, "test") gracePeriodMessage: gracePeriodMessage(warning.gracePeriodEnds) link: billingLink(warning.orgId) }) @@ -318,7 +324,12 @@ createRun = (options = {}) -> }) when "PAID_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS" errors.warning("PAID_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS", { - usedMessage: usedMessage(warning.limit) + usedTestsMessage: usedTestsMessage(warning.limit, "private test") + link: billingLink(warning.orgId) + }) + when "PAID_PLAN_EXCEEDS_MONTHLY_TESTS" + errors.warning("PAID_PLAN_EXCEEDS_MONTHLY_TESTS", { + usedTestsMessage: usedTestsMessage(warning.limit, "test") link: billingLink(warning.orgId) }) when "PLAN_IN_GRACE_PERIOD_RUN_GROUPING_FEATURE_USED" @@ -345,7 +356,12 @@ createRun = (options = {}) -> switch code when "FREE_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS" errors.throw("FREE_PLAN_EXCEEDS_MONTHLY_PRIVATE_TESTS", { - usedMessage: usedMessage(limit) + usedTestsMessage: usedTestsMessage(limit, "private test") + link: billingLink(orgId) + }) + when "FREE_PLAN_EXCEEDS_MONTHLY_TESTS" + errors.throw("FREE_PLAN_EXCEEDS_MONTHLY_TESTS", { + usedTestsMessage: usedTestsMessage(limit, "test") link: billingLink(orgId) }) when "PARALLEL_FEATURE_NOT_AVAILABLE_IN_PLAN" diff --git a/packages/server/test/e2e/7_record_spec.coffee b/packages/server/test/e2e/7_record_spec.coffee index d07315e29296..3b3b211616d6 100644 --- a/packages/server/test/e2e/7_record_spec.coffee +++ b/packages/server/test/e2e/7_record_spec.coffee @@ -829,6 +829,30 @@ describe "e2e record", -> expectedExitCode: 1 }) + describe "create run 402 - free plan exceeds monthly tests", -> + setup([{ + method: "post" + url: "/runs" + req: "postRunRequest@2.1.0", + res: (req, res) -> res.status(402).json({ + code: "FREE_PLAN_EXCEEDS_MONTHLY_TESTS" + payload: { + used: 600 + limit: 500 + orgId: "org-id-1234" + } + }) + }]) + + it "errors and exits when on free plan and over recorded tests limit", -> + e2e.exec(@, { + key: "f858a2bc-b469-4e48-be67-0876339ee7e1" + spec: "record_pass*" + record: true + snapshot: true + expectedExitCode: 1 + }) + describe "create run 402 - parallel feature not available in plan", -> setup([{ method: "post" @@ -1164,7 +1188,7 @@ describe "e2e record", -> describe "api interaction warnings", -> describe "create run warnings", -> - describe "grace period - over limit", -> + describe "grace period - over private tests limit", -> routes = defaultRoutes.slice() routes[0] = { method: "post" @@ -1195,6 +1219,37 @@ describe "e2e record", -> expectedExitCode: 0 }) + describe "grace period - over tests limit", -> + routes = defaultRoutes.slice() + routes[0] = { + method: "post" + url: "/runs" + req: "postRunRequest@2.1.0", + res: (req, res) -> res.status(200).json({ + runId + groupId + machineId + runUrl + warnings: [{ + code: "FREE_PLAN_IN_GRACE_PERIOD_EXCEEDS_MONTHLY_TESTS" + limit: 500 + gracePeriodEnds: "2999-12-31" + orgId: "org-id-1234" + }] + }) + } + + setup(routes) + + it "warns when over test recordings", -> + e2e.exec(@, { + key: "f858a2bc-b469-4e48-be67-0876339ee7e1" + spec: "record_pass*" + record: true + snapshot: true + expectedExitCode: 0 + }) + describe "grace period - parallel feature", -> routes = defaultRoutes.slice() routes[0] = { @@ -1255,7 +1310,7 @@ describe "e2e record", -> expectedExitCode: 0 }) - describe "paid plan - over limit", -> + describe "paid plan - over private tests limit", -> routes = defaultRoutes.slice() routes[0] = { method: "post" @@ -1285,3 +1340,34 @@ describe "e2e record", -> snapshot: true expectedExitCode: 0 }) + + describe "paid plan - over tests limit", -> + routes = defaultRoutes.slice() + routes[0] = { + method: "post" + url: "/runs" + req: "postRunRequest@2.1.0", + res: (req, res) -> res.status(200).json({ + runId + groupId + machineId + runUrl + warnings: [{ + code: "PAID_PLAN_EXCEEDS_MONTHLY_TESTS" + used: 700 + limit: 500 + orgId: "org-id-1234" + }] + }) + } + + setup(routes) + + it "warns when over test recordings", -> + e2e.exec(@, { + key: "f858a2bc-b469-4e48-be67-0876339ee7e1" + spec: "record_pass*" + record: true + snapshot: true + expectedExitCode: 0 + })