-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
245 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,7 +194,6 @@ | |
border-radius: 0 6px 6px 0; | ||
margin: 0 0 0 1px; | ||
} | ||
|
||
} | ||
|
||
::-webkit-color-swatch-wrapper { | ||
|
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
210 changes: 210 additions & 0 deletions
210
rust/perspective-viewer/test/js/column_settings/number_string_format.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,210 @@ | ||
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ | ||
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ | ||
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ | ||
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃ | ||
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃ | ||
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ | ||
// ┃ Copyright (c) 2017, the Perspective Authors. ┃ | ||
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃ | ||
// ┃ This file is part of the Perspective library, distributed under the terms ┃ | ||
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃ | ||
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ | ||
|
||
import { Type } from "@finos/perspective"; | ||
import { | ||
DEFAULT_CONFIG, | ||
PageView, | ||
compareContentsToSnapshot, | ||
} from "@finos/perspective-test"; | ||
import { ColumnSelector } from "@finos/perspective-test/src/js/models/settings_panel"; | ||
import { test, expect } from "@finos/perspective-test"; | ||
import { DataGridPlugin } from "@finos/perspective-test/src/js/models/plugins"; | ||
import { DataGrid } from "@finos/perspective-test/src/js/models/plugins/datagrid"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("/tools/perspective-test/src/html/basic-test.html"); | ||
await page.evaluate(async () => { | ||
while (!window["__TEST_PERSPECTIVE_READY__"]) { | ||
await new Promise((x) => setTimeout(x, 10)); | ||
} | ||
}); | ||
}); | ||
|
||
test("Integer/float styles", async ({ page }) => { | ||
const view = new PageView(page); | ||
await view.restore({ | ||
settings: true, | ||
plugin: "Datagrid", | ||
columns: ["Profit", "Row ID"], | ||
}); | ||
const profit = await view.settingsPanel.activeColumns.getColumnByName( | ||
"Profit" | ||
); | ||
await profit.editBtn.click(); | ||
const styleContainer = view.columnSettingsSidebar.styleTab.container; | ||
await styleContainer.getByText("Fractional Digits").waitFor(); | ||
const rowId = await view.settingsPanel.activeColumns.getColumnByName( | ||
"Row ID" | ||
); | ||
await rowId.editBtn.click(); | ||
await styleContainer | ||
.getByText("Fractional Digits") | ||
.waitFor({ state: "detached" }); | ||
}); | ||
for (const name of ["Significant Digits", "Fractional Digits"]) { | ||
test(`Rounding Increment doesn't send when ${name} is open`, async ({ | ||
page, | ||
}) => { | ||
let view = new PageView(page); | ||
await view.restore({ | ||
settings: true, | ||
plugin: "Datagrid", | ||
columns: ["Profit"], | ||
}); | ||
const profit = await view.settingsPanel.activeColumns.getColumnByName( | ||
"Profit" | ||
); | ||
await profit.editBtn.click(); | ||
const styleContainer = view.columnSettingsSidebar.styleTab.container; | ||
await styleContainer | ||
.locator("#Rounding-Increment-checkbox ~ div > select") | ||
.selectOption("20"); | ||
await styleContainer.getByText(name).click(); | ||
await expect( | ||
styleContainer.locator("#Rounding-Increment-checkbox") | ||
).toBeDisabled(); | ||
let config = await view.save(); | ||
expect(config).toMatchObject({ | ||
column_config: {}, | ||
}); | ||
await styleContainer.getByText(name).click(); | ||
config = await view.save(); | ||
expect(config).toMatchObject({ | ||
column_config: { | ||
Profit: { | ||
number_string_format: { | ||
maximumFractionDigits: 0, | ||
roundingIncrement: 20, | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
} | ||
test("Rounding Priority doesn't send unless Fractional and Significant Digits are open", async ({ | ||
page, | ||
}) => { | ||
const view = new PageView(page); | ||
await view.restore({ | ||
settings: true, | ||
plugin: "Datagrid", | ||
columns: ["Profit"], | ||
}); | ||
const col = await view.settingsPanel.activeColumns.getColumnByName( | ||
"Profit" | ||
); | ||
await col.editBtn.click(); | ||
const styleContainer = view.columnSettingsSidebar.styleTab.container; | ||
await expect( | ||
styleContainer.locator("#Rounding-Priority-checkbox") | ||
).toBeDisabled(); | ||
await styleContainer.getByText("Fractional Digits").click(); | ||
await styleContainer.getByText("Significant Digits").click(); | ||
await expect( | ||
styleContainer.locator("#Rounding-Priority-checkbox") | ||
).toBeEnabled(); | ||
const select = styleContainer.locator( | ||
"#Rounding-Priority-checkbox ~ div > select" | ||
); | ||
await select.scrollIntoViewIfNeeded(); | ||
await select.selectOption("MorePrecision"); | ||
const config = await view.save(); | ||
expect(config).toMatchObject({ | ||
column_config: { | ||
Profit: { | ||
number_string_format: { | ||
roundingPriority: "morePrecision", | ||
}, | ||
}, | ||
}, | ||
}); | ||
await styleContainer.getByText("Fractional Digits").click(); | ||
const config2 = await view.save(); | ||
expect(config2).toMatchObject({ | ||
column_config: {}, | ||
}); | ||
}); | ||
|
||
test("Datagrid integration", async ({ page }) => { | ||
const view = new PageView(page); | ||
const datagrid = new DataGrid(page); | ||
await view.restore({ | ||
plugin: "Datagrid", | ||
columns: ["Profit"], | ||
column_config: { | ||
Profit: { | ||
number_string_format: { | ||
minimumIntegerDigits: 3, | ||
maximumFractionDigits: 0, | ||
roundingIncrement: 50, | ||
roundingMode: "ceil", | ||
notation: "compact", | ||
compactDisplay: "short", | ||
signDisplay: "always", | ||
}, | ||
}, | ||
}, | ||
}); | ||
const decimal = await datagrid.regularTable.table.innerHTML(); | ||
await compareContentsToSnapshot(decimal, [ | ||
"datagrid-integration-decimal.html", | ||
]); | ||
await view.restore({ | ||
plugin: "Datagrid", | ||
columns: ["Profit"], | ||
column_config: { | ||
Profit: { | ||
number_string_format: { | ||
style: "currency", | ||
currency: "USD", | ||
currencySign: "accounting", | ||
}, | ||
}, | ||
}, | ||
}); | ||
const currency = await datagrid.regularTable.table.innerHTML(); | ||
await compareContentsToSnapshot(currency, [ | ||
"datagrid-integration-currency.html", | ||
]); | ||
|
||
await view.restore({ | ||
plugin: "Datagrid", | ||
columns: ["Profit"], | ||
column_config: { | ||
Profit: { | ||
number_string_format: { | ||
style: "unit", | ||
unit: "byte", | ||
}, | ||
}, | ||
}, | ||
}); | ||
const unit = await datagrid.regularTable.table.innerHTML(); | ||
await compareContentsToSnapshot(unit, ["datagrid-integration-unit.html"]); | ||
|
||
await view.restore({ | ||
plugin: "Datagrid", | ||
columns: ["Profit"], | ||
column_config: { | ||
Profit: { | ||
number_string_format: { | ||
style: "percent", | ||
}, | ||
}, | ||
}, | ||
}); | ||
const data = await datagrid.regularTable.table.innerHTML(); | ||
await compareContentsToSnapshot(data, [ | ||
"datagrid-integration-percent.html", | ||
]); | ||
}); |
Binary file not shown.