chore(ci): change fe test based on node 20 (#5657)

* chore(ci): change fe test based on node 20

* chore(ci): change setup-node to v4

* fix(client): fix test case

* fix(client): fix test case
This commit is contained in:
Junyi 2024-11-15 18:12:36 +08:00 committed by GitHub
parent 97358707f9
commit 60225a11c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 12 deletions

View File

@ -33,14 +33,14 @@ jobs:
frontend-test:
strategy:
matrix:
node_version: ['18']
node_version: ['20']
runs-on: ubuntu-latest
container: node:${{ matrix.node_version }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: 'yarn'

View File

@ -12,6 +12,7 @@ import React from 'react';
import App1 from '../demos/input';
import App2 from '../demos/textarea';
import App3 from '../demos/url';
import App4 from '../demos/json';
import JSON5 from 'json5';
import JSONInput from '../demos/new-demos/json';
import JSON5Input from '../demos/new-demos/json5';
@ -131,18 +132,13 @@ describe('Input.JSON', () => {
});
it('should display the error when the value is invalid', async () => {
const { container } = render(<JSONInput />);
const { container } = render(<App4 />);
await waitFor(() => {
expect(screen.getByText('Test').innerHTML).toBe('Test');
const textarea = container.querySelector('textarea') as HTMLTextAreaElement;
fireEvent.change(textarea, { target: { value: '{"name":nocobase}' } });
fireEvent.blur(textarea, { target: { value: '{"name":nocobase}' } });
expect(screen.getByText(/Unexpected token/)).toBeInTheDocument();
});
const textarea = container.querySelector('textarea') as HTMLTextAreaElement;
await userEvent.clear(textarea);
// To escape special characters, use double curly braces
await userEvent.type(textarea, '{{name:"nocobase"}');
// mock blur event
await userEvent.click(document.body);
expect(screen.getByText(/Unexpected token n/)).toBeInTheDocument();
});
it('should not display error when the value is valid JSON5', async () => {