Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
test: add new test case
adilson1f861480fbeb
diff --git a/backend/e2e-test/routes/v1/user-activation.spec.ts b/backend/e2e-test/routes/v1/user-activation.spec.tsindex c1fa9698bb..462ca07d55 100644--- a/backend/e2e-test/routes/v1/user-activation.spec.ts+++ b/backend/e2e-test/routes/v1/user-activation.spec.ts@@ -102,21 +102,24 @@ describe("User Activation Router", () => {if (createdUserIds.length) await db(TableName.Users).whereIn("id", createdUserIds).del();});- test("old org (62 days) → no activation and no row created", async () => {+ test("old org (90 days) with few users → activation shown and row created", async () => {const db = getDb();- const org = await createOrgWithAdmin(db, daysAgo(62));+ const org = await createOrgWithAdmin(db, daysAgo(90));const res = await callActivation(org.id);expect(res.statusCode).toBe(200);- expect(res.json().shouldShowActivation).toBe(false);+ const body = res.json();+ expect(body.shouldShowActivation).toBe(true);+ expect(body.stage).toBe("FIRST_SECRET");const row = await getActivationRow(db, org.id);- expect(row).toBeUndefined();+ expect(row).toBeDefined();+ expect(row?.firstSecretCreatedAt).not.toBeNull();});- test("new org (60 days) with more than 5 users → no activation and no row created", async () => {+ test("old org (90 days) with more than 5 users → no activation and no row created", async () => {const db = getDb();- const org = await createOrgWithAdmin(db, daysAgo(60));+ const org = await createOrgWithAdmin(db, daysAgo(90));// admin member + 5 more = 6 users (> 5)for (let i = 0; i < 5; i += 1) {// eslint-disable-next-line no-await-in-loop@@ -131,6 +134,25 @@ describe("User Activation Router", () => {expect(row).toBeUndefined();});+ test("young org with more than 5 users → activation shown", async () => {+ const db = getDb();+ const org = await createOrgWithAdmin(db, daysAgo(1));+ // admin member + 5 more = 6 users (> 5), but the org is still young+ for (let i = 0; i < 5; i += 1) {+ // eslint-disable-next-line no-await-in-loop+ await addAcceptedMember(db, org.id);+ }++ const res = await callActivation(org.id);+ expect(res.statusCode).toBe(200);+ const body = res.json();+ expect(body.shouldShowActivation).toBe(true);+ expect(body.stage).toBe("FIRST_SECRET");++ const row = await getActivationRow(db, org.id);+ expect(row).toBeDefined();+ });+test("new org, < 5 users, first interaction → firstSecretCreatedAt is set", async () => {const db = getDb();const org = await createOrgWithAdmin(db, daysAgo(1));diff --git a/frontend/src/hooks/useSecretsActivationNudge.tsx b/frontend/src/hooks/useSecretsActivationNudge.tsxindex b0a0ee8d85..b93852cb13 100644--- a/frontend/src/hooks/useSecretsActivationNudge.tsx+++ b/frontend/src/hooks/useSecretsActivationNudge.tsx@@ -42,31 +42,34 @@ export const useSecretsActivationNudge = () => {OrgPermissionSubjects.Member);- const checkActivation = useCallback(async () => {- if (!isRootOrganization || !canInviteMembers || !currentOrg?.id) return;+ const checkActivation = useCallback(+ async (customDelayMs?: number) => {+ if (!isRootOrganization || !canInviteMembers || !currentOrg?.id) return;- const queryKey = userActivationKeys.secretsStatus(currentOrg.id, user.id);- // Already checked this session (cached): don't call again and don't re-open the modal.- if (queryClient.getQueryData(queryKey) !== undefined) return;+ const queryKey = userActivationKeys.secretsStatus(currentOrg.id, user.id);+ // Already checked this session (cached): don't call again and don't re-open the modal.+ if (queryClient.getQueryData(queryKey) !== undefined) return;- try {- const data = await queryClient.ensureQueryData({- queryKey,- queryFn: fetchSecretsActivationStatus,- retry: false,- gcTime: Infinity- });- if (data.shouldShowActivation) {- // Give the page a beat before nudging so it doesn't feel abrupt.- if (openTimeoutRef.current) clearTimeout(openTimeoutRef.current);- openTimeoutRef.current = setTimeout(() => {- handlePopUpOpen("inviteMembers");- }, ACTIVATION_NUDGE_DELAY_MS);+ try {+ const data = await queryClient.ensureQueryData({+ queryKey,+ queryFn: fetchSecretsActivationStatus,+ retry: false,+ gcTime: Infinity+ });+ if (data.shouldShowActivation) {+ // Give the page a beat before nudging so it doesn't feel abrupt.+ if (openTimeoutRef.current) clearTimeout(openTimeoutRef.current);+ openTimeoutRef.current = setTimeout(() => {+ handlePopUpOpen("inviteMembers");+ }, customDelayMs ?? ACTIVATION_NUDGE_DELAY_MS);+ }+ } catch {+ // Silent by design: a failed activation check must not disrupt the page.}- } catch {- // Silent by design: a failed activation check must not disrupt the page.- }- }, [isRootOrganization, canInviteMembers, currentOrg?.id, user.id, queryClient, handlePopUpOpen]);+ },+ [isRootOrganization, canInviteMembers, currentOrg?.id, user.id, queryClient, handlePopUpOpen]+ );return { popUp, handlePopUpToggle, checkActivation };};diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsxindex d1bba08a61..ce21b0f453 100644--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx@@ -94,6 +94,7 @@ import {TooltipTrigger} from "@app/components/v3";import { apiRequest } from "@app/config/request";+import { EXAMPLE_PROJECT_NAME } from "@app/const";import { ROUTE_PATHS } from "@app/const/routes";import {ProjectPermissionActions,@@ -702,6 +703,13 @@ const OverviewPageContent = () => {checkActivation: checkSecretsActivation} = useSecretsActivationNudge();+ const hasSecrets = !isPlaceholderData && Boolean(totalSecretCount);+ useEffect(() => {+ if (hasSecrets) {+ checkSecretsActivation(4000);+ }+ }, [hasSecrets, checkSecretsActivation]);+const secretImportsShaped = secretImports?.flatMap(({ data }) => data).filter(Boolean)