Add saved starter words for signed-in players

Players can save up to 3 favorite opening words and tap one to fill the
current row. Words are stored on profiles.starter_words and saved through
the set_starter_words RPC, which validates them against the dictionary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zakaria
2026-10-28 10:39:32 -04:00
parent e4d0d3b55c
commit 6daf3237e8
5 changed files with 427 additions and 4 deletions
+45
View File
@@ -116,3 +116,48 @@ test("definition lookup leaves loading state when a provider times out", async (
timeout: 6500
})
})
test("guests are prompted to sign in to save starter words", async ({ page }) => {
await openApp(page)
await skipIntro(page)
const starterPanel = page.locator("#starter-panel")
await expect(starterPanel).toBeVisible()
await expect(starterPanel).toContainText("to save up to 3 favorite openers")
await expect(page.locator("#starter-edit")).toBeHidden()
await starterPanel.locator("[data-starter-sign-in]").click()
await expect(page.locator("#auth-modal")).toBeVisible()
})
test("starter words fill the current row and the editor keeps keys off the board", async ({ page }) => {
await page.route("**/rest/v1/rpc/set_starter_words", route => route.fulfill({ json: ["crane", "arise"] }))
await openApp(page)
await skipIntro(page)
await expect(page.locator("#round-status")).not.toContainText("Loading")
await page.evaluate(() => {
authSession = { user: { id: "test-user", email: "player@example.test" } }
starterWords = ["plane", "arise"]
starterWordsLoaded = true
renderStarterPanel()
})
const readFirstRow = () => page.locator("[data-guess-grid] .tile").evaluateAll(tiles =>
tiles.slice(0, 5).map(tile => tile.dataset.letter || "").join("")
)
await page.keyboard.press("Q")
await page.locator("[data-starter-word='arise']").click()
expect(await readFirstRow()).toBe("arise")
await page.locator("#starter-edit").click()
const firstInput = page.locator(".starter-input").first()
await expect(firstInput).toHaveValue("plane")
await firstInput.fill("crane")
await firstInput.press("Enter")
await expect(page.locator("[data-alert-container]")).toContainText("Starter words saved")
await expect(page.locator("[data-starter-word]")).toHaveText(["crane", "arise"])
expect(await readFirstRow()).toBe("arise")
})