0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-28 00:46:45 +01:00
posthog/cypress/e2e/billingUpgradeCTA.cy.ts
Bianca Yang d8e7d1a4a7
feat: Add Cypress Tests for Onboarding Flow (#20676)
* wip

* iteration 1

* some small fixes

* update

* Update UI snapshots for `chromium` (1)

* fix up product intro page test

* Update UI snapshots for `webkit` (2)

* Update UI snapshots for `webkit` (2)

* rebase on main, fix a type issue

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `chromium` (2)

* remove console log

* remove extraneous file

* fix tests again...

* Update UI snapshots for `chromium` (2)

* more test tweaks

* Update UI snapshots for `chromium` (2)

* yet another set of fixeds

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `webkit` (2)

* Update UI snapshots for `chromium` (2)

* Update UI snapshots for `webkit` (2)

* one more test tweak

* fix(admin): follow up for org page performance improvements (#20912)

* feat: Add clickhouse migration to create a dictionary (#20665)

* feat: Add clickhouse migration to create a dictionary

* refactor: Use dictionary created in migration for squashing

* fix: Test file drop references to dictionary

* fix: Update comment

* chore: Master merge

* fix: Typo in dictionary

Co-authored-by: James Greenhill <fuziontech@gmail.com>

---------

Co-authored-by: James Greenhill <fuziontech@gmail.com>

* fix: picking embedding input samples (#20913)

* fix: Split healthcheck to separate nginx unit app (#20917)

Split healthcheck to separate nginx unit app

When posthog is under load the healthcheck can stop responding.
Split it off into a separate app so it has a dedicated thread to handle it

* chore: BillingProduct cleanup (#20910)

* fix: show names on frontend (#20918)

* fix(experiment): revert default goal back to Trends (#20921)

* Add missing healthcheck routes to app (#20923)

* Add missing healthcheck routes to app

* Switch healthz to _health

* chore: Add context to deployment messages (#20911)

Add context to deployment messages

Co-authored-by: xneyder <xneyder@gmail.com>

* chore(environments): Add migration to backfill projects (#20887)

* chore(environments): Add migration to backfill projects

* Fix `noop`

* Add `project_id` to plugin server test setup

* Fix `project_id`

* Also add `posthog_project` to plugin server tests

* Update `createTeam`

* Fix func tests

* refactor(style): do not use star imports for locals (#20915)

* feat(sentry): enable sampling via http header (#20916)

* fix: Add missing underscore to healthcheck routes (#20926)

Add missing underscore to healthcheck routes

* chore(deps): Update posthog-js to 1.115.0 (#20924)

* fix(toolbar): Keep flags in sync (#20927)

* fix(toolbar): Keep flags in sync

* add test

* fix: some typos in summary settings (#20925)

* fix: some typos in summary settings

* Update UI snapshots for `chromium` (2)

* don't compare instance equality you fool

* feels wrong for reset to change opt in status...

* Fix

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* fix: custom player inspector events should respect mini filters (#20929)

* fix: custom player inspector events should respect mini filters

* all the alls

* fix: don't show billing step on self-hosted (#20931)

don't show billing step on self-hosted

* chore: improve onboarding spacing consistency (#20838)

* Make the space between sections consistent

* add more space above team section

* Improve the topbar spacing and positioning

* Move the breadcrumbs above and center the title

* Make spacing consistent across all SDKs

* Add chain op to plans for when they aren't available

* Make sdk margin top consistent with other steps

* Update the invite onboarding step title

* Move the breadcrumbs to be left aligned

* Set top bar title to onboarding in onboarding

* Fix cypress tests

* Update cypress tests

* Remove stale snapshots

* remove billing changes

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* fix: flappy snapshot (#20930)

* attempt fix for flappy snapshot

* Update UI snapshots for `chromium` (2)

* fix another one

* Update UI snapshots for `chromium` (2)

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* fix storybook

* Update UI snapshots for `webkit` (2)

* Update UI snapshots for `chromium` (1)

* Update UI snapshots for `chromium` (2)

* fix some tests

* another round of fixes

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Thomas Obermüller <thomas.obermueller@gmail.com>
Co-authored-by: Tomás Farías Santana <tomas@tomasfarias.dev>
Co-authored-by: James Greenhill <fuziontech@gmail.com>
Co-authored-by: David Newell <d.newell1@outlook.com>
Co-authored-by: Frank Hamand <frankhamand@gmail.com>
Co-authored-by: Juraj Majerik <juro.majerik@gmail.com>
Co-authored-by: danielxnj <115043334+danielxnj@users.noreply.github.com>
Co-authored-by: xneyder <xneyder@gmail.com>
Co-authored-by: Michael Matloka <dev@twixes.com>
Co-authored-by: PostHog Bot <69588470+posthog-bot@users.noreply.github.com>
Co-authored-by: Neil Kakkar <neilkakkar@gmail.com>
Co-authored-by: Paul D'Ambra <paul@posthog.com>
Co-authored-by: Raquel Smith <raquelmsmith@users.noreply.github.com>
Co-authored-by: Zach Waterfield <zlwaterfield@gmail.com>
2024-03-18 21:19:26 -07:00

58 lines
2.3 KiB
TypeScript

import { decideResponse } from '../fixtures/api/decide'
import * as fflate from 'fflate'
// Mainly testing to make sure events are fired as expected
describe('Billing Upgrade CTA', () => {
beforeEach(() => {
cy.intercept('**/decide/*', (req) =>
req.reply(
decideResponse({
'billing-upgrade-language': 'credit_card',
})
)
)
cy.intercept('/api/billing-v2/', { fixture: 'api/billing-v2/billing-v2-unsubscribed.json' })
})
it('Check that events are being sent on each page visit', () => {
cy.visit('/organization/billing')
cy.get('[data-attr=product_analytics-upgrade-cta] .LemonButton__content').should('have.text', 'Add credit card')
cy.window().then((win) => {
const events = (win as any)._cypress_posthog_captures
const matchingEvents = events.filter((event) => event.event === 'billing CTA shown')
// One for each product card
expect(matchingEvents.length).to.equal(4)
})
// Mock billing response with subscription
cy.intercept('/api/billing-v2/', { fixture: 'api/billing-v2/billing-v2.json' })
cy.reload()
cy.get('[data-attr=session_replay-upgrade-cta] .LemonButton__content').should('have.text', 'Add paid plan')
cy.intercept('POST', '**/e/?compression=gzip-js*').as('capture3')
cy.window().then((win) => {
const events = (win as any)._cypress_posthog_captures
const matchingEvents = events.filter((event) => event.event === 'billing CTA shown')
expect(matchingEvents.length).to.equal(3)
})
cy.intercept('/api/billing-v2/', { fixture: 'api/billing-v2/billing-v2-unsubscribed.json' })
// Navigate to the onboarding billing step
cy.visit('/products')
cy.get('[data-attr=product_analytics-onboarding-card]').click()
cy.get('[data-attr=onboarding-breadcrumbs] > :nth-child(5)').click()
cy.intercept('POST', '**/e/?compression=gzip-js*').as('capture4')
cy.window().then((win) => {
const events = (win as any)._cypress_posthog_captures
const matchingEvents = events.filter((event) => event.event === 'billing CTA shown')
expect(matchingEvents.length).to.equal(3)
})
})
})