mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 12:12:15 +01:00
change e2e tests to use organization default values for money formatting
This commit is contained in:
@@ -27,9 +27,11 @@ test('test that organization billable rate can be updated with all existing time
|
|||||||
.getByLabel('Organization Billable Rate')
|
.getByLabel('Organization Billable Rate')
|
||||||
.fill(newBillableRate.toString());
|
.fill(newBillableRate.toString());
|
||||||
await page
|
await page
|
||||||
.locator('button')
|
.locator('form')
|
||||||
.filter({ hasText: /^Save$/ })
|
.filter({ hasText: 'Organization Billable' })
|
||||||
|
.getByRole('button')
|
||||||
.click();
|
.click();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page
|
page
|
||||||
.getByRole('button', { name: 'Yes, update existing time entries' })
|
.getByRole('button', { name: 'Yes, update existing time entries' })
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { expect, Page } from '@playwright/test';
|
import { expect, Page } from '@playwright/test';
|
||||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||||
import { test } from '../playwright/fixtures';
|
import { test } from '../playwright/fixtures';
|
||||||
import { formatCents, getOrganizationCurrencySymbol } from '../resources/js/packages/ui/src/utils/money';
|
import { formatCentsWithOrganizationDefaults } from './utils/money';
|
||||||
import type { CurrencyFormat } from '../resources/js/packages/ui/src/utils/money';
|
import type { CurrencyFormat } from '../resources/js/packages/ui/src/utils/money';
|
||||||
|
import { NumberFormat } from '@/packages/ui/src/utils/number';
|
||||||
|
|
||||||
async function goToProjectsOverview(page: Page) {
|
async function goToProjectsOverview(page: Page) {
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/projects');
|
||||||
@@ -62,12 +63,6 @@ test('test that updating project member billable rate works for existing time en
|
|||||||
page
|
page
|
||||||
.getByRole('row')
|
.getByRole('row')
|
||||||
.first()
|
.first()
|
||||||
.getByText(formatCents(
|
.getByText(formatCentsWithOrganizationDefaults(newBillableRate * 100))
|
||||||
newBillableRate * 100,
|
|
||||||
'EUR',
|
|
||||||
'symbol-before' as CurrencyFormat,
|
|
||||||
'€',
|
|
||||||
'space-point'
|
|
||||||
))
|
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { expect, Page } from '@playwright/test';
|
import { expect, Page } from '@playwright/test';
|
||||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
||||||
import { test } from '../playwright/fixtures';
|
import { test } from '../playwright/fixtures';
|
||||||
import { formatCents, getOrganizationCurrencySymbol } from '../resources/js/packages/ui/src/utils/money';
|
import { formatCentsWithOrganizationDefaults } from './utils/money';
|
||||||
import type { CurrencyFormat } from '../resources/js/packages/ui/src/utils/money';
|
import type { CurrencyFormat } from '../resources/js/packages/ui/src/utils/money';
|
||||||
|
|
||||||
async function goToProjectsOverview(page: Page) {
|
async function goToProjectsOverview(page: Page) {
|
||||||
@@ -132,13 +132,7 @@ test('test that updating billable rate works with existing time entries', async
|
|||||||
page
|
page
|
||||||
.getByRole('row')
|
.getByRole('row')
|
||||||
.first()
|
.first()
|
||||||
.getByText(formatCents(
|
.getByText(formatCentsWithOrganizationDefaults(newBillableRate * 100))
|
||||||
newBillableRate * 100,
|
|
||||||
'EUR',
|
|
||||||
'symbol-before' as CurrencyFormat,
|
|
||||||
'€',
|
|
||||||
'space-point'
|
|
||||||
))
|
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
17
e2e/utils/money.ts
Normal file
17
e2e/utils/money.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { formatCents } from '../../resources/js/packages/ui/src/utils/money';
|
||||||
|
import type { CurrencyFormat } from '../../resources/js/packages/ui/src/utils/money';
|
||||||
|
import { NumberFormat } from '../../resources/js/packages/ui/src/utils/number';
|
||||||
|
|
||||||
|
export function formatCentsWithOrganizationDefaults(
|
||||||
|
cents: number,
|
||||||
|
currencyCode: string = 'EUR',
|
||||||
|
currencySymbol: string = '€'
|
||||||
|
): string {
|
||||||
|
return formatCents(
|
||||||
|
cents,
|
||||||
|
currencyCode,
|
||||||
|
'iso-code-after-with-space' as CurrencyFormat,
|
||||||
|
currencySymbol,
|
||||||
|
'point-comma' as NumberFormat
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user