diff --git a/.changeset/chilly-buttons-sell.md b/.changeset/chilly-buttons-sell.md new file mode 100644 index 000000000..35975ac6e --- /dev/null +++ b/.changeset/chilly-buttons-sell.md @@ -0,0 +1,5 @@ +--- +'renterd': patch +--- + +Fixed an issue where network averages shown on pinned field tips did not follow the currency display preference. diff --git a/.changeset/shiny-phones-burn.md b/.changeset/shiny-phones-burn.md new file mode 100644 index 000000000..3adeca3f9 --- /dev/null +++ b/.changeset/shiny-phones-burn.md @@ -0,0 +1,5 @@ +--- +'@siafoundation/design-system': patch +--- + +Fiat fields now show averages and suggestions according to the currency display preference. diff --git a/apps/hostd/contexts/config/types.ts b/apps/hostd/contexts/config/types.ts index cea56f7ee..0a2292f11 100644 --- a/apps/hostd/contexts/config/types.ts +++ b/apps/hostd/contexts/config/types.ts @@ -1,5 +1,5 @@ import { DNSProvider } from '@siafoundation/hostd-types' -import { SiaCentralCurrency } from '@siafoundation/sia-central-types' +import { CurrencyId } from '@siafoundation/react-core' import BigNumber from 'bignumber.js' export type ConfigViewMode = 'basic' | 'advanced' @@ -29,7 +29,7 @@ export const dnsProviderOptions: { value: DNSProvider; label: string }[] = [ ] export const defaultValuesSettingsPinned = { - pinnedCurrency: '' as SiaCentralCurrency | '', + pinnedCurrency: '' as CurrencyId | '', pinnedThreshold: new BigNumber(0), shouldPinStoragePrice: false, storagePricePinned: new BigNumber(0), diff --git a/apps/renterd-e2e/src/fixtures/beforeTest.ts b/apps/renterd-e2e/src/fixtures/beforeTest.ts index 452fe657e..e8c9287fc 100644 --- a/apps/renterd-e2e/src/fixtures/beforeTest.ts +++ b/apps/renterd-e2e/src/fixtures/beforeTest.ts @@ -5,6 +5,7 @@ import { configResetAllSettings } from './configResetAllSettings' import { setViewMode } from './configViewMode' import { Page } from 'playwright' import { mockApiSiaScanExchangeRates } from './siascan' +import { setCurrencyDisplay } from './preferences' export async function beforeTest(page: Page) { await mockApiSiaCentralExchangeRates({ page }) @@ -12,6 +13,7 @@ export async function beforeTest(page: Page) { await login({ page }) // Reset state. + await setCurrencyDisplay(page, 'bothPreferSc') await navigateToConfig({ page }) await configResetAllSettings({ page }) await setViewMode({ page, state: 'basic' }) diff --git a/apps/renterd-e2e/src/fixtures/preferences.ts b/apps/renterd-e2e/src/fixtures/preferences.ts new file mode 100644 index 000000000..8bd7dbcaf --- /dev/null +++ b/apps/renterd-e2e/src/fixtures/preferences.ts @@ -0,0 +1,11 @@ +import { Page } from 'playwright' +import { fillSelectInputByName } from './selectInput' + +export async function setCurrencyDisplay( + page: Page, + display: 'sc' | 'fiat' | 'bothPreferSc' | 'bothPreferFiat' +) { + await page.getByLabel('App preferences').click() + await fillSelectInputByName(page, 'currencyDisplay', display) + await page.getByRole('dialog').getByLabel('close').click() +} diff --git a/apps/renterd-e2e/src/specs/config.spec.ts b/apps/renterd-e2e/src/specs/config.spec.ts index b52bccf84..512220fe6 100644 --- a/apps/renterd-e2e/src/specs/config.spec.ts +++ b/apps/renterd-e2e/src/specs/config.spec.ts @@ -9,6 +9,7 @@ import { import { clearToasts } from '../fixtures/clearToasts' import { clickIfEnabledAndWait, clickIf } from '../fixtures/click' import { beforeTest } from '../fixtures/beforeTest' +import { setCurrencyDisplay } from '../fixtures/preferences' test.beforeEach(async ({ page }) => { await beforeTest(page) @@ -56,6 +57,33 @@ test('basic field change and save behaviour', async ({ page }) => { for (const part of estimateParts) { await expect(page.getByText(part)).toBeVisible() } + + // Tips are displayed in the correct currency. + await expect( + page + .getByTestId('maxStoragePriceTBMonthGroup') + .getByLabel('Network average') + .getByText('360') + ).toBeVisible() + await expect( + page + .getByTestId('maxStoragePriceTBMonthGroup') + .getByLabel('Fit current allowance') + .getByText('300') + ).toBeVisible() + await setCurrencyDisplay(page, 'bothPreferFiat') + await expect( + page + .getByTestId('maxStoragePriceTBMonthGroup') + .getByLabel('Network average') + .getByText('$3.81') + ).toBeVisible() + await expect( + page + .getByTestId('maxStoragePriceTBMonthGroup') + .getByLabel('Fit current allowance') + .getByText('$3.17') + ).toBeVisible() }) test('set max prices to fit current allowance', async ({ page }) => { diff --git a/libs/design-system/src/app/CurrencyDisplaySelector.tsx b/libs/design-system/src/app/CurrencyDisplaySelector.tsx index 5c3951d01..bc5bd17a3 100644 --- a/libs/design-system/src/app/CurrencyDisplaySelector.tsx +++ b/libs/design-system/src/app/CurrencyDisplaySelector.tsx @@ -15,6 +15,8 @@ export function CurrencyDisplaySelector() { return (