From 7ec381d351b44a292b88281f7252ef225f1cc218 Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 1 Dec 2024 16:17:23 +0000 Subject: [PATCH] Fix issue #5343: [Bug]: Frontend changes cause Python unit tests workflow to fail but not frontend workflow --- .github/workflows/frontend-lint.yml | 33 ++++++++++++++++++++++++++ .github/workflows/frontend-test.yml | 33 ++++++++++++++++++++++++++ frontend/src/components/chat-input.tsx | 7 +++--- 3 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/frontend-lint.yml create mode 100644 .github/workflows/frontend-test.yml diff --git a/.github/workflows/frontend-lint.yml b/.github/workflows/frontend-lint.yml new file mode 100644 index 000000000000..2406d77391d7 --- /dev/null +++ b/.github/workflows/frontend-lint.yml @@ -0,0 +1,33 @@ +name: Lint Frontend + +on: + pull_request: + paths: + - 'frontend/**' + - '.github/workflows/frontend-lint.yml' + push: + branches: + - main + paths: + - 'frontend/**' + - '.github/workflows/frontend-lint.yml' + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + + - name: Install dependencies + run: cd frontend && npm ci + + - name: Run TypeScript type checking + run: cd frontend && npx tsc --noEmit + + - name: Run ESLint and Prettier + run: cd frontend && npm run lint diff --git a/.github/workflows/frontend-test.yml b/.github/workflows/frontend-test.yml new file mode 100644 index 000000000000..425d7e4299ed --- /dev/null +++ b/.github/workflows/frontend-test.yml @@ -0,0 +1,33 @@ +name: Frontend Tests + +on: + pull_request: + paths: + - 'frontend/**' + - '.github/workflows/frontend-test.yml' + push: + branches: + - main + paths: + - 'frontend/**' + - '.github/workflows/frontend-test.yml' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + cache-dependency-path: frontend/package-lock.json + + - name: Install dependencies + run: cd frontend && npm ci + + - name: Run TypeScript type checking + run: cd frontend && npx tsc --noEmit + + - name: Run tests + run: cd frontend && npm run test diff --git a/frontend/src/components/chat-input.tsx b/frontend/src/components/chat-input.tsx index 96c27fc84d65..a6474d206578 100644 --- a/frontend/src/components/chat-input.tsx +++ b/frontend/src/components/chat-input.tsx @@ -82,9 +82,10 @@ export function ChatInput({ }; const handleSubmitMessage = () => { - if (textareaRef.current?.value) { - onSubmit(textareaRef.current.value); - textareaRef.current.value = ""; + const textarea = textareaRef.current; + if (textarea?.value) { + onSubmit(textarea.value); + textarea.value = ""; } };