Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(control-ui): r2-l7 cover confirm dialog backdrop dismissal
Josué53f5a9672c17
diff --git a/control-ui/components/__tests__/ConfirmDialog.test.tsx b/control-ui/components/__tests__/ConfirmDialog.test.tsxindex 6add469e5..f0cfbac40 100644--- a/control-ui/components/__tests__/ConfirmDialog.test.tsx+++ b/control-ui/components/__tests__/ConfirmDialog.test.tsx@@ -1,6 +1,6 @@-import { useEffect } from 'react'+import { useEffect, useState } from 'react'import { afterEach, describe, expect, it } from 'vitest'-import { cleanup, render, screen } from '@testing-library/react'+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import { useConfirmDialog } from '../ConfirmDialog'import type { ConfirmDialogOptions } from '../ConfirmDialog/types'@@ -17,6 +17,22 @@ function ConfirmHarness({ options }: { options: ConfirmDialogOptions }) {return confirmDialog}+function DismissHarness() {+ const { confirm, confirmDialog } = useConfirmDialog()+ const [outcome, setOutcome] = useState('pending')+ useEffect(() => {+ void confirm({ message: 'Discard this change?', title: 'Discard changes' }).then(result => {+ setOutcome(result ? 'confirmed' : 'dismissed')+ })+ }, [confirm])+ return (+ <>+ <output>{outcome}</output>+ {confirmDialog}+ </>+ )+}+describe('ConfirmDialog accessibility', () => {it('names the details block in the alertdialog accessible description', () => {render(@@ -46,4 +62,12 @@ describe('ConfirmDialog accessibility', () => {const dialog = screen.getByRole('alertdialog')expect(dialog).toHaveAccessibleDescription('Proceed with the change?')})++ it('treats a backdrop click as dismissal instead of confirmation', async () => {+ render(<DismissHarness />)++ fireEvent.mouseDown(document.querySelector('.cu-modal-backdrop') as HTMLElement)++ await waitFor(() => expect(screen.getByText('dismissed')).toBeInTheDocument())+ })})diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex f2c287571..1343b818c 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.597",+ "version": "0.1.598","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.597",+ "version": "0.1.598","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.jsonindex 3d086ca2e..1b3fe65d9 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.597",+ "version": "0.1.598","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",