pages.spec.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { expect, test } from '@playwright/test'
  2. import { settle } from '../../support/hydration'
  3. /**
  4. * The sign-in and sign-up pages on a self-hosted install.
  5. *
  6. * The pages were rebuilt around a cloud sign-up pitch, and a self-hosted
  7. * install must not get it: its visitors are the workshop's own staff, and a
  8. * "free plan, no credit card" banner or a Google button would be selling them
  9. * a product they already run, through a Google client nobody configured. What
  10. * they do keep is the way to an account above the form and the language
  11. * switcher, which is theirs as much as anybody's.
  12. */
  13. test.use({ storageState: { cookies: [], origins: [] } })
  14. test.describe('a self-hosted install', () => {
  15. test('signs people up without a sales pitch or Google', async ({ page }) => {
  16. await page.goto('/auth/sign-up')
  17. await settle(page)
  18. for (const field of ['#name', '#email', '#password']) {
  19. await expect(page.locator(field)).toBeVisible()
  20. }
  21. await expect(page.getByText('Free plan, no credit card')).toHaveCount(0)
  22. await expect(page.getByRole('button', { name: 'Continue with Google' })).toHaveCount(0)
  23. })
  24. test('puts the way to an account above the sign-in form', async ({ page }) => {
  25. await page.goto('/auth/sign-in')
  26. await settle(page)
  27. const link = page.getByRole('link', { name: 'Create one' })
  28. await expect(link).toHaveAttribute('href', /\/auth\/sign-up/)
  29. const linkBox = await link.boundingBox()
  30. const emailBox = await page.locator('#email').boundingBox()
  31. expect(linkBox && emailBox && linkBox.y < emailBox.y, 'the link sits above the form').toBe(true)
  32. await expect(page.getByRole('button', { name: 'Continue with Google' })).toHaveCount(0)
  33. })
  34. test('lets the language be changed before signing in', async ({ page, context }) => {
  35. await page.goto('/auth/sign-in')
  36. await settle(page)
  37. await expect(page.getByRole('button', { name: 'Sign In', exact: true })).toBeVisible()
  38. await expect(async () => {
  39. await page.getByRole('combobox', { name: 'Language' }).click()
  40. await expect(page.getByRole('option', { name: 'Norsk Bokmål' })).toBeVisible({
  41. timeout: 2_000,
  42. })
  43. }).toPass({ timeout: 30_000 })
  44. await page.getByRole('option', { name: 'Norsk Bokmål' }).click()
  45. // The page re-renders in Norwegian and the choice is kept.
  46. await expect(page.getByRole('button', { name: 'Sign In', exact: true })).toHaveCount(0, {
  47. timeout: 30_000,
  48. })
  49. const cookie = (await context.cookies()).find((c) => c.name === 'locale')
  50. expect(cookie?.value).toBe('nb')
  51. })
  52. })