-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor drills unit tests structure, split huge file by drill type
- Loading branch information
1 parent
aa10916
commit 381ec0f
Showing
15 changed files
with
2,653 additions
and
2,261 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
131 changes: 131 additions & 0 deletions
131
frontend/src/metabase-lib/tests/drills-column-filter.unit.spec.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,131 @@ | ||
import type { DrillThruType } from "metabase-lib"; | ||
import type { DrillDisplayInfoTestCase } from "metabase-lib/tests/drills-common"; | ||
import { getDrillsQueryParameters } from "metabase-lib/tests/drills-common"; | ||
import { getAvailableDrillByType } from "metabase-lib/test-helpers"; | ||
|
||
const DRILL_TYPE: DrillThruType = "drill-thru/column-filter"; | ||
|
||
describe("drill-thru/column-filter", () => { | ||
describe("availableDrillThrus", () => { | ||
it.each<DrillDisplayInfoTestCase>([ | ||
{ | ||
clickType: "header", | ||
queryType: "unaggregated", | ||
columnName: "ID", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: expect.objectContaining({ short: "=" }), | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "unaggregated", | ||
columnName: "USER_ID", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: expect.objectContaining({ short: "=" }), | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "unaggregated", | ||
columnName: "TAX", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: expect.objectContaining({ short: "=" }), | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "unaggregated", | ||
columnName: "DISCOUNT", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: expect.objectContaining({ short: "=" }), | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "unaggregated", | ||
columnName: "CREATED_AT", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: null, | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "unaggregated", | ||
columnName: "QUANTITY", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: expect.objectContaining({ short: "=" }), | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "aggregated", | ||
columnName: "PRODUCT_ID", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: expect.objectContaining({ short: "=" }), | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "aggregated", | ||
columnName: "PRODUCT_ID", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: expect.objectContaining({ short: "=" }), | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "aggregated", | ||
columnName: "CREATED_AT", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: null, | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "aggregated", | ||
columnName: "count", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: expect.objectContaining({ short: "=" }), | ||
}, | ||
}, | ||
{ | ||
clickType: "header", | ||
queryType: "aggregated", | ||
columnName: "max", | ||
expectedParameters: { | ||
type: "drill-thru/column-filter", | ||
initialOp: expect.objectContaining({ short: "=" }), | ||
}, | ||
}, | ||
])( | ||
`should return "${DRILL_TYPE}" drill config for $columnName $clickType in $queryType query`, | ||
({ | ||
columnName, | ||
clickType, | ||
queryType, | ||
queryTable = "ORDERS", | ||
customQuestion, | ||
expectedParameters, | ||
}) => { | ||
const { drillDisplayInfo } = getAvailableDrillByType({ | ||
drillType: DRILL_TYPE, | ||
clickType, | ||
clickedColumnName: columnName, | ||
...getDrillsQueryParameters(queryType, queryTable, customQuestion), | ||
}); | ||
|
||
expect(drillDisplayInfo).toEqual(expectedParameters); | ||
}, | ||
); | ||
}); | ||
}); |
Oops, something went wrong.