Skip to content

Commit

Permalink
[fix]: limit the max input length of the order desc to 50
Browse files Browse the repository at this point in the history
  • Loading branch information
LZS911 committed May 24, 2022
1 parent efc0379 commit 90ca7b2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
34 changes: 22 additions & 12 deletions src/page/Order/Create/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ exports[`Order/Create should audit sql when user click audit button 1`] = `
<div
class="ant-form-item-control-input-content"
>
<textarea
class="ant-input"
id="describe"
placeholder="common.form.placeholder.input"
style="height: -40px; min-height: -12px; max-height: -40px; resize: none;"
/>
<div
class="ant-input-textarea ant-input-textarea-show-count"
data-count="0 / 50"
>
<textarea
class="ant-input"
id="describe"
placeholder="common.form.placeholder.input"
style="height: -40px; min-height: -12px; max-height: -40px; resize: none;"
/>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -2316,12 +2321,17 @@ exports[`Order/Create should render page header 1`] = `
<div
class="ant-form-item-control-input-content"
>
<textarea
class="ant-input"
id="describe"
placeholder="common.form.placeholder.input"
style="height: -40px; min-height: -12px; max-height: -40px; overflow-y: hidden; resize: none; overflow-x: hidden;"
/>
<div
class="ant-input-textarea ant-input-textarea-show-count"
data-count="0 / 50"
>
<textarea
class="ant-input"
id="describe"
placeholder="common.form.placeholder.input"
style="height: -40px; min-height: -12px; max-height: -40px; overflow-y: hidden; resize: none; overflow-x: hidden;"
/>
</div>
</div>
</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions src/page/Order/Create/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
taskSqls,
} from '../Detail/__testData__';

const orderDescMaxLength = 50;

describe('Order/Create', () => {
beforeEach(() => {
jest.useFakeTimers();
Expand Down Expand Up @@ -140,7 +142,11 @@ describe('Order/Create', () => {
target: { value: 'orderName' },
});
fireEvent.input(screen.getByLabelText('order.baseInfo.describe'), {
target: { value: 'order describe' },
target: {
value: Array.from({ length: orderDescMaxLength + 1 }, () => 'e').join(
''
),
},
});

fireEvent.mouseDown(screen.getByLabelText('order.sqlInfo.instanceName'));
Expand Down Expand Up @@ -197,7 +203,7 @@ describe('Order/Create', () => {
'ant-btn-loading'
);
expect(createOrderSpy).toBeCalledWith({
desc: 'order describe',
desc: Array.from({ length: orderDescMaxLength }, () => 'e').join(''),
task_id: String(taskInfo.task_id),
workflow_subject: 'orderName',
});
Expand Down
2 changes: 2 additions & 0 deletions src/page/Order/Create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ const CreateOrder = () => {
placeholder={t('common.form.placeholder.input', {
name: t('order.baseInfo.describe'),
})}
maxLength={50}
showCount
/>
</Form.Item>
</Form>
Expand Down

0 comments on commit 90ca7b2

Please sign in to comment.