test(desktop): target API key field by test id, not label

Follow-up to 4e18170. `getByLabel("API Key", { exact: true })` still
failed: when the credential is required the field's accessible name is
"API Key *" (the required "*" marker is included in the label-derived
name despite aria-hidden), so an exact "API Key" match resolves to zero
elements and times out.

Switch all 16 call sites to getByTestId("persona-provider-api-key") —
the stable id on the input across every surface (persona, global config,
edit agent). This sidesteps both the show/hide-button collision and the
required-marker name variance. Playwright's own strict-mode output named
this test id as the canonical locator for the element.

Signed-off-by: Atish Patel <atish@squareup.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Atish Patel
2026-07-17 20:42:47 -05:00
parent 83d01852a6
commit bf25546cce
7 changed files with 15 additions and 13 deletions

View File

@@ -180,7 +180,7 @@ test.describe("agent readiness gate screenshots", () => {
await selectProvider(page, "Anthropic");
await setCustomModel(page, "claude-opus-4-5");
await expect(page.getByLabel("API Key", { exact: true })).toBeVisible();
await expect(page.getByTestId("persona-provider-api-key")).toBeVisible();
await expect(page.getByTestId("persona-dialog-submit")).toBeDisabled({
timeout: 10_000,
});
@@ -219,7 +219,7 @@ test.describe("agent readiness gate screenshots", () => {
await selectProvider(page, "Anthropic");
await setCustomModel(page, "claude-opus-4-5");
await page
.getByLabel("API Key", { exact: true })
.getByTestId("persona-provider-api-key")
.fill("sk-test-api-key-for-e2e");
await expect(page.getByTestId("persona-dialog-submit")).toBeEnabled({

View File

@@ -135,7 +135,7 @@ test.describe("edit agent dialog", () => {
await page.locator("#edit-agent-custom-model").fill("claude-opus-4-5");
// Anthropic requires a credential before save unlocks.
await page
.getByLabel("API Key", { exact: true })
.getByTestId("persona-provider-api-key")
.fill("sk-test-edit-agent-e2e");
const submit = page.getByTestId("edit-agent-dialog-submit");

View File

@@ -212,7 +212,7 @@ test.describe("global agent config screenshots", () => {
await openCreateDialog(page);
await customizeAgentAi(page);
await expect(page.getByLabel("API Key", { exact: true })).toBeVisible({
await expect(page.getByTestId("persona-provider-api-key")).toBeVisible({
timeout: 10_000,
});
await expect(
@@ -233,7 +233,7 @@ test.describe("global agent config screenshots", () => {
await openCreateDialog(page);
await customizeAgentAi(page);
await expect(page.getByLabel("API Key", { exact: true })).toHaveAttribute(
await expect(page.getByTestId("persona-provider-api-key")).toHaveAttribute(
"placeholder",
"Inherited from global config",
);

View File

@@ -966,7 +966,7 @@ test("config page shows Agent defaults form", async ({ page }) => {
).toHaveCount(0);
await page.keyboard.press("Escape");
await expect(page.getByText("Applies to all agents")).toHaveCount(0);
await expect(page.getByLabel("OpenAI API Key")).toHaveCount(0);
await expect(page.getByTestId("persona-provider-api-key")).toHaveCount(0);
await expect(effortSelect).toBeVisible();
await expect(
page.getByText(
@@ -1338,7 +1338,7 @@ test("compact default config still persists rapid provider edits", async ({
await chooseConfigDropdownOption(page, "global-agent-provider", "anthropic");
await expect(providerSelect).toHaveAttribute("data-value", "anthropic");
await expect(page.getByLabel("API Key")).toBeVisible();
await expect(page.getByTestId("persona-provider-api-key")).toBeVisible();
await expect(page.getByLabel("Value for DATABRICKS_HOST")).toHaveCount(0);
});

View File

@@ -329,7 +329,7 @@ test("persona model options follow the selected LLM provider", async ({
await selectDropdownOption(page, llmProvider, "OpenAI");
const dialog = page.getByRole("dialog");
await expect(dialog.getByLabel("API Key", { exact: true })).toBeVisible();
await expect(dialog.getByTestId("persona-provider-api-key")).toBeVisible();
await expect(
dialog.getByRole("button", { name: "Advanced", exact: true }),
).toHaveAttribute("aria-expanded", "false");
@@ -342,17 +342,19 @@ test("persona model options follow the selected LLM provider", async ({
.click();
await selectDropdownOption(page, llmProvider, "Anthropic");
await expect(dialog.getByLabel("API Key", { exact: true })).toBeVisible();
await expect(dialog.getByTestId("persona-provider-api-key")).toBeVisible();
await expect(model).toBeVisible();
await selectDropdownOption(page, llmProvider, "Gemini");
await expect(dialog.getByLabel("API Key", { exact: true })).toBeVisible();
await expect(dialog.getByTestId("persona-provider-api-key")).toBeVisible();
await expect(model).toBeVisible();
// Switch back to inherited defaults — per-agent provider, credential, and
// model controls disappear together.
await page.getByRole("tab", { name: "Use agent defaults" }).click();
await expect(llmProvider).not.toBeVisible();
await expect(dialog.getByLabel("API Key", { exact: true })).not.toBeVisible();
await expect(
dialog.getByTestId("persona-provider-api-key"),
).not.toBeVisible();
await expect(model).not.toBeVisible();
});

View File

@@ -237,7 +237,7 @@ test("create agent supports parallelism and system prompt overrides", async ({
.click();
await page.getByLabel("Custom model ID").fill("claude-opus-4-5");
await page
.getByLabel("API Key", { exact: true })
.getByTestId("persona-provider-api-key")
.fill("sk-test-api-key-for-e2e");
const advancedToggle = page.getByRole("button", {

View File

@@ -154,7 +154,7 @@ test.describe("welcome and channel agent entry points", () => {
.click();
await page.getByLabel("Custom model ID").fill("claude-opus-4-5");
await page
.getByLabel("API Key", { exact: true })
.getByTestId("persona-provider-api-key")
.fill("sk-test-api-key-for-e2e");
await expect(page.getByTestId("persona-dialog-submit")).toBeEnabled();
await page.getByTestId("persona-dialog-submit").click();