-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Split derived.test.js to separate files. (#38162)
## Description This PR started with this goal: - Deleted the unreadable `derived.test.js` (4668 lines) file and split each suite to its file. - Moved all `derived.js` related specs in widget folder to __tests__ folder Later we found that `testRegex` in `jest.config` will treat anything inside `__tests__` as runnable, so we modify this rule and are moving to a consistent naming for our unit tests(any file ending with `.test.` or `.spec.` This refactor aims to improve maintainability and ensure that the table widget's derived properties are thoroughly tested. Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!WARNING] > Tests have not run on the HEAD b3168bb yet > <hr>Tue, 17 Dec 2024 10:20:54 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Expanded properties for table widget configuration. - Introduced sample data constants for column schemas and processed table data. - **Bug Fixes** - Improved validation tests for editable cells and row selection functions. - **Tests** - Added comprehensive test suites for various table widget functionalities, including filtering, sorting, and row selection. - Introduced tests for handling HTML content within table columns. - Added tests for new functions related to row updates and indices. - Enhanced test coverage for existing utility functions and table properties. - **Chores** - Updated import paths to reflect a new directory structure across various test files. - Modified Jest configuration for improved readability and regex adjustments. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
1 parent
8415e16
commit 5d213dd
Showing
25 changed files
with
4,720 additions
and
4,681 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ableWidgetV2/widget/TableRendered.test.ts → ...V2/widget/__tests__/TableRendered.test.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
191 changes: 191 additions & 0 deletions
191
app/client/src/widgets/TableWidgetV2/widget/__tests__/derived.test/fixture.js
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,191 @@ | ||
export const samplePrimaryColumns = { | ||
step: { | ||
index: 0, | ||
width: 150, | ||
id: "step", | ||
originalId: "step", | ||
alias: "step", | ||
horizontalAlignment: "LEFT", | ||
verticalAlignment: "CENTER", | ||
columnType: "text", | ||
textSize: "0.875rem", | ||
enableFilter: true, | ||
enableSort: true, | ||
isVisible: true, | ||
isCellVisible: true, | ||
isCellEditable: false, | ||
isDerived: false, | ||
label: "step", | ||
computedValue: ["#1", "#2", "#3"], | ||
labelColor: "#FFFFFF", | ||
cellBackground: "", | ||
textColor: "", | ||
fontStyle: "", | ||
}, | ||
task: { | ||
index: 1, | ||
width: 150, | ||
id: "task", | ||
originalId: "task", | ||
alias: "task", | ||
horizontalAlignment: "LEFT", | ||
verticalAlignment: "CENTER", | ||
columnType: "text", | ||
textSize: "0.875rem", | ||
enableFilter: true, | ||
enableSort: true, | ||
isVisible: true, | ||
isCellVisible: true, | ||
isCellEditable: false, | ||
isDerived: false, | ||
label: "task", | ||
computedValue: [ | ||
"Drop a table", | ||
"Create a query fetch_users with the Mock DB", | ||
"Bind the query using => fetch_users.data", | ||
], | ||
labelColor: "#FFFFFF", | ||
cellBackground: "", | ||
textColor: "", | ||
fontStyle: "", | ||
}, | ||
status: { | ||
index: 2, | ||
width: 150, | ||
id: "status", | ||
originalId: "status", | ||
alias: "status", | ||
horizontalAlignment: "LEFT", | ||
verticalAlignment: "CENTER", | ||
columnType: "text", | ||
textSize: "0.875rem", | ||
enableFilter: true, | ||
enableSort: true, | ||
isVisible: true, | ||
isCellVisible: true, | ||
isCellEditable: false, | ||
isDerived: false, | ||
label: "status", | ||
computedValue: ["✅", "--", "--"], | ||
labelColor: "#FFFFFF", | ||
cellBackground: "", | ||
textColor: "", | ||
fontStyle: "", | ||
}, | ||
action: { | ||
index: 3, | ||
width: 150, | ||
id: "action", | ||
originalId: "action", | ||
alias: "action", | ||
horizontalAlignment: "LEFT", | ||
verticalAlignment: "CENTER", | ||
columnType: "button", | ||
textSize: "0.875rem", | ||
enableFilter: true, | ||
enableSort: true, | ||
isVisible: true, | ||
isCellVisible: true, | ||
isCellEditable: false, | ||
isDisabled: false, | ||
isDerived: false, | ||
label: "action", | ||
onClick: | ||
"{{currentRow.step === '#1' ? showAlert('Done', 'success') : currentRow.step === '#2' ? navigateTo('https://docs.appsmith.com/core-concepts/connecting-to-data-sources/querying-a-database',undefined,'NEW_WINDOW') : navigateTo('https://docs.appsmith.com/core-concepts/displaying-data-read/display-data-tables',undefined,'NEW_WINDOW')}}", | ||
computedValue: ["", "", ""], | ||
labelColor: "#FFFFFF", | ||
buttonColor: ["#553DE9", "#553DE9", "#553DE9"], | ||
borderRadius: ["0.375rem", "0.375rem", "0.375rem"], | ||
boxShadow: ["none", "none", "none"], | ||
buttonLabel: ["Action", "Action", "Action"], | ||
buttonVariant: "PRIMARY", | ||
}, | ||
customColumn1: { | ||
allowCellWrapping: false, | ||
index: 4, | ||
width: 150, | ||
originalId: "customColumn1", | ||
id: "customColumn1", | ||
alias: "customColumn1", | ||
horizontalAlignment: "LEFT", | ||
verticalAlignment: "CENTER", | ||
columnType: "menuButton", | ||
textSize: "0.875rem", | ||
enableFilter: true, | ||
enableSort: true, | ||
isVisible: true, | ||
isDisabled: false, | ||
isCellEditable: false, | ||
isEditable: false, | ||
isCellVisible: true, | ||
isDerived: true, | ||
label: "menu", | ||
isSaveVisible: true, | ||
isDiscardVisible: true, | ||
computedValue: "", | ||
buttonStyle: "rgb(3, 179, 101)", | ||
labelColor: "#FFFFFF", | ||
menuColor: ["#553DE9", "#553DE9", "#553DE9"], | ||
borderRadius: ["0.375rem", "0.375rem", "0.375rem"], | ||
boxShadow: ["none", "none", "none"], | ||
customAlias: "", | ||
menuButtonLabel: ["Open Menu", "Open Menu", "Open Menu"], | ||
menuVariant: "PRIMARY", | ||
menuButtoniconName: "", | ||
}, | ||
customColumn2: { | ||
allowCellWrapping: false, | ||
index: 5, | ||
width: 150, | ||
originalId: "customColumn2", | ||
id: "customColumn2", | ||
alias: "customColumn2", | ||
horizontalAlignment: "LEFT", | ||
verticalAlignment: "CENTER", | ||
columnType: "iconButton", | ||
textSize: "0.875rem", | ||
enableFilter: true, | ||
enableSort: true, | ||
isVisible: true, | ||
isDisabled: false, | ||
isCellEditable: false, | ||
isEditable: false, | ||
isCellVisible: true, | ||
isDerived: true, | ||
label: "icon", | ||
isSaveVisible: true, | ||
isDiscardVisible: true, | ||
computedValue: "", | ||
buttonStyle: "rgb(3, 179, 101)", | ||
labelColor: "#FFFFFF", | ||
buttonColor: ["#553DE9", "#553DE9", "#553DE9"], | ||
borderRadius: ["0.375rem", "0.375rem", "0.375rem"], | ||
boxShadow: ["none", "none", "none"], | ||
customAlias: "", | ||
buttonVariant: "PRIMARY", | ||
iconName: "add", | ||
}, | ||
}; | ||
export const sampleProcessedTableData = [ | ||
{ | ||
step: "#1", | ||
task: "Drop a table", | ||
status: "✅", | ||
action: "", | ||
__originalIndex__: 0, | ||
}, | ||
{ | ||
step: "#2", | ||
task: "Create a query fetch_users with the Mock DB", | ||
status: "--", | ||
action: "", | ||
__originalIndex__: 1, | ||
}, | ||
{ | ||
step: "#3", | ||
task: "Bind the query using => fetch_users.data", | ||
status: "--", | ||
action: "", | ||
__originalIndex__: 2, | ||
}, | ||
]; |
Oops, something went wrong.