Skip to content

Commit a66ad53

Browse files
committed
Lint fixes
1 parent c91e2e2 commit a66ad53

File tree

8 files changed

+152
-175
lines changed

8 files changed

+152
-175
lines changed

datahub-web-react/src/app/ingestV2/source/builder/RecipeForm/__tests__/common-git-info.test.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
import React from 'react';
21
import { render, screen } from '@testing-library/react';
32
import { Form } from 'antd';
3+
import React from 'react';
44

5-
import { GIT_INFO_REPO } from '@app/ingestV2/source/builder/RecipeForm/common';
6-
import { FieldType } from '@app/ingestV2/source/builder/RecipeForm/common';
5+
import { FieldType, GIT_INFO_REPO } from '@app/ingestV2/source/builder/RecipeForm/common';
76

87
// Mock FormField component for testing
9-
const MockFormField = ({ field, removeMargin }) => {
8+
const MockFormField = ({ field, removeMargin: _removeMargin }: { field: any; removeMargin: boolean }) => {
109
const { name, label, tooltip, type, placeholder, rules, required } = field;
11-
10+
1211
return (
1312
<div data-testid={`form-field-${name}`}>
14-
<label>{label}</label>
15-
{tooltip && <div data-testid={`tooltip-${name}`}>{typeof tooltip === 'string' ? tooltip : 'React tooltip'}</div>}
16-
<input
17-
type={type === FieldType.SECRET ? 'password' : 'text'}
13+
<label htmlFor={`input-${name}`}>{label}</label>
14+
{tooltip && (
15+
<div data-testid={`tooltip-${name}`}>{typeof tooltip === 'string' ? tooltip : 'React tooltip'}</div>
16+
)}
17+
<input
18+
id={`input-${name}`}
19+
type={type === FieldType.SECRET ? 'password' : 'text'}
1820
placeholder={placeholder}
1921
data-required={required}
2022
data-rules={rules ? rules.length : 0}
@@ -40,10 +42,10 @@ describe('Common Git Info Fields', () => {
4042
it('should render tooltip with multi-platform examples', () => {
4143
render(
4244
<Form>
43-
<MockFormField field={GIT_INFO_REPO} removeMargin={false} />
44-
</Form>
45+
<MockFormField field={GIT_INFO_REPO} removeMargin={false} />,
46+
</Form>,
4547
);
46-
48+
4749
const tooltip = screen.getByTestId('tooltip-git_info.repo');
4850
expect(tooltip.textContent).toContain('React tooltip');
4951
});
@@ -57,9 +59,9 @@ describe('Common Git Info Fields', () => {
5759

5860
it('should support multiple Git platforms in tooltip', () => {
5961
// Test that the tooltip contains information about multiple platforms
60-
const tooltip = GIT_INFO_REPO.tooltip;
62+
const { tooltip } = GIT_INFO_REPO;
6163
expect(tooltip).toBeDefined();
62-
64+
6365
// Since tooltip is a React component, we test its structure
6466
expect(React.isValidElement(tooltip)).toBe(true);
6567
});

datahub-web-react/src/app/ingestV2/source/builder/RecipeForm/__tests__/constants-git-info.test.tsx

Lines changed: 46 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { LOOKML_GIT_INFO_REPO } from '@app/ingestV2/source/builder/RecipeForm/lookml';
21
import { GIT_INFO_REPO } from '@app/ingestV2/source/builder/RecipeForm/common';
3-
import { LOOKML } from '@app/ingestV2/source/builder/RecipeForm/lookml';
4-
import { SOURCE_CONFIGS } from '@app/ingestV2/source/builder/RecipeForm/constants';
2+
import { RECIPE_FIELDS } from '@app/ingestV2/source/builder/RecipeForm/constants';
3+
import { LOOKML, LOOKML_GIT_INFO_REPO } from '@app/ingestV2/source/builder/RecipeForm/lookml';
54

65
describe('Constants Git Info Integration', () => {
76
describe('Field Imports', () => {
@@ -18,65 +17,57 @@ describe('Constants Git Info Integration', () => {
1817

1918
describe('Source Configuration Integration', () => {
2019
it('should include LOOKML_GIT_INFO_REPO in LOOKML source config', () => {
21-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
20+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
2221
expect(lookmlConfig).toBeDefined();
2322
expect(lookmlConfig.fields).toContain(LOOKML_GIT_INFO_REPO);
2423
});
2524

2625
it('should have correct field order in LOOKML config', () => {
27-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
28-
const fields = lookmlConfig.fields;
29-
26+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
27+
const { fields } = lookmlConfig;
28+
3029
// LOOKML_GIT_INFO_REPO should be the first field
3130
expect(fields[0]).toBe(LOOKML_GIT_INFO_REPO);
3231
});
3332

3433
it('should not contain deprecated github_info references', () => {
35-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
36-
const fields = lookmlConfig.fields;
37-
34+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
35+
const { fields } = lookmlConfig;
36+
3837
// Check that no fields have github_info in their name
39-
const githubInfoFields = fields.filter(field =>
40-
field.name && field.name.includes('github_info')
41-
);
38+
const githubInfoFields = fields.filter((field) => field.name && field.name.includes('github_info'));
4239
expect(githubInfoFields).toHaveLength(0);
4340
});
4441

4542
it('should contain git_info references', () => {
46-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
47-
const fields = lookmlConfig.fields;
48-
43+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
44+
const { fields } = lookmlConfig;
45+
4946
// Check that fields have git_info in their name
50-
const gitInfoFields = fields.filter(field =>
51-
field.name && field.name.includes('git_info')
52-
);
47+
const gitInfoFields = fields.filter((field) => field.name && field.name.includes('git_info'));
5348
expect(gitInfoFields.length).toBeGreaterThan(0);
5449
});
5550
});
5651

5752
describe('Field Consistency', () => {
5853
it('should have consistent field paths for git_info', () => {
59-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
60-
const fields = lookmlConfig.fields;
61-
62-
const gitInfoFields = fields.filter(field =>
63-
field.name && field.name.includes('git_info')
64-
);
65-
66-
gitInfoFields.forEach(field => {
54+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
55+
const { fields } = lookmlConfig;
56+
57+
const gitInfoFields = fields.filter((field) => field.name && field.name.includes('git_info'));
58+
59+
gitInfoFields.forEach((field) => {
6760
expect(field.fieldPath).toMatch(/^source\.config\.git_info\./);
6861
});
6962
});
7063

7164
it('should have proper field types for git_info fields', () => {
72-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
73-
const fields = lookmlConfig.fields;
74-
75-
const gitInfoFields = fields.filter(field =>
76-
field.name && field.name.includes('git_info')
77-
);
78-
79-
gitInfoFields.forEach(field => {
65+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
66+
const { fields } = lookmlConfig;
67+
68+
const gitInfoFields = fields.filter((field) => field.name && field.name.includes('git_info'));
69+
70+
gitInfoFields.forEach((field) => {
8071
expect(field.type).toBeDefined();
8172
expect(['TEXT', 'SECRET']).toContain(field.type);
8273
});
@@ -85,27 +76,23 @@ describe('Constants Git Info Integration', () => {
8576

8677
describe('Migration from github_info', () => {
8778
it('should not have any github_info field references', () => {
88-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
89-
const fields = lookmlConfig.fields;
90-
79+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
80+
const { fields } = lookmlConfig;
81+
9182
// Ensure no fields reference the old github_info structure
92-
const oldFieldPaths = fields.filter(field =>
93-
field.fieldPath && field.fieldPath.includes('github_info')
94-
);
83+
const oldFieldPaths = fields.filter((field) => field.fieldPath && field.fieldPath.includes('github_info'));
9584
expect(oldFieldPaths).toHaveLength(0);
9685
});
9786

9887
it('should have updated field names from github_info to git_info', () => {
99-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
100-
const fields = lookmlConfig.fields;
101-
102-
const gitInfoFields = fields.filter(field =>
103-
field.name && field.name.includes('git_info')
104-
);
105-
88+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
89+
const { fields } = lookmlConfig;
90+
91+
const gitInfoFields = fields.filter((field) => field.name && field.name.includes('git_info'));
92+
10693
expect(gitInfoFields.length).toBeGreaterThan(0);
107-
108-
gitInfoFields.forEach(field => {
94+
95+
gitInfoFields.forEach((field) => {
10996
expect(field.name).toMatch(/^git_info\./);
11097
expect(field.name).not.toMatch(/^github_info\./);
11198
});
@@ -114,21 +101,19 @@ describe('Constants Git Info Integration', () => {
114101

115102
describe('Field Validation', () => {
116103
it('should have required fields properly marked', () => {
117-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
118-
const fields = lookmlConfig.fields;
119-
120-
const requiredFields = fields.filter(field => field.required === true);
104+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
105+
const { fields } = lookmlConfig;
106+
107+
const requiredFields = fields.filter((field) => field.required === true);
121108
expect(requiredFields.length).toBeGreaterThan(0);
122109
});
123110

124111
it('should have validation rules for required fields', () => {
125-
const lookmlConfig = SOURCE_CONFIGS[LOOKML];
126-
const fields = lookmlConfig.fields;
127-
128-
const fieldsWithRules = fields.filter(field =>
129-
field.rules && field.rules.length > 0
130-
);
131-
112+
const lookmlConfig = RECIPE_FIELDS[LOOKML];
113+
const { fields } = lookmlConfig;
114+
115+
const fieldsWithRules = fields.filter((field) => field.rules && field.rules.length > 0);
116+
132117
expect(fieldsWithRules.length).toBeGreaterThan(0);
133118
});
134119
});

datahub-web-react/src/app/ingestV2/source/builder/RecipeForm/__tests__/git-info-validation.test.tsx

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { LOOKML_GIT_INFO_REPO_SSH_LOCATOR } from '@app/ingestV2/source/builder/RecipeForm/lookml';
22

33
describe('Git Info Validation Logic', () => {
4-
describe('REPO_SSH_LOCATOR Validation', () => {
5-
const createValidator = (repoValue) => {
6-
return LOOKML_GIT_INFO_REPO_SSH_LOCATOR.rules![0]({
7-
getFieldValue: (fieldName) => {
8-
if (fieldName === 'git_info.repo') return repoValue;
9-
return undefined;
10-
}
11-
});
12-
};
4+
const createValidator = (repoValue: string | undefined | null) => {
5+
return LOOKML_GIT_INFO_REPO_SSH_LOCATOR.rules![0]({
6+
getFieldValue: (fieldName) => {
7+
if (fieldName === 'git_info.repo') return repoValue;
8+
return undefined;
9+
},
10+
});
11+
};
1312

13+
describe('REPO_SSH_LOCATOR Validation', () => {
1414
describe('GitHub Repository Detection', () => {
1515
it('should not require SSH locator for GitHub short format', async () => {
1616
const validator = createValidator('datahub-project/datahub');
@@ -54,21 +54,21 @@ describe('Git Info Validation Logic', () => {
5454
it('should require SSH locator for Bitbucket', async () => {
5555
const validator = createValidator('https://bitbucket.org/org/repo');
5656
await expect(validator.validator({}, '')).rejects.toThrow(
57-
'Repository SSH Locator is required for Git platforms other than GitHub and GitLab'
57+
'Repository SSH Locator is required for Git platforms other than GitHub and GitLab',
5858
);
5959
});
6060

6161
it('should require SSH locator for custom Git server', async () => {
6262
const validator = createValidator('https://custom-git.com/org/repo');
6363
await expect(validator.validator({}, '')).rejects.toThrow(
64-
'Repository SSH Locator is required for Git platforms other than GitHub and GitLab'
64+
'Repository SSH Locator is required for Git platforms other than GitHub and GitLab',
6565
);
6666
});
6767

6868
it('should require SSH locator for SSH URL format', async () => {
6969
const validator = createValidator('[email protected]:org/repo');
7070
await expect(validator.validator({}, '')).rejects.toThrow(
71-
'Repository SSH Locator is required for Git platforms other than GitHub and GitLab'
71+
'Repository SSH Locator is required for Git platforms other than GitHub and GitLab',
7272
);
7373
});
7474

@@ -119,7 +119,7 @@ describe('Git Info Validation Logic', () => {
119119
it('should require SSH locator for non-GitHub/GitLab URLs with similar patterns', async () => {
120120
const validator = createValidator('https://github-enterprise.company.com/org/repo');
121121
await expect(validator.validator({}, '')).rejects.toThrow(
122-
'Repository SSH Locator is required for Git platforms other than GitHub and GitLab'
122+
'Repository SSH Locator is required for Git platforms other than GitHub and GitLab',
123123
);
124124
});
125125
});
@@ -130,19 +130,11 @@ describe('Git Info Validation Logic', () => {
130130
const validator = createValidator('https://custom-git.com/org/repo');
131131
try {
132132
await validator.validator({}, '');
133-
} catch (error) {
134-
expect(error.message).toBe('Repository SSH Locator is required for Git platforms other than GitHub and GitLab');
133+
} catch (error: any) {
134+
expect(error.message).toBe(
135+
'Repository SSH Locator is required for Git platforms other than GitHub and GitLab',
136+
);
135137
}
136138
});
137139
});
138-
139-
// Helper function for creating validators
140-
function createValidator(repoValue) {
141-
return LOOKML_GIT_INFO_REPO_SSH_LOCATOR.rules![0]({
142-
getFieldValue: (fieldName) => {
143-
if (fieldName === 'git_info.repo') return repoValue;
144-
return undefined;
145-
}
146-
});
147-
}
148140
});

0 commit comments

Comments
 (0)