app.spec.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { test, expect } from '@playwright/test'
  2. /**
  3. * The cheapest possible proof that a build is not dead on arrival: the session
  4. * survives, the main lists render, and the contract the technician app depends
  5. * on still answers.
  6. */
  7. test.describe('smoke', () => {
  8. test('the authenticated shell loads', async ({ page }) => {
  9. await page.goto('/')
  10. await expect(page).not.toHaveURL(/\/auth\//)
  11. await expect(page.locator('#password')).toHaveCount(0)
  12. })
  13. test('the seeded workshop has customers and vehicles', async ({ page }) => {
  14. // Lists render a card for phones and a table for wider screens and hide
  15. // one of them; the table is the visible one at the desktop size used here.
  16. // Searched, like the vehicles below: the list shows the twenty customers
  17. // touched last, and the specs that run before this one plant their own,
  18. // so the seed's are not on the first page of an unsearched list.
  19. await page.goto('/customers?search=James%20Mitchell')
  20. await expect(page.getByRole('table').getByText('James Mitchell').first()).toBeVisible()
  21. // The vehicle list opens as a grid of cards, each headed by the vehicle's
  22. // name; searched, so the one asserted on is on the first page.
  23. await page.goto('/vehicles?search=Camry')
  24. await expect(page.getByRole('heading', { name: /Camry/i }).first()).toBeVisible()
  25. })
  26. test('the technician app handshake still answers', async ({ request }) => {
  27. // The mobile app calls this before a technician can type anything else. A
  28. // change to its shape strands every phone, and no unit test would notice.
  29. const response = await request.get('/api/v1/tech/health')
  30. expect(response.status()).toBe(200)
  31. const body = (await response.json()) as {
  32. data?: { service?: string; api?: string; minAppVersion?: string }
  33. }
  34. expect(body.data?.service).toBe('torqvoice')
  35. expect(body.data?.api).toBe('v1')
  36. expect(body.data?.minAppVersion).toMatch(/^\d+\.\d+\.\d+$/)
  37. })
  38. })