Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore]: modify table row key and remove redundant components #393

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1077,8 +1077,7 @@ exports[`test ScanTypeSqlCollection should match snapshot 2`] = `
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="/* ApplicationName=DBeaver 24.1.2 - SQLEditor <Console> */ select 1,SLEEP(11)
LIMIT 0, 200"
data-row-key="1"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -1266,8 +1265,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="/* ApplicationName=DBeaver 24.1.2 - SQLEditor <Console> */ select 1,1,1,1,1,SLEEP(11)
LIMIT 0, 200"
data-row-key="12"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -1479,8 +1477,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="/* ApplicationName=DBeaver 24.1.2 - SQLEditor <Console> */ SELECT SLEEP(11)
LIMIT 0, 200"
data-row-key="123"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -1662,7 +1659,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="Prepare"
data-row-key="1234"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -1823,7 +1820,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="COMMIT"
data-row-key="12345"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -1979,7 +1976,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="INSERT INTO \`audit_plan_sqls_v2\` (\`audit_plan_id\`,\`fingerprint_md5\`, \`fingerprint\`, \`sql_content\`, \`info\`, \`schema\`) VALUES (3, 'a62860c563df5399c2acb800673ae715', 'CREATE TABLE \`audit_files\` (\\n \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT,\\n \`created_at\` datetime DEFAULT CURRENT_TIMESTAMP,\\n \`updated_at\` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\\n \`deleted_at\` datetime DEFAULT NULL,\\n \`task_id\` int(10) unsigned DEFAULT NULL,\\n \`unique_name\` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,\\n \`file_host\` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,\\n \`file_name\` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,\\n PRIMARY KEY (\`id\`)"
data-row-key="123456"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -3230,8 +3227,7 @@ exports[`test ScanTypeSqlCollection should open report drawer and set current au
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="/* ApplicationName=DBeaver 24.1.2 - SQLEditor <Console> */ select 1,SLEEP(11)
LIMIT 0, 200"
data-row-key="1"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -3419,8 +3415,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="/* ApplicationName=DBeaver 24.1.2 - SQLEditor <Console> */ select 1,1,1,1,1,SLEEP(11)
LIMIT 0, 200"
data-row-key="12"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -3632,8 +3627,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="/* ApplicationName=DBeaver 24.1.2 - SQLEditor <Console> */ SELECT SLEEP(11)
LIMIT 0, 200"
data-row-key="123"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -3815,7 +3809,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="Prepare"
data-row-key="1234"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -3976,7 +3970,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="COMMIT"
data-row-key="12345"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -4132,7 +4126,7 @@ LIMIT
</tr>
<tr
class="ant-table-row ant-table-row-level-0"
data-row-key="INSERT INTO \`audit_plan_sqls_v2\` (\`audit_plan_id\`,\`fingerprint_md5\`, \`fingerprint\`, \`sql_content\`, \`info\`, \`schema\`) VALUES (3, 'a62860c563df5399c2acb800673ae715', 'CREATE TABLE \`audit_files\` (\\n \`id\` int(10) unsigned NOT NULL AUTO_INCREMENT,\\n \`created_at\` datetime DEFAULT CURRENT_TIMESTAMP,\\n \`updated_at\` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\\n \`deleted_at\` datetime DEFAULT NULL,\\n \`task_id\` int(10) unsigned DEFAULT NULL,\\n \`unique_name\` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,\\n \`file_host\` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,\\n \`file_name\` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,\\n PRIMARY KEY (\`id\`)"
data-row-key="123456"
>
<td
class="ant-table-cell ellipsis-column-large-width"
Expand Down Expand Up @@ -4531,7 +4525,7 @@ LIMIT
class="ant-drawer-extra"
>
<a
href="/sqle/project/700300/sql-management-conf/1/analyze/undefined"
href="/sqle/project/700300/sql-management-conf/1/analyze/1"
target="blank"
>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ const ScanTypeSqlCollection: React.FC<ScanTypeSqlCollectionProps> = ({

{messageContextHolder}
<ActiontechTable
rowKey={(record) => record.sql}
rowKey="id"
setting={tableSetting}
errorMessage={getTableRowError && getErrorMessage(getTableRowError)}
loading={getFilterMetaListLoading || getTableRowLoading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,7 @@ describe('test sqle/SqlManagementConf/Update', () => {
it('render update audit plan', async () => {
const { baseElement } = superRender(<UpdateSqlManagementConf />);
await act(async () => jest.advanceTimersByTime(3000));
expect(getInstanceAuditPlanDetailSpy).toHaveBeenCalledTimes(1);
expect(getDriversSpy).toHaveBeenCalled();
expect(getProjectRuleTemplateTipSpy).toHaveBeenCalled();
expect(getGlobalRuleTemplateTipSpy).toHaveBeenCalled();
expect(getInstanceTipListSpy).toHaveBeenCalled();
expect(getAuditPlanMetaSpy).toHaveBeenCalled();
expect(getInstanceSpy).toHaveBeenCalled();

await act(async () => jest.advanceTimersByTime(3000));
// cancel default
fireEvent.click(screen.getByText('自定义'));
Expand All @@ -134,59 +128,39 @@ describe('test sqle/SqlManagementConf/Update', () => {

const aliMysqlLog = mockAuditPlanMetaData[3];
const planType = aliMysqlLog.audit_plan_type;
await act(async () => {
fireEvent.input(
getBySelector(`#${planType}_${aliMysqlLog.audit_plan_params?.[0].key}`),
{
target: { value: 'test' }
}
);
await jest.advanceTimersByTime(100);
});
await act(async () => {
fireEvent.input(getAllBySelector('input[type="password"]')[0], {
target: { value: '123' }
});
await jest.advanceTimersByTime(100);
});
await act(async () => {
fireEvent.input(getAllBySelector('input[type="password"]')[1], {
target: { value: '456' }
});
await jest.advanceTimersByTime(100);
});
await act(async () => {
fireEvent.input(
getBySelector(`#${planType}_${aliMysqlLog.audit_plan_params?.[3].key}`),
{
target: { value: '100' }
}
);
await jest.advanceTimersByTime(100);
});
await act(async () => {
fireEvent.input(
getBySelector(`#${planType}_${aliMysqlLog.audit_plan_params?.[4].key}`),
{
target: { value: '200' }
}
);
await jest.advanceTimersByTime(100);
fireEvent.input(
getBySelector(`#${planType}_${aliMysqlLog.audit_plan_params?.[0].key}`),
{
target: { value: 'test' }
}
);
fireEvent.input(getAllBySelector('input[type="password"]')[0], {
target: { value: '123' }
});
await act(async () => {
fireEvent.input(
getBySelector(`#${planType}_${aliMysqlLog.audit_plan_params?.[5].key}`),
{
target: { value: 'test.com' }
}
);
await jest.advanceTimersByTime(100);
fireEvent.input(getAllBySelector('input[type="password"]')[1], {
target: { value: '456' }
});
fireEvent.input(
getBySelector(`#${planType}_${aliMysqlLog.audit_plan_params?.[3].key}`),
{
target: { value: '100' }
}
);
fireEvent.input(
getBySelector(`#${planType}_${aliMysqlLog.audit_plan_params?.[4].key}`),
{
target: { value: '200' }
}
);
fireEvent.input(
getBySelector(`#${planType}_${aliMysqlLog.audit_plan_params?.[5].key}`),
{
target: { value: 'test.com' }
}
);
fireEvent.mouseDown(getBySelector(`#${planType}_ruleTemplateName`));
await act(async () => {
fireEvent.click(getBySelector('div[title="default_MySQL1"]'));
await jest.advanceTimersByTime(100);
});
fireEvent.click(getBySelector('div[title="default_MySQL1"]'));
await act(async () => jest.advanceTimersByTime(0));

expect(screen.getByTestId('audit_level_switch')).not.toBeChecked();
expect(screen.getByTestId('row_examined_avg_switch')).toBeChecked();
Expand All @@ -197,7 +171,7 @@ describe('test sqle/SqlManagementConf/Update', () => {

expect(baseElement).toMatchSnapshot();
fireEvent.click(screen.getByText('提 交'));
await act(async () => jest.advanceTimersByTime(300));
await act(async () => jest.advanceTimersByTime(0));
expect(updateInstanceAuditPlanSpy).toHaveBeenCalledTimes(1);
expect(updateInstanceAuditPlanSpy).toHaveBeenNthCalledWith(1, {
instance_audit_plan_id: auditPlanId,
Expand Down
Loading
Loading