Closed saravmajestic closed 1 week ago
Sweep: In src\webview_provider\docsEditPanel.ts, function: getTestDataByColumn, fix the tests which has same test name with different config to be saved properly in yaml file
I'm going to follow the following steps to help you solve the GitHub issue:
getTestDataByColumn
method in docsEditPanel.ts
to preserve existing test configurations when updating column tests in the documentation editor.saveDocumentation
case in the setupWebviewHooks
method of docsEditPanel.ts
to use the updated getTestDataByColumn
method when saving column documentation.Here are the changes we decided to make. I'm done making edits and now I'm just validating the changes using a linter to catch any mistakes like syntax errors or undefined variables:
src/webview_provider/docsEditPanel.ts
Modify the `getTestDataByColumn` method to preserve existing test configurations when updating column tests in the documentation editor.
---
+++
@@ -36,35 +36,10 @@
return key === fullName;
});
- // If relationships test, set field and to
- if (this.isRelationship(kwargs)) {
- const { to, field } = kwargs;
- return {
- relationships: {
- ...existingConfig?.["relationships"],
- field,
- to,
- },
- };
+ if (existingConfig) {
+ return existingConfig;
}
- // set values if test is accepted_values
- if (this.isAcceptedValues(kwargs)) {
- return {
- accepted_values: {
- ...existingConfig?.["accepted_values"],
- values: kwargs.values,
- },
- };
- }
-
- if (existingConfig?.[fullName]) {
- return {
- [fullName]: existingConfig?.[fullName],
- };
- }
-
- // Add extra config from external packages or test macros
// Add extra config from external packages or test macros
const testMetaKwargs = this.getTestMetadataKwArgs(kwargs, fullName);
return testMetaKwargs || fullName;
src/webview_provider/docsEditPanel.ts
Update the `saveDocumentation` case in the `setupWebviewHooks` method to use the updated `getTestDataByColumn` method when saving column documentation.
---
+++
@@ -15,13 +15,11 @@
isColumnNameEqual(yamlColumn.name, column.name),
);
if (existingColumn !== undefined) {
- // ignore tests from existing column, as it will be recreated in `getTestDataByColumn`
- const { tests, ...rest } = existingColumn;
return {
- ...rest,
+ ...existingColumn,
name: existingColumn.name,
data_type: (
- rest.data_type || column.type
+ existingColumn.data_type || column.type
)?.toLowerCase(),
description: column.description || undefined,
...this.getTestDataByColumn(
Your changes have been successfully made to the branch sweep/documentation_editor_mess_up_tests_when
. I have validated these changes using a syntax checker and a linter.
[!TIP] To recreate the pull request, edit the issue title or description.
This is an automated message generated by Sweep AI.
Expected behavior
Actual behavior
Steps To Reproduce
I have two accepted values tests with two different configs but the Documentation Editor changed them to give them the same config.
before
after
Log output/Screenshots
No response
Operating System
MacOs
dbt version
1.7
dbt Adapter
any
dbt Power User version
any
Are you willing to submit PR?