mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-10 12:37:55 +01:00
fix(slack): recover rejected grants and consume creation confirmations
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
61d199b086
commit
34ffc905ea
5 files changed
+77
-6
No files matched your search
@@ -201,6 +201,59 @@ test.describe.serial("native chat adapter UI", () => {
|
||||
await expect.poll(() => authorizationRequests).toBe(1);
|
||||
await expect(page).toHaveURL("https://slack.test/manager-consent");
|
||||
});
|
||||
test("Slack: every uncertain creation retry needs a fresh confirmation", async ({ page }) => {
|
||||
const slack = PROVIDERS.find(provider => provider.provider === "slack")!;
|
||||
const mock = await installChatControlPlaneMock(page, slack, seed, { enableChatConnectors: true, managedSlack: true });
|
||||
mock.setSlackUncertain();
|
||||
const attempts: { requestId: string; confirmedNoAppCreated?: boolean }[] = [];
|
||||
await page.route("**/slack/managed/provision", async route => {
|
||||
attempts.push(route.request().postDataJSON());
|
||||
await route.fulfill({ json: {} });
|
||||
});
|
||||
await page.goto(`/${seed.prefix}/apps/chat/connect?provider=slack&purpose=chat&resume=endpoint-slack`);
|
||||
const confirm = page.getByRole("checkbox", { name: "I checked Slack and no app was created. Create a new app." });
|
||||
const create = page.getByRole("button", { name: "Add to Slack", exact: true });
|
||||
await expect(create).toBeDisabled();
|
||||
await confirm.check(); await create.click();
|
||||
await expect(confirm).not.toBeChecked(); await expect(create).toBeDisabled();
|
||||
expect(attempts).toHaveLength(1); expect(attempts[0]!.confirmedNoAppCreated).toBe(true);
|
||||
await confirm.check(); await create.click();
|
||||
await expect(confirm).not.toBeChecked(); await expect(create).toBeDisabled();
|
||||
expect(attempts).toHaveLength(2); expect(attempts[1]!.requestId).not.toBe(attempts[0]!.requestId);
|
||||
});
|
||||
test("Slack: own-app creation consumes confirmation even when the response is lost", async ({ page }) => {
|
||||
const slack = PROVIDERS.find(provider => provider.provider === "slack")!;
|
||||
const mock = await installChatControlPlaneMock(page, slack, seed, { enableChatConnectors: true, automaticSlack: true });
|
||||
mock.setSlackUncertain();
|
||||
let attempts = 0;
|
||||
await page.route("**/slack/registration", async route => {
|
||||
attempts++; expect(route.request().postDataJSON().confirmedNoAppCreated).toBe(true);
|
||||
await route.fulfill({ status: 502, json: { error: "Creation response unavailable" } });
|
||||
});
|
||||
await page.goto(`/${seed.prefix}/apps/chat/connect?provider=slack&purpose=chat&resume=endpoint-slack`);
|
||||
const confirm = page.getByRole("checkbox");
|
||||
await confirm.check();
|
||||
await page.getByLabel("App configuration access token", { exact: true }).fill("fixture-config-token");
|
||||
await page.getByRole("button", { name: "Create Slack app", exact: true }).click();
|
||||
await expect(page.getByRole("alert")).toBeVisible();
|
||||
await expect(confirm).not.toBeChecked();
|
||||
await expect(page.getByRole("button", { name: "Create Slack app", exact: true })).toBeDisabled();
|
||||
expect(attempts).toBe(1);
|
||||
});
|
||||
test("Slack: temporarily unavailable managed setup can retry in place", async ({ page }) => {
|
||||
const slack = PROVIDERS.find(provider => provider.provider === "slack")!;
|
||||
await installChatControlPlaneMock(page, slack, seed, { enableChatConnectors: true, managedSlack: true });
|
||||
let available = false;
|
||||
await page.route("**/chat-slack/setup-options", async route => {
|
||||
if (available) return route.fallback();
|
||||
await route.fulfill({ json: { managedAvailable: false, defaultMethod: "automatic", workspaces: [] } });
|
||||
});
|
||||
await page.goto(`/${seed.prefix}/apps/chat/connect?provider=slack&purpose=chat&resume=endpoint-slack`);
|
||||
await expect(page.getByText("Managed Slack setup is unavailable. Try again later.")).toBeVisible();
|
||||
available = true; await page.getByRole("button", { name: "Retry", exact: true }).click();
|
||||
await expect(page.getByRole("button", { name: "Add to Slack", exact: true })).toBeEnabled();
|
||||
await expect(page.getByRole("heading", { name: "Add to Slack", exact: true })).toBeVisible();
|
||||
});
|
||||
test("Slack: own-app selection persists before provisioning", async ({ page }) => {
|
||||
const slack = PROVIDERS.find(provider => provider.provider === "slack")!;
|
||||
await installChatControlPlaneMock(page, slack, seed, { enableChatConnectors: true, managedSlack: true });
|
||||
|
||||
Reference in new issue
Block a user