Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

2.6 KB
Raw Blame
import { test, expect, type Page } from '@playwright/test'
import { tauriMockInit, DEFAULT_ASSISTANT_REPLY, DEFAULT_MODEL_NAME } from './support/tauri-mock'
import { routeCloud, seedOnboardingDone, signInViaGate, cloudSwitch } from './support/cloud-mock'
import { openNewChat } from './support/ui'

/**
 * 2.5.7 cloud onboarding — purple header switch → gate login → cloud mode.
 *
 * A Max-plan account flips the switch to Cloud through the gate modal: login
 * (email+password against the mocked Supabase), /api/me grants access, the
 * modal closes itself, and the chat picker surfaces ONLY the hosted catalog
 * while the local-hardware tabs disappear. Flipping back to Local restores
 * today's app. (The 2.5.7 first-flip onboarding modal is gone — since #91 the
 * one-time onboarding runs in the web checkout after subscribing.)
 */

async function boot(page: Page) {
  await page.addInitScript(tauriMockInit, {
    assistantReply: DEFAULT_ASSISTANT_REPLY,
    modelName: DEFAULT_MODEL_NAME,
  })
  await seedOnboardingDone(page)
  await routeCloud(page, { license: 'active', tier: 'hosted-max', access: true })
  await page.goto('/')
  await expect(cloudSwitch(page)).toBeVisible({ timeout: 20_000 })
}

test('Max account: switch → login → cloud mode with the hosted catalog', async ({ page }) => {
  await boot(page)

  // Local-hardware tabs exist in local mode.
  await expect(page.getByRole('button', { name: /^Models$/ })).toBeVisible()

  await signInViaGate(page)

  // The gate flips the mode itself once the account clears every check.
  await expect(cloudSwitch(page)).toBeChecked({ timeout: 20_000 })

  // Local-hardware surfaces are gone in cloud mode.
  await expect(page.getByRole('button', { name: /^Models$/ })).toBeHidden()
  await expect(page.getByRole('button', { name: /^Benchmark$/ })).toBeHidden()

  // The chat picker lists the hosted catalog (and only it), and none of it
  // is picked for the user: since 3.0.5 he names the model himself.
  await openNewChat(page)
  const picker = page.getByRole('button', { name: 'Select chat model', exact: true })
  await expect(picker).toContainText('Choose a model', { timeout: 20_000 })
  await picker.click()
  const menu = page.getByTestId('model-picker-menu')
  await expect(menu.getByRole('button', { name: /Llama 3\.1 8B Turbo/i })).toBeVisible({ timeout: 20_000 })
  await expect(menu.getByText(DEFAULT_MODEL_NAME)).toHaveCount(0)
  await page.keyboard.press('Escape')

  // Flipping back to Local always works and restores the local tabs.
  await cloudSwitch(page).click()
  await expect(cloudSwitch(page)).not.toBeChecked()
  await expect(page.getByRole('button', { name: /^Models$/ })).toBeVisible()
})