yardz opened a new pull request #13422:
URL: https://github.com/apache/superset/pull/13422


   ### SUMMARY
   The purpose of this PR is to improve the readability and maintainability of 
component `src/components/dataViewCommon/TableCollection.tsx`.
   
   #### Observed issues:
   High complexity, makes the code more difficult to understand and to test.
   **Proposed solution:** Divide the component into smaller, more specialized 
components.
   
   
   #### Solution description
   The component was initially divided into 2:  `TableCollectionHead` and 
`TableCollectionBody`
   As the table's data model is complex, the tests were intended to just ensure 
that the pros were being send correctly to these components.
   
   The `TableCollectionHead` is intended to render the table's head (`<thead 
/>`). For this, it was divided into 2. The `TableCollectionHead` itself that 
takes care of the re-rendering of the lines (`<tr>`) and the 
`TableCollectionHeadCol` which takes care of the rendering of the cells 
(`<td>`).
   The testing strategy of TableCollectionHead is also just to ensure that an 
object that minimally respects the interface of the `react-table` and sends the 
correct props to `TableCollectionHeadCol`.
   The`TableCollectionHeadCol` test targets all states/behaviors variations 
supported by the component.
   
   
   The component `TableCollectionBody` was also initially divided into 2 
components `TableCollectionLoading` and `TableCollectionBodyContent`.
   `TableCollectionLoading` is responsible for rendering when the table is in 
the loading state and has no information. The testing strategy is to cover the 
behaviors and ensure that the props are sent correctly to the component 
`TableCollectionCell`
   The component `TableCollectionBodyContent` is responsible for rendering the 
data (the rows / `<tr>`) of the table. The testing strategy also consists of 
covering possible behaviors and sending the correct props to 
`TableCollectionCell`
   `TableCollectionCell` is responsible for rendering a table cell (`<td>`), 
either containing data or in a loading state. The testing strategy consists of 
verifying that when receiving the cell data (props), it will behave properly.
   
   In summary, `TableCollection`, `TableCollectionHead`, `TableCollectionBody`, 
`TableCollectionLoading` and `TableCollectionBodyContent` are responsible for 
sending the pops to a component below in your tree. Their tests are focused on 
ensuring that the props are being sent correctly.
   `TableCollectionHeadCol` and `TableCollectionHeadCol` are responsible for 
render the table cells (`<td>/<th>`). The testing of these components is 
focused on behavior and correct rendering.
   
   
   ### TEST PLAN
   No changes in behavior should occur and all tests must pass.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to