mirror of
https://github.com/hanzo-apps/hanzo.ai.git
synced 2026-10-30 14:58:08 +00:00
54 lines
2.5 KiB
TypeScript
54 lines
2.5 KiB
TypeScript
import { expect, test } from '@playwright/test'
|
|
import { signIn } from './session'
|
|
|
|
/**
|
|
* THE FOOT'S THREE ERRANDS, AND THEY ARE THREE.
|
|
*
|
|
* Inviting a teammate adds somebody to your org; sharing Hanzo hands the
|
|
* product to somebody who has none; upgrading chooses a plan. hanzo.app drew
|
|
* them separately because they go to three different places, and a row that
|
|
* named one and did another would be the whole defect.
|
|
*/
|
|
test.beforeEach(async ({ page }) => {
|
|
await signIn(page)
|
|
await page.addInitScript(() => {
|
|
;(window as unknown as { asked?: string }).asked = undefined
|
|
window.open = ((url?: string | URL) => {
|
|
;(window as unknown as { asked?: string }).asked = String(url)
|
|
return null
|
|
}) as typeof window.open
|
|
})
|
|
await page.setViewportSize({ width: 1440, height: 900 })
|
|
await page.goto('/work')
|
|
await page.waitForLoadState('networkidle')
|
|
// At this width the sidebar is already open — its control reads "Close
|
|
// sidebar" — so there is nothing to press first. Pressing "Open sidebar"
|
|
// waited 30s for a button that only exists once the sidebar is shut, and
|
|
// took all three errands down with it before any of them was reached.
|
|
// Waiting on the first errand is the real precondition, and it is the
|
|
// fixed 900ms sleep's job done honestly.
|
|
await expect(page.getByRole('button', { name: 'Share Hanzo', exact: true })).toBeVisible()
|
|
})
|
|
|
|
test('Share Hanzo opens the referral page in place', async ({ page }) => {
|
|
await page.getByRole('button', { name: 'Share Hanzo', exact: true }).click()
|
|
// Polled rather than waited on: the router moves without a page load, so
|
|
// waiting for one waits for something that never happens.
|
|
await expect.poll(() => new URL(page.url()).pathname, { timeout: 15_000 }).toBe('/referral')
|
|
})
|
|
|
|
test('Upgrade opens the checkout at hanzo.ai/pay', async ({ page }) => {
|
|
await page.getByRole('button', { name: 'Upgrade', exact: true }).click()
|
|
expect(await page.evaluate(() => (window as unknown as { asked?: string }).asked)).toBe(
|
|
'https://hanzo.ai/pay',
|
|
)
|
|
})
|
|
|
|
test('Invite Teammates is a different errand and a different address', async ({ page }) => {
|
|
await page.getByRole('button', { name: 'Invite Teammates', exact: true }).click()
|
|
const asked = await page.evaluate(() => (window as unknown as { asked?: string }).asked)
|
|
expect(asked).not.toBe('https://billing.hanzo.ai')
|
|
// The org's own page, which is where members are added.
|
|
expect(asked, 'inviting is about an org, not a plan').toContain('/settings/organization/members')
|
|
})
|