Skip to content

Commit 51bf90a

Browse files
committed
fix(knowledge): align secret reference styling and caret tracking
1 parent c4ac87f commit 51bf90a

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

‎apps/sim/app/o/[organizationId]/settings/components/integrations/search-source-setup.test.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ async function chooseSyncFrequency(label: string) {
269269
async function fill(placeholder: string, value: string) {
270270
const input = document.querySelector<HTMLInputElement>(`input[placeholder="${placeholder}"]`)
271271
expect(input, `Input ${placeholder}`).not.toBeNull()
272+
await act(async () => input?.focus())
272273
await act(async () => {
273274
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, value)
274275
input?.dispatchEvent(new Event('input', { bubbles: true }))
@@ -897,16 +898,16 @@ describe('member content credentials in real add and edit dialogs', () => {
897898
)
898899
await click(card!)
899900
expect(document.body.textContent).not.toContain('Connected members')
900-
expect(button('Administrator token')).toHaveAttribute('aria-checked', 'true')
901-
expect(document.body.textContent).not.toContain('Connection method')
901+
expect(document.body.textContent).not.toContain('Administrator token')
902+
expect(document.body.textContent).toContain('Everyone in this workspace')
902903
await fill('Enter your GitLab PAT', 'new-pat')
903904
await fill('gitlab.example.com', 'gitlab.example.test')
904905
await fill('group/project or numeric ID', '1')
905906
expect(button('Connect & Sync')).toBeEnabled()
906907
await click(button('Connect & Sync'))
907908
expect(mocks.create.mock.calls[1][0]).toMatchObject({
908909
connectorType: 'gitlab',
909-
accessMode: 'admin',
910+
accessMode: 'workspace',
910911
apiKey: 'new-pat',
911912
})
912913
expect(mocks.create.mock.calls[1][0].sourceConfig).not.toHaveProperty('excludeChannels')

‎apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/add-connector-modal/add-connector-modal.test.tsx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,10 +905,24 @@ describe('Search setup options', () => {
905905
input.dispatchEvent(new Event('input', { bubbles: true }))
906906
})
907907
expect(document.body.textContent).toContain('GITLAB_PAT')
908+
expect(input.className).toContain('text-[var(--brand-secondary)]')
909+
await act(async () => {
910+
input.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }))
911+
input.setSelectionRange(0, 0)
912+
input.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }))
913+
})
914+
expect(document.querySelector('[role="menuitem"]')).toBeNull()
915+
expect(input.value).toBe('{{GIT')
916+
await act(async () => {
917+
input.setSelectionRange(input.value.length, input.value.length)
918+
input.dispatchEvent(new KeyboardEvent('keyup', { key: 'End', bubbles: true }))
919+
})
920+
expect(document.body.textContent).toContain('GITLAB_PAT')
908921
await act(async () =>
909922
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }))
910923
)
911924
expect(input.value).toBe('{{GITLAB_PAT}}')
925+
expect(input.className).toContain('text-[var(--brand-secondary)]')
912926
expect(mocks.create).not.toHaveBeenCalled()
913927
await act(async () => button('Connect & Sync').click())
914928
expect(mocks.create).toHaveBeenCalledWith(

‎apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/add-connector-modal/connector-api-key-input.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export function ConnectorApiKeyInput({
3636
setCursorPosition(inputRef.current?.selectionStart ?? next.length)
3737
setShowSecrets(true)
3838
}}
39+
onSelect={(event) => {
40+
setCursorPosition(event.currentTarget.selectionStart ?? value.length)
41+
}}
42+
inputClassName={
43+
value.trimStart().startsWith('{{') ? 'text-[var(--brand-secondary)]' : undefined
44+
}
3945
placeholder={placeholder}
4046
/>
4147
{visible && (

0 commit comments

Comments
 (0)