Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nouzbe committed Oct 5, 2023
1 parent 42fe63a commit 033e322
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 34 deletions.
56 changes: 28 additions & 28 deletions src/4.3_to_5.0/__snapshots__/migrate_43_to_50.test.ts.snap

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/4.3_to_5.0/_migrateQuery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("_migrateQuery", () => {
"cubeName": "EquityDerivativesCube",
"elementType": "From",
},
"slicerAxis": undefined,
"slicerAxis": null,
"withClause": [],
},
"updateMode": "once",
Expand Down Expand Up @@ -56,7 +56,10 @@ describe("_migrateQuery", () => {
mdx: "SELECT FROM [EquityDerivativesCube] WHERE [Currency].[Currency].[AllMember].[EUR]",
};
const [{ query, filters }] = _migrateQuery({ legacyQuery, cube })!;
expect(stringify(query.mdx!)).toBe("SELECT FROM [EquityDerivativesCube]");

// Filters are unchanged in the query.
expect(stringify(query.mdx!)).toBe(legacyQuery.mdx);

expect(filters.length).toBe(1);
expect(stringify(filters[0])).toBe(
"[Currency].[Currency].[AllMember].[EUR]",
Expand Down
8 changes: 8 additions & 0 deletions src/4.3_to_5.0/migrateChart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe("migrateChart", () => {
it("returns the ActiveUI5 chart widget state corresponding to the given ActiveUI4 chart widget state", () => {
expect(migrateChart(legacyChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -83,6 +84,7 @@ describe("migrateChart", () => {
it("migrates a legacy line chart to a Plotly line chart", () => {
expect(migrateChart(legacyLineChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -113,6 +115,7 @@ describe("migrateChart", () => {
it("migrates a legacy area chart to a Plotly area chart", () => {
expect(migrateChart(legacyAreaChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -143,6 +146,7 @@ describe("migrateChart", () => {
it("migrates a legacy column chart to a Plotly column chart", () => {
expect(migrateChart(legacyColumnChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -172,6 +176,7 @@ describe("migrateChart", () => {
it("migrates a legacy bar chart to a Plotly bar chart", () => {
expect(migrateChart(legacyBarChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down Expand Up @@ -201,6 +206,7 @@ describe("migrateChart", () => {
it("migrates a legacy pie chart to a Plotly pie chart", () => {
expect(migrateChart(legacyPieChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand All @@ -227,6 +233,7 @@ describe("migrateChart", () => {
it("migrates a legacy scatter plot to a Plotly scatter plot", () => {
expect(migrateChart(legacyScatterPlot, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"color": [
Expand Down Expand Up @@ -262,6 +269,7 @@ describe("migrateChart", () => {
it("migrates an empty chart widget to a plotly-line-chart", () => {
expect(migrateChart(emptyLegacyChart, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down
4 changes: 3 additions & 1 deletion src/4.3_to_5.0/migrateDashboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("migrateDashboard", () => {
expect(dashboard.pages["p-0"].content).toMatchInlineSnapshot(`
{
"1": {
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand All @@ -36,7 +37,7 @@ describe("migrateDashboard", () => {
},
"name": "Tree table",
"query": {
"mdx": "SELECT NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM [EquityDerivativesCube] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS",
"mdx": "SELECT NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM (SELECT {[Currency].[Currency].[ALL].[AllMember].[GBP], [Currency].[Currency].[ALL].[AllMember].[JPY], [Currency].[Currency].[ALL].[AllMember].[USD]} ON COLUMNS FROM (SELECT TopCount(Filter([Geography].[City].Levels(1).Members, NOT IsEmpty([Measures].[contributors.COUNT])), 3, [Measures].[contributors.COUNT]) ON COLUMNS FROM [EquityDerivativesCube])) CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS",
"updateMode": "once",
},
"queryContext": [
Expand All @@ -57,6 +58,7 @@ describe("migrateDashboard", () => {
"widgetKey": "tree-table",
},
"2": {
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down
4 changes: 3 additions & 1 deletion src/4.3_to_5.0/migrateDrillthrough.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ describe("migrateDrillthrough", () => {
expect(migrateDrillthrough(legacyDrillthrough, servers))
.toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {},
"filters": [
"[Booking].[Desk].[ALL].[AllMember].[LegalEntityA].[BusinessUnitA]",
],
"name": "Drillthrough LegalEntityA ➜ BusinessUnitA",
"query": {
"mdx": "DRILLTHROUGH SELECT FROM [EquityDerivativesCube] RETURN MemberValue([BusinessUnit]), Caption([BusinessUnit]), MemberValue([TradeId]), Caption([TradeId])",
"mdx": "DRILLTHROUGH SELECT FROM [EquityDerivativesCube] WHERE [Booking].[Desk].[ALL].[AllMember].[LegalEntityA].[BusinessUnitA] RETURN MemberValue([BusinessUnit]), Caption([BusinessUnit]), MemberValue([TradeId]), Caption([TradeId])",
"updateMode": "once",
},
"queryContext": [],
Expand All @@ -28,6 +29,7 @@ describe("migrateDrillthrough", () => {
expect(migrateDrillthrough(emptyLegacyDrillthrough, servers))
.toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {},
"filters": [],
"name": "Untitled Drillthrough Table",
Expand Down
3 changes: 3 additions & 0 deletions src/4.3_to_5.0/migrateKpi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe("migrateKpi", () => {
it("returns the ActiveUI5 KPI widget state corresponding to the given ActiveUI4 KPI widget state", () => {
expect(migrateKpi(legacyKpi, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"columns": [],
Expand Down Expand Up @@ -46,6 +47,7 @@ describe("migrateKpi", () => {
it("migrates a KPI widget with a comparison", () => {
expect(migrateKpi(legacyComparisonValues, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"comparison": {
"comparedMemberNamePath": [
"AllMember",
Expand Down Expand Up @@ -83,6 +85,7 @@ describe("migrateKpi", () => {
it("migrates an empty KPI widget", () => {
expect(migrateKpi(emptyLegacyKpi, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"columns": [],
Expand Down
7 changes: 6 additions & 1 deletion src/4.3_to_5.0/migrateTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe("migrateTable", () => {
it("migrates a tree table widget", () => {
expect(migrateTable(legacyTreeTable, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand All @@ -37,7 +38,7 @@ describe("migrateTable", () => {
},
"name": "Tree table",
"query": {
"mdx": "SELECT NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM [EquityDerivativesCube] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS",
"mdx": "SELECT NON EMPTY Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember])) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM (SELECT {[Currency].[Currency].[ALL].[AllMember].[GBP], [Currency].[Currency].[ALL].[AllMember].[JPY], [Currency].[Currency].[ALL].[AllMember].[USD]} ON COLUMNS FROM (SELECT TopCount(Filter([Geography].[City].Levels(1).Members, NOT IsEmpty([Measures].[contributors.COUNT])), 3, [Measures].[contributors.COUNT]) ON COLUMNS FROM [EquityDerivativesCube])) CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS",
"updateMode": "once",
},
"queryContext": [
Expand All @@ -63,6 +64,7 @@ describe("migrateTable", () => {
it("migrates an empty table widget", () => {
expect(migrateTable(emptyLegacyTable, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {},
"filters": [],
"mapping": {
Expand All @@ -86,6 +88,7 @@ describe("migrateTable", () => {
it("migrates a tabular view widget", () => {
expect(migrateTable(legacyTabularView, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand Down Expand Up @@ -114,6 +117,7 @@ describe("migrateTable", () => {
it("migrates a pivot table widget", () => {
expect(migrateTable(legacyPivotTable, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand Down Expand Up @@ -142,6 +146,7 @@ describe("migrateTable", () => {
it("migrates a table widget", () => {
expect(migrateTable(legacyTable, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"columnWidths": {
"[Currency].[Currency].[Currency]": 250,
},
Expand Down
1 change: 1 addition & 0 deletions src/4.3_to_5.0/migrateWidget.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe("migrateWidget", () => {

expect(migrateWidget(legacyWidgetState, servers)).toMatchInlineSnapshot(`
{
"areFiltersDrivenByMdx": true,
"filters": [],
"mapping": {
"horizontalSubplots": [],
Expand Down
2 changes: 1 addition & 1 deletion src/4.3_to_5.0/migrate_43_to_50.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe("migrate_43_to_50", () => {
"entry": {
"canRead": true,
"canWrite": true,
"content": "{"pages":{"p-0":{"layout":{"children":[{"leafKey":"2"},{"leafKey":"1"}],"direction":"row"},"name":"Page 1","filters":[],"content":{"1":{"serverUrl":"","mdx":"SELECT NON EMPTY Crossjoin(Hierarchize(DrilldownLevel([Geography].[City].[ALL].[AllMember])), Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember]))) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM [foo] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS","contextValues":{"mdx.hiddengrandtotals":"1"},"updateMode":"once","ranges":{"row":{"chunkSize":2000,"thresholdPercentage":0.1},"column":{"chunkSize":50,"thresholdPercentage":0.2}},"configuration":{"tabular":{"pinnedHeaderSelector":"member","sortingMode":"non-breaking","addButtonFilter":"numeric","cellRenderers":["tree-layout"],"statisticsShown":true,"columnsGroups":[{"captionProducer":"firstColumn","cellFactory":"kpi-status","selector":"kpi-status"},{"captionProducer":"firstColumn","cellFactory":"lookup","selector":"lookup"},{"captionProducer":"expiry","cellFactory":"expiry","selector":"kpi-expiry"},{"captionProducer":"columnMerge","cellFactory":{"args":{},"key":"treeCells"},"selector":"member"}],"hideAddButton":true,"defaultOptions":{},"expansion":{"automaticExpansion":true}}},"name":"Untitled Pivot Table","widgetKey":"pivot-table"},"2":{"switchedTo":"plotly-clustered-column-chart","mapping":{"xAxis":["[Currency].[Currency].[Currency]"],"values":["[Measures].[pnl.FOREX]"],"secondaryValues":[],"splitBy":["[Booking].[Desk].[LegalEntity]","ALL_MEASURES"],"horizontalSubplots":[],"verticalSubplots":[]},"query":{"mdx":"SELECT NON EMPTY Crossjoin(Hierarchize(DrilldownLevel([Currency].[Currency])), Hierarchize(DrilldownLevel([Booking].[Desk].[ALL].[AllMember]))) ON ROWS, NON EMPTY [Measures].[pnl.FOREX] ON COLUMNS FROM [EquityDerivativesCube]","updateMode":"once"},"filters":[],"queryContext":[],"serverKey":"my-server","name":"Untitled Chart","widgetKey":"plotly-line-chart"}},"queryContext":[]}},"pagesOrder":["p-0"],"filters":[],"queryContext":[]}",
"content": "{"pages":{"p-0":{"layout":{"children":[{"leafKey":"2"},{"leafKey":"1"}],"direction":"row"},"name":"Page 1","filters":[],"content":{"1":{"serverUrl":"","mdx":"SELECT NON EMPTY Crossjoin(Hierarchize(DrilldownLevel([Geography].[City].[ALL].[AllMember])), Hierarchize(DrilldownLevel([Currency].[Currency].[ALL].[AllMember]))) ON ROWS, NON EMPTY [Measures].[contributors.COUNT] ON COLUMNS FROM [foo] CELL PROPERTIES VALUE, FORMATTED_VALUE, BACK_COLOR, FORE_COLOR, FONT_FLAGS","contextValues":{"mdx.hiddengrandtotals":"1"},"updateMode":"once","ranges":{"row":{"chunkSize":2000,"thresholdPercentage":0.1},"column":{"chunkSize":50,"thresholdPercentage":0.2}},"configuration":{"tabular":{"pinnedHeaderSelector":"member","sortingMode":"non-breaking","addButtonFilter":"numeric","cellRenderers":["tree-layout"],"statisticsShown":true,"columnsGroups":[{"captionProducer":"firstColumn","cellFactory":"kpi-status","selector":"kpi-status"},{"captionProducer":"firstColumn","cellFactory":"lookup","selector":"lookup"},{"captionProducer":"expiry","cellFactory":"expiry","selector":"kpi-expiry"},{"captionProducer":"columnMerge","cellFactory":{"args":{},"key":"treeCells"},"selector":"member"}],"hideAddButton":true,"defaultOptions":{},"expansion":{"automaticExpansion":true}}},"name":"Untitled Pivot Table","widgetKey":"pivot-table"},"2":{"switchedTo":"plotly-clustered-column-chart","mapping":{"xAxis":["[Currency].[Currency].[Currency]"],"values":["[Measures].[pnl.FOREX]"],"secondaryValues":[],"splitBy":["[Booking].[Desk].[LegalEntity]","ALL_MEASURES"],"horizontalSubplots":[],"verticalSubplots":[]},"query":{"mdx":"SELECT NON EMPTY Crossjoin(Hierarchize(DrilldownLevel([Currency].[Currency])), Hierarchize(DrilldownLevel([Booking].[Desk].[ALL].[AllMember]))) ON ROWS, NON EMPTY [Measures].[pnl.FOREX] ON COLUMNS FROM [EquityDerivativesCube]","updateMode":"once"},"filters":[],"queryContext":[],"serverKey":"my-server","name":"Untitled Chart","widgetKey":"plotly-line-chart","areFiltersDrivenByMdx":true}},"queryContext":[]}},"pagesOrder":["p-0"],"filters":[],"queryContext":[]}",
"isDirectory": false,
"lastEditor": "admin",
"owners": [
Expand Down

0 comments on commit 033e322

Please sign in to comment.