-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor: OSS requirements for the custom property automation action (#1…
…9507) * Fix the return type for the custom property API function * Break down the EditTableTypePropertyModal.tsx component * Fix the custom property inputs for date-time type properties * auto lint formatting changes * Add the autoFocus prop for DataAssetAsyncSelectList * Fix and add the unit tests for new code (cherry picked from commit 638e988)
- Loading branch information
1 parent
9a6480b
commit 1dc8da2
Showing
17 changed files
with
609 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ents/common/CustomPropertyTable/TableTypeProperty/EditTableTypePropertyModal.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2025 Collate. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { CustomProperty } from '../../../../generated/entity/type'; | ||
import { TableTypePropertyValueType } from '../CustomPropertyTable.interface'; | ||
|
||
export interface EditTableTypePropertyModalProps { | ||
isVisible: boolean; | ||
isUpdating: boolean; | ||
property: CustomProperty; | ||
columns: string[]; | ||
rows: Record<string, string>[]; | ||
onCancel: () => void; | ||
onSave: (data: TableTypePropertyValueType) => Promise<void>; | ||
} |
95 changes: 95 additions & 0 deletions
95
...mponents/common/CustomPropertyTable/TableTypeProperty/EditTableTypePropertyModal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright 2025 Collate. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import { fireEvent, render, waitFor } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { CustomProperty } from '../../../../generated/type/customProperty'; | ||
import EditTableTypePropertyModal from './EditTableTypePropertyModal'; | ||
import { EditTableTypePropertyModalProps } from './EditTableTypePropertyModal.interface'; | ||
|
||
jest.mock('./TableTypePropertyEditTable', () => | ||
jest.fn().mockImplementation(() => <div>TableTypePropertyEditTable</div>) | ||
); | ||
|
||
jest.mock('./TableTypePropertyView', () => | ||
jest.fn().mockImplementation(() => <div>TableTypePropertyView</div>) | ||
); | ||
|
||
const mockOnCancel = jest.fn(); | ||
const mockOnSave = jest.fn().mockResolvedValue(undefined); | ||
|
||
const defaultProps: EditTableTypePropertyModalProps = { | ||
isVisible: true, | ||
isUpdating: false, | ||
property: {} as CustomProperty, | ||
columns: ['column1', 'column2'], | ||
rows: [{ column1: 'value1', column2: 'value2' }], | ||
onCancel: mockOnCancel, | ||
onSave: mockOnSave, | ||
}; | ||
|
||
describe('EditTableTypePropertyModal', () => { | ||
it('should render the modal with the correct title', () => { | ||
const { getByText } = render( | ||
<EditTableTypePropertyModal {...defaultProps} /> | ||
); | ||
|
||
expect(getByText('label.edit-entity-name')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call onCancel when the cancel button is clicked', () => { | ||
const { getByTestId } = render( | ||
<EditTableTypePropertyModal {...defaultProps} /> | ||
); | ||
fireEvent.click(getByTestId('cancel-update-table-type-property')); | ||
|
||
expect(mockOnCancel).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should call onSave with the correct data when the update button is clicked', async () => { | ||
const { getByTestId } = render( | ||
<EditTableTypePropertyModal {...defaultProps} /> | ||
); | ||
fireEvent.click(getByTestId('update-table-type-property')); | ||
await waitFor(() => | ||
expect(mockOnSave).toHaveBeenCalledWith({ | ||
rows: [{ column1: 'value1', column2: 'value2' }], | ||
columns: ['column1', 'column2'], | ||
}) | ||
); | ||
}); | ||
|
||
it('should add a new row when the add new row button is clicked', () => { | ||
const { getByTestId, getByText } = render( | ||
<EditTableTypePropertyModal {...defaultProps} /> | ||
); | ||
fireEvent.click(getByTestId('add-new-row')); | ||
|
||
expect(getByText('TableTypePropertyEditTable')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render TableTypePropertyView when dataSource is empty', () => { | ||
const props = { ...defaultProps, rows: [] }; | ||
const { getByText } = render(<EditTableTypePropertyModal {...props} />); | ||
|
||
expect(getByText('TableTypePropertyView')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render TableTypePropertyEditTable when dataSource is not empty', () => { | ||
const { getByText } = render( | ||
<EditTableTypePropertyModal {...defaultProps} /> | ||
); | ||
|
||
expect(getByText('TableTypePropertyEditTable')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.