Skip to content

Commit

Permalink
Merge pull request #172 from actiontech/test/DMS-805
Browse files Browse the repository at this point in the history
[test](sqle/RuleKnowledge): add unit test
  • Loading branch information
LZS911 authored Jan 12, 2024
2 parents 0ffdf8a + 3fb11de commit c98831e
Show file tree
Hide file tree
Showing 27 changed files with 1,320 additions and 67 deletions.
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ module.exports = {
'monaco-editor': '<rootDir>/packages/shared/lib/testUtil/mockEditor.jsx',
'@monaco-editor/react':
'<rootDir>/packages/shared/lib/testUtil/mockEditor.jsx',
'@uiw/react-md-editor':
'<rootDir>/packages/shared/lib/testUtil/mockEditor.jsx',
'@actiontech/(.*)': '<rootDir>/packages/$1',
...pathsToModuleNameMapper(compilerOptions.paths)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`page/DataSource/AddDataSource render add database snap 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -961,7 +961,7 @@ exports[`page/DataSource/AddDataSource render submit when add database api succe
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -2212,7 +2212,7 @@ exports[`page/DataSource/AddDataSource render submit when add database api succe
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -2720,7 +2720,7 @@ exports[`page/DataSource/AddDataSource render submit when add database api succe
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -3228,7 +3228,7 @@ exports[`page/DataSource/AddDataSource render submit when add database api succe
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`page/DataSource/DataSourceList render list no permission 1`] = `
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -408,7 +408,7 @@ exports[`page/DataSource/DataSourceList render list snap 1`] = `
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -812,7 +812,7 @@ exports[`page/DataSource/DataSourceList render table filter option val 1`] = `
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -1675,7 +1675,7 @@ exports[`page/DataSource/DataSourceList render table for action btn render table
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -2380,7 +2380,7 @@ exports[`page/DataSource/DataSourceList render table for action btn render table
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -3085,7 +3085,7 @@ exports[`page/DataSource/DataSourceList render table for api has data 1`] = `
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -3827,7 +3827,7 @@ exports[`page/DataSource/DataSourceList render table for api has data 2`] = `
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -4594,7 +4594,7 @@ exports[`page/DataSource/DataSourceList render table for api return no data 1`]
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -4973,7 +4973,7 @@ exports[`page/DataSource/DataSourceList render table for api return no data 2`]
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -5352,7 +5352,7 @@ exports[`page/DataSource/DataSourceList render table for column val 1`] = `
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`page/DataSource/UpdateDataSource render edit data when has all value 1`
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -1112,7 +1112,7 @@ exports[`page/DataSource/UpdateDataSource render edit data when has all value 2`
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -2241,7 +2241,7 @@ exports[`page/DataSource/UpdateDataSource render edit database snap 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -3235,7 +3235,7 @@ exports[`page/DataSource/UpdateDataSource render get default val error 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -3381,7 +3381,7 @@ exports[`page/DataSource/UpdateDataSource render get default val error 2`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -3550,7 +3550,7 @@ exports[`page/DataSource/UpdateDataSource render prepare api 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`page/SyncDataSource/AddPage render add submit for success 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -495,7 +495,7 @@ exports[`page/SyncDataSource/AddPage render add sync task snap 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -1942,7 +1942,7 @@ exports[`page/SyncDataSource/AddPage render form item for prepare api 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`page/SyncDataSource/SyncTaskList render list action when no permission
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -448,7 +448,7 @@ exports[`page/SyncDataSource/SyncTaskList render list column data for table 1`]
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -934,7 +934,7 @@ exports[`page/SyncDataSource/SyncTaskList render list snap 1`] = `
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -1239,7 +1239,7 @@ exports[`page/SyncDataSource/SyncTaskList render list snap 2`] = `
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -1737,7 +1737,7 @@ exports[`page/SyncDataSource/SyncTaskList render list snap when no projectID 1`]
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -2018,7 +2018,7 @@ exports[`page/SyncDataSource/SyncTaskList render list snap when no projectID 2`]
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`page/SyncDataSource/UpdateSyncTask render click reset btn 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -1478,7 +1478,7 @@ exports[`page/SyncDataSource/UpdateSyncTask render click reset btn 2`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -2954,7 +2954,7 @@ exports[`page/SyncDataSource/UpdateSyncTask render edit database snap 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -4425,7 +4425,7 @@ exports[`page/SyncDataSource/UpdateSyncTask render taskId is null 1`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -4595,7 +4595,7 @@ exports[`page/SyncDataSource/UpdateSyncTask render taskId is null 2`] = `
class="css-doq0dk"
>
<div
class="actiontech-page-header-namespace fixed-style css-14fwawz"
class="actiontech-page-header-namespace fixed-style css-1xspr0w"
>
<div
class="title"
Expand Down
25 changes: 23 additions & 2 deletions packages/shared/lib/testUtil/mockEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import { cloneDeep, isObject } from 'lodash';

const mockEditor = (props) => {
const { onMount, ...otherProps } = props;
return <input {...otherProps} />;
const { onMount, onChange, value, ...otherProps } = props;

const cloneProps = cloneDeep(otherProps);

Object.keys(cloneProps).forEach((key) => {
if (isObject(cloneProps[key])) {
cloneProps[key] = JSON.stringify(cloneProps[key]);
}
});
return (
<input
onChange={(e) => onChange(e.target.value)}
value={value ?? ''}
{...cloneProps}
/>
);
};

mockEditor.Markdown = (props) => {
const { source, ...otherProps } = props;
return <div {...otherProps}>{source}</div>;
};

export const loader = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`sqle/OperationRecord/List render action when filter item show 1`] = `
<div>
<article>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -798,7 +798,7 @@ exports[`sqle/OperationRecord/List render operation record table when request re
<div>
<article>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down Expand Up @@ -1401,7 +1401,7 @@ exports[`sqle/OperationRecord/List render table when request return error 1`] =
<div>
<article>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`slqe/OperationRecord CE should match snap shot 1`] = `
<body>
<div>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`slqe/OperationRecord should render operation record list 1`] = `
<div>
<article>
<div
class="actiontech-page-header-namespace css-14fwawz"
class="actiontech-page-header-namespace css-1xspr0w"
>
<div
class="title"
Expand Down
Loading

0 comments on commit c98831e

Please sign in to comment.