Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(control-ui): cover the post-install copy and reset the clipboard mock

Jose Gabriel Ramirez Encinas6c6b8bfef619
diff --git a/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx b/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx
index 53d825ce2..0edb96a00 100644
--- a/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx
+++ b/control-ui/components/__tests__/AddRemoteServerWizard.test.tsx
@@ -72,6 +72,10 @@ afterEach(() => {
getContextsMock.mockResolvedValue({
items: [buildContextResource({ metadata: { name: 'research', resourceVersion: 'rv1' } })],
})
+ // mockClear keeps queued *Once values; reset so an unused one cannot leak into the
+ // next test, then restore the default successful copy.
+ copyMock.mockReset()
+ copyMock.mockResolvedValue(true)
})
function renderWizard(props?: Partial<Parameters<typeof AddRemoteServerWizard>[0]>) {
@@ -372,8 +376,6 @@ describe('AddRemoteServerWizard', () => {
})
it('pre-registered per-server: Copy hands the shown URI to the clipboard and confirms', async () => {
- copyMock.mockClear()
- copyMock.mockResolvedValueOnce(true)
await detectPreRegisteredPerServer('hubspot')
fireEvent.click(screen.getByRole('button', { name: 'Copy redirect URI' }))
@@ -407,6 +409,11 @@ describe('AddRemoteServerWizard', () => {
const uri = await screen.findByRole('textbox', { name: 'Redirect URI' })
expect(uri).toHaveValue(PRE_REGISTERED_PER_SERVER_INSTALLED.redirectUri)
expect(screen.queryByText(/differs from the one shown before/i)).not.toBeInTheDocument()
+ // The URI the operator copies after install is the one control-api reported.
+ fireEvent.click(screen.getByRole('button', { name: 'Copy redirect URI' }))
+ await waitFor(() =>
+ expect(copyMock).toHaveBeenCalledWith(PRE_REGISTERED_PER_SERVER_INSTALLED.redirectUri)
+ )
expect(onInstalled).not.toHaveBeenCalled()
expect(screen.queryByRole('button', { name: 'Back' })).not.toBeInTheDocument()
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 4967d720d..1d7a14a73 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.706",
+ "version": "0.1.707",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.706",
+ "version": "0.1.707",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index 4ec977951..2d3351c4e 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.706",
+ "version": "0.1.707",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",