From 24cab83f482c2cdd7dc04b76bb7683ce5ee74498 Mon Sep 17 00:00:00 2001 From: Hare Date: Sun, 13 Sep 2026 00:05:14 +0900 Subject: [PATCH] test: cover repository credential rotate visibility --- .../test/repository-access/ui.test.ts | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/web/workspace/test/repository-access/ui.test.ts b/web/workspace/test/repository-access/ui.test.ts index ea0cbe9e..845f396a 100644 --- a/web/workspace/test/repository-access/ui.test.ts +++ b/web/workspace/test/repository-access/ui.test.ts @@ -90,6 +90,46 @@ test("Repository Access generates and copies selectable public keys", () => { ); }); +test("Repository Access hides Rotate for the Workspace default credential", () => { + const credentialsStart = source.indexOf("

SSH credentials

"); + const generateStart = source.indexOf( + "

Generate Repository SSH credential

", + ); + assert( + credentialsStart >= 0 && generateStart > credentialsStart, + "credential list should appear before the generation form", + ); + + const credentialList = source.slice(credentialsStart, generateStart); + const additionalCredentialGuard = credentialList.indexOf( + "{#if credential.credential_id !== workspaceDefaultCredentialId}", + ); + const rotateAction = credentialList.indexOf( + "rotateCredentialId = rotateCredentialId === credential.credential_id", + additionalCredentialGuard, + ); + const deleteAction = credentialList.indexOf( + "onclick={() => void deleteCredential(credential)}", + rotateAction, + ); + const guardEnd = credentialList.indexOf("{/if}", deleteAction); + + assert( + additionalCredentialGuard >= 0 && + rotateAction > additionalCredentialGuard && + deleteAction > rotateAction && + guardEnd > deleteAction, + "Rotate and Delete should render only for additional credentials", + ); + assert( + credentialList.indexOf( + "{#if rotateCredentialId === credential.credential_id}", + guardEnd, + ) > guardEnd, + "the existing rotation form should remain available after selecting an additional credential", + ); +}); + test("Repository credential submissions clear write-only fields in finally blocks", () => { const createStart = source.indexOf("async function createCredential()"); const rotateStart = source.indexOf("async function rotateCredential(");