diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ae49706..d3d4062d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,6 @@ name: CI permissions: contents: read -permissions: - contents: read - on: push: branches: [main] diff --git a/package-lock.json b/package-lock.json index 0f82ae04..5956b2ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2460,13 +2460,6 @@ "dev": true, "license": "MIT" }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, "node_modules/baseline-browser-mapping": { "version": "2.9.14", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.14.tgz", diff --git a/src/components/CookieConsent.tsx b/src/components/CookieConsent.tsx index 4ea3344e..d9a93afd 100644 --- a/src/components/CookieConsent.tsx +++ b/src/components/CookieConsent.tsx @@ -2,6 +2,12 @@ import { useState } from 'react'; import { AnimatePresence, motion } from 'framer-motion'; import { Button } from './ui/Button'; +/** + * Reads the stored cookie consent preference from localStorage. + * Returns true (show consent) when no preference has been saved yet. + * + * @returns True if the consent banner should be displayed, false otherwise + */ function getInitialConsentState(): boolean { try { const hasConsented = localStorage.getItem('docugen-cookie-consent'); diff --git a/src/components/ShareButtons.tsx b/src/components/ShareButtons.tsx index 06532573..e56c43c7 100644 --- a/src/components/ShareButtons.tsx +++ b/src/components/ShareButtons.tsx @@ -66,6 +66,10 @@ export function ShareButtons({ }, ]; + /** + * Copies the share URL to the clipboard. + * Silently logs an error if the Clipboard API is unavailable. + */ const handleCopyLink = async () => { try { await navigator.clipboard.writeText(url); diff --git a/src/components/UploadDemo.test.tsx b/src/components/UploadDemo.test.tsx index 956d0053..43f0c042 100644 --- a/src/components/UploadDemo.test.tsx +++ b/src/components/UploadDemo.test.tsx @@ -2,6 +2,14 @@ import { render, screen, fireEvent } from '@testing-library/react'; import { describe, it, expect } from 'vitest'; import { UploadDemo } from './UploadDemo'; +function createFileList(file: File) { + return { + 0: file, + length: 1, + item: (index: number) => (index === 0 ? file : null), + }; +} + describe('UploadDemo', () => { it('renders drag and drop zone initially', () => { render(); @@ -23,7 +31,7 @@ describe('UploadDemo', () => { fireEvent.drop(dropzone as Element, { dataTransfer: { - files: [file], + files: createFileList(file), }, }); }); @@ -35,7 +43,7 @@ describe('UploadDemo', () => { fireEvent.drop(dropzone as Element, { dataTransfer: { - files: [file], + files: createFileList(file), }, }); diff --git a/src/components/UploadDemo.tsx b/src/components/UploadDemo.tsx index 9c7bc5fc..bf31cf12 100644 --- a/src/components/UploadDemo.tsx +++ b/src/components/UploadDemo.tsx @@ -64,7 +64,7 @@ export function UploadDemo() { (e: React.DragEvent) => { e.preventDefault(); setIsDragging(false); - const droppedFile = e.dataTransfer.files[0]; + const droppedFile = e.dataTransfer.files.item(0); if (droppedFile && (droppedFile.name.endsWith('.md') || droppedFile.name.endsWith('.mdx'))) { setFile(droppedFile); simulateUpload();