mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-06-15 13:32:43 +01:00
Compare commits
3 Commits
b3785f0aa6
...
3caf7438b5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3caf7438b5 | ||
|
|
d929d31847 | ||
|
|
d7bb36d50f |
@@ -50,6 +50,9 @@ class OrganizationController extends Controller
|
|||||||
if ($request->getName() !== null) {
|
if ($request->getName() !== null) {
|
||||||
$organization->name = $request->getName();
|
$organization->name = $request->getName();
|
||||||
}
|
}
|
||||||
|
if ($request->getCurrency() !== null) {
|
||||||
|
$organization->currency = $request->getCurrency();
|
||||||
|
}
|
||||||
if ($request->getEmployeesCanSeeBillableRates() !== null) {
|
if ($request->getEmployeesCanSeeBillableRates() !== null) {
|
||||||
$organization->employees_can_see_billable_rates = $request->getEmployeesCanSeeBillableRates();
|
$organization->employees_can_see_billable_rates = $request->getEmployeesCanSeeBillableRates();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Enums\NumberFormat;
|
|||||||
use App\Enums\TimeFormat;
|
use App\Enums\TimeFormat;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
|
use App\Rules\CurrencyRule;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +22,7 @@ class OrganizationUpdateRequest extends BaseFormRequest
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string|\Illuminate\Contracts\Validation\Rule>>
|
* @return array<string, array<string|\Illuminate\Contracts\Validation\Rule|\Illuminate\Contracts\Validation\ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
@@ -30,6 +31,10 @@ class OrganizationUpdateRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
'max:255',
|
'max:255',
|
||||||
],
|
],
|
||||||
|
'currency' => [
|
||||||
|
'string',
|
||||||
|
new CurrencyRule,
|
||||||
|
],
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => array_merge(
|
||||||
[
|
[
|
||||||
'nullable',
|
'nullable',
|
||||||
@@ -68,6 +73,11 @@ class OrganizationUpdateRequest extends BaseFormRequest
|
|||||||
return $this->has('name') ? (string) $this->input('name') : null;
|
return $this->has('name') ? (string) $this->input('name') : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCurrency(): ?string
|
||||||
|
{
|
||||||
|
return $this->has('currency') ? (string) $this->input('currency') : null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getNumberFormat(): ?NumberFormat
|
public function getNumberFormat(): ?NumberFormat
|
||||||
{
|
{
|
||||||
return $this->has('number_format') ? NumberFormat::from($this->input('number_format')) : null;
|
return $this->has('number_format') ? NumberFormat::from($this->input('number_format')) : null;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
createRunningTimeEntryWithStartViaApi,
|
createRunningTimeEntryWithStartViaApi,
|
||||||
createTaskViaApi,
|
createTaskViaApi,
|
||||||
createProjectWithClientViaApi,
|
createProjectWithClientViaApi,
|
||||||
updateUserProfileViaWeb,
|
updateUserProfileViaApi,
|
||||||
updateOrganizationSettingViaApi,
|
updateOrganizationSettingViaApi,
|
||||||
} from './utils/api';
|
} from './utils/api';
|
||||||
|
|
||||||
@@ -1803,28 +1803,22 @@ test.describe('Click-Drag Selection to Create', () => {
|
|||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
test.describe('Timezone & Localization', () => {
|
test.describe('Timezone & Localization', () => {
|
||||||
test('week start day: monday shows Mon as first column', async ({ page }) => {
|
test('week start day: monday shows Mon as first column', async ({ page, ctx }) => {
|
||||||
// Navigate to calendar first to load Inertia page props
|
await updateUserProfileViaApi(ctx, { week_start: 'monday' });
|
||||||
await goToCalendar(page);
|
await goToCalendar(page);
|
||||||
await updateUserProfileViaWeb(page, { week_start: 'monday' });
|
|
||||||
await page.reload();
|
|
||||||
await expect(page.locator('.fc')).toBeVisible();
|
await expect(page.locator('.fc')).toBeVisible();
|
||||||
|
|
||||||
const firstHeader = page.locator('.fc-col-header-cell').first();
|
const firstHeader = page.locator('.fc-col-header-cell').first();
|
||||||
await expect(firstHeader).toContainText('Mon');
|
await expect(firstHeader).toContainText('Mon');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('week start day: sunday shows Sun as first column', async ({ page }) => {
|
test('week start day: sunday shows Sun as first column', async ({ page, ctx }) => {
|
||||||
|
await updateUserProfileViaApi(ctx, { week_start: 'sunday' });
|
||||||
await goToCalendar(page);
|
await goToCalendar(page);
|
||||||
await updateUserProfileViaWeb(page, { week_start: 'sunday' });
|
|
||||||
await page.reload();
|
|
||||||
await expect(page.locator('.fc')).toBeVisible();
|
await expect(page.locator('.fc')).toBeVisible();
|
||||||
|
|
||||||
const firstHeader = page.locator('.fc-col-header-cell').first();
|
const firstHeader = page.locator('.fc-col-header-cell').first();
|
||||||
await expect(firstHeader).toContainText('Sun');
|
await expect(firstHeader).toContainText('Sun');
|
||||||
|
|
||||||
// Reset to monday for other tests
|
|
||||||
await updateUserProfileViaWeb(page, { week_start: 'monday' });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('12-hour time format shows AM/PM on slot labels', async ({ page, ctx }) => {
|
test('12-hour time format shows AM/PM on slot labels', async ({ page, ctx }) => {
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ test.describe('Command Palette', () => {
|
|||||||
const newOrgName = 'TestOrg' + Math.floor(Math.random() * 10000);
|
const newOrgName = 'TestOrg' + Math.floor(Math.random() * 10000);
|
||||||
|
|
||||||
// Create a new organization
|
// Create a new organization
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/teams/create');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/organizations/create');
|
||||||
await page.getByLabel('Organization Name').fill(newOrgName);
|
await page.getByLabel('Organization Name').fill(newOrgName);
|
||||||
await page.getByRole('button', { name: 'Create' }).click();
|
await page.getByRole('button', { name: 'Create' }).click();
|
||||||
|
|
||||||
@@ -393,7 +393,7 @@ test.describe('Command Palette', () => {
|
|||||||
const newOrgName = 'GroupTestOrg' + Math.floor(Math.random() * 10000);
|
const newOrgName = 'GroupTestOrg' + Math.floor(Math.random() * 10000);
|
||||||
|
|
||||||
// Create a new organization to ensure we have multiple
|
// Create a new organization to ensure we have multiple
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/teams/create');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/organizations/create');
|
||||||
await page.getByLabel('Organization Name').fill(newOrgName);
|
await page.getByLabel('Organization Name').fill(newOrgName);
|
||||||
await page.getByRole('button', { name: 'Create' }).click();
|
await page.getByRole('button', { name: 'Create' }).click();
|
||||||
await expect(page.getByTestId('dashboard_view')).toBeVisible({ timeout: 10000 });
|
await expect(page.getByTestId('dashboard_view')).toBeVisible({ timeout: 10000 });
|
||||||
|
|||||||
@@ -55,6 +55,33 @@ test('test that organization name can be updated', async ({ page }) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('test that organization currency can be updated', async ({ page }) => {
|
||||||
|
await goToOrganizationSettings(page);
|
||||||
|
await page.getByLabel('Currency', { exact: true }).selectOption('USD');
|
||||||
|
await Promise.all([
|
||||||
|
page.waitForRequest(
|
||||||
|
(request) =>
|
||||||
|
request.url().includes('/api/v1/organizations/') &&
|
||||||
|
request.method() === 'PUT' &&
|
||||||
|
request.postDataJSON().currency === 'USD'
|
||||||
|
),
|
||||||
|
page.waitForResponse(
|
||||||
|
async (response) =>
|
||||||
|
response.url().includes('/api/v1/organizations/') &&
|
||||||
|
response.request().method() === 'PUT' &&
|
||||||
|
response.status() === 200 &&
|
||||||
|
(await response.json()).data.currency === 'USD'
|
||||||
|
),
|
||||||
|
page
|
||||||
|
.locator('form')
|
||||||
|
.filter({ hasText: 'Organization Name' })
|
||||||
|
.getByRole('button', { name: 'Save' })
|
||||||
|
.click(),
|
||||||
|
]);
|
||||||
|
await page.reload();
|
||||||
|
await expect(page.getByLabel('Currency', { exact: true })).toHaveValue('USD');
|
||||||
|
});
|
||||||
|
|
||||||
test('test that organization billable rate can be updated with all existing time entries', async ({
|
test('test that organization billable rate can be updated with all existing time entries', async ({
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
@@ -387,7 +414,7 @@ test('test that format settings persist after page reload', async ({ page }) =>
|
|||||||
|
|
||||||
test.describe('Organization Create, Delete & Switch', () => {
|
test.describe('Organization Create, Delete & Switch', () => {
|
||||||
async function createOrganization(page, name: string) {
|
async function createOrganization(page, name: string) {
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/teams/create');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/organizations/create');
|
||||||
await page.getByLabel('Organization Name').fill(name);
|
await page.getByLabel('Organization Name').fill(name);
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForResponse(
|
page.waitForResponse(
|
||||||
@@ -413,7 +440,7 @@ test.describe('Organization Create, Delete & Switch', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('does not create an organization when the name is empty', async ({ page }) => {
|
test('does not create an organization when the name is empty', async ({ page }) => {
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/teams/create');
|
await page.goto(PLAYWRIGHT_BASE_URL + '/organizations/create');
|
||||||
|
|
||||||
// The form posts to the API, which rejects the empty name with a 422.
|
// The form posts to the API, which rejects the empty name with a 422.
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
@@ -427,8 +454,7 @@ test.describe('Organization Create, Delete & Switch', () => {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Validation failed, so we stay on the create form and never reach a
|
// Validation failed, so we stay on the create form and never reach a
|
||||||
// dashboard. ('/teams/create' redirects to '/organizations/create', so
|
// dashboard. Assert on the form rather than the URL.
|
||||||
// assert on the form rather than the URL.)
|
|
||||||
await expect(page.getByText('Organization Details')).toBeVisible();
|
await expect(page.getByText('Organization Details')).toBeVisible();
|
||||||
await expect(page.getByRole('alert')).toContainText('The name field is required.');
|
await expect(page.getByRole('alert')).toContainText('The name field is required.');
|
||||||
await expect(page.getByLabel('Organization Name')).toHaveAttribute('aria-invalid', 'true');
|
await expect(page.getByLabel('Organization Name')).toHaveAttribute('aria-invalid', 'true');
|
||||||
@@ -505,7 +531,7 @@ test.describe('Organization Create, Delete & Switch', () => {
|
|||||||
|
|
||||||
test.describe('Admin Organization Settings Access', () => {
|
test.describe('Admin Organization Settings Access', () => {
|
||||||
test('admin can see and edit organization settings', async ({ ctx, admin }) => {
|
test('admin can see and edit organization settings', async ({ ctx, admin }) => {
|
||||||
await admin.page.goto(PLAYWRIGHT_BASE_URL + '/teams/' + ctx.orgId);
|
await admin.page.goto(PLAYWRIGHT_BASE_URL + '/organizations/' + ctx.orgId);
|
||||||
|
|
||||||
// Organization Name section is visible
|
// Organization Name section is visible
|
||||||
await expect(
|
await expect(
|
||||||
@@ -542,7 +568,7 @@ test.describe('Admin Organization Settings Access', () => {
|
|||||||
|
|
||||||
test.describe('Employee Organization Settings Restrictions', () => {
|
test.describe('Employee Organization Settings Restrictions', () => {
|
||||||
test('employee can see org name but not editable settings', async ({ ctx, employee }) => {
|
test('employee can see org name but not editable settings', async ({ ctx, employee }) => {
|
||||||
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/teams/' + ctx.orgId);
|
await employee.page.goto(PLAYWRIGHT_BASE_URL + '/organizations/' + ctx.orgId);
|
||||||
|
|
||||||
// Organization Name section is visible (but inputs are disabled)
|
// Organization Name section is visible (but inputs are disabled)
|
||||||
await expect(
|
await expect(
|
||||||
|
|||||||
@@ -641,10 +641,13 @@ export async function updateOrganizationCurrencyViaWeb(
|
|||||||
const xsrfCookie = cookies.find((c) => c.name === 'XSRF-TOKEN');
|
const xsrfCookie = cookies.find((c) => c.name === 'XSRF-TOKEN');
|
||||||
const xsrfToken = xsrfCookie ? decodeURIComponent(xsrfCookie.value) : '';
|
const xsrfToken = xsrfCookie ? decodeURIComponent(xsrfCookie.value) : '';
|
||||||
|
|
||||||
const response = await page.request.put(`${PLAYWRIGHT_BASE_URL}/teams/${ctx.orgId}`, {
|
const response = await page.request.put(
|
||||||
headers: { 'X-XSRF-TOKEN': xsrfToken },
|
`${PLAYWRIGHT_BASE_URL}/api/v1/organizations/${ctx.orgId}`,
|
||||||
data: { name, currency },
|
{
|
||||||
});
|
headers: { 'X-XSRF-TOKEN': xsrfToken },
|
||||||
|
data: { name, currency },
|
||||||
|
}
|
||||||
|
);
|
||||||
expect(response.status()).toBe(200);
|
expect(response.status()).toBe(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -801,53 +804,23 @@ export async function getCurrentUserViaApi(ctx: TestContext) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateUserProfileViaWeb(
|
export async function updateUserProfileViaApi(
|
||||||
page: Page,
|
ctx: TestContext,
|
||||||
settings: { timezone?: string; week_start?: string }
|
settings: { timezone?: string; week_start?: string }
|
||||||
) {
|
) {
|
||||||
// Read user info from Inertia's data-page attribute on the root element
|
const user = await getCurrentUserViaApi(ctx);
|
||||||
const userInfo = await page.evaluate(() => {
|
|
||||||
// Try Inertia's data-page attribute (stores initial page props as JSON)
|
|
||||||
const appEl = document.getElementById('app');
|
|
||||||
if (appEl) {
|
|
||||||
const dataPage = appEl.getAttribute('data-page');
|
|
||||||
if (dataPage) {
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(dataPage);
|
|
||||||
const user = parsed?.props?.auth?.user;
|
|
||||||
if (user) {
|
|
||||||
return {
|
|
||||||
name: user.name,
|
|
||||||
email: user.email,
|
|
||||||
timezone: user.timezone,
|
|
||||||
week_start: user.week_start,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// JSON parse failed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
if (!userInfo) throw new Error('Could not read user info from Inertia data-page attribute');
|
|
||||||
|
|
||||||
const cookies = await page.context().cookies();
|
// Only send the fields under test; the endpoint leaves omitted fields untouched.
|
||||||
const xsrfCookie = cookies.find((c) => c.name === 'XSRF-TOKEN');
|
const data: Record<string, string> = {};
|
||||||
const xsrfToken = xsrfCookie ? decodeURIComponent(xsrfCookie.value) : '';
|
if (settings.timezone !== undefined) {
|
||||||
|
data.timezone = settings.timezone;
|
||||||
|
}
|
||||||
|
if (settings.week_start !== undefined) {
|
||||||
|
data.week_start = settings.week_start;
|
||||||
|
}
|
||||||
|
|
||||||
const response = await page.request.put(`${PLAYWRIGHT_BASE_URL}/user/profile-information`, {
|
const response = await ctx.request.put(`${PLAYWRIGHT_BASE_URL}/api/v1/users/${user.id}`, {
|
||||||
headers: {
|
data,
|
||||||
'X-XSRF-TOKEN': xsrfToken,
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Accept: 'application/json',
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
name: userInfo.name,
|
|
||||||
email: userInfo.email,
|
|
||||||
timezone: settings.timezone ?? userInfo.timezone,
|
|
||||||
week_start: settings.week_start ?? userInfo.week_start,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
expect(response.status()).toBe(200);
|
expect(response.status()).toBe(200);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ const switchToTeam = (organization: Organization) => {
|
|||||||
|
|
||||||
<DropdownMenuItem as-child>
|
<DropdownMenuItem as-child>
|
||||||
<Link
|
<Link
|
||||||
:href="route('teams.show', page.props.auth.user.current_team.id)"
|
:href="route('organizations.show', page.props.auth.user.current_team.id)"
|
||||||
class="inline-flex items-center gap-2.5 w-full">
|
class="inline-flex items-center gap-2.5 w-full">
|
||||||
<Cog6ToothIcon class="w-5 h-5 text-icon-default" />
|
<Cog6ToothIcon class="w-5 h-5 text-icon-default" />
|
||||||
<span>Organization Settings</span>
|
<span>Organization Settings</span>
|
||||||
@@ -74,7 +74,7 @@ const switchToTeam = (organization: Organization) => {
|
|||||||
|
|
||||||
<DropdownMenuItem as-child>
|
<DropdownMenuItem as-child>
|
||||||
<Link
|
<Link
|
||||||
:href="route('teams.create')"
|
:href="route('organizations.create')"
|
||||||
class="inline-flex items-center gap-2.5 w-full">
|
class="inline-flex items-center gap-2.5 w-full">
|
||||||
<PlusCircleIcon class="w-5 h-5 text-icon-default" />
|
<PlusCircleIcon class="w-5 h-5 text-icon-default" />
|
||||||
<span>Create new organization</span>
|
<span>Create new organization</span>
|
||||||
|
|||||||
@@ -280,10 +280,15 @@ const page = usePage<{
|
|||||||
v-if="canUpdateOrganization()"
|
v-if="canUpdateOrganization()"
|
||||||
title="Settings"
|
title="Settings"
|
||||||
:icon="Cog6ToothIcon"
|
:icon="Cog6ToothIcon"
|
||||||
:href="route('teams.show', page.props.auth.user.current_team.id)"
|
:href="
|
||||||
|
route(
|
||||||
|
'organizations.show',
|
||||||
|
page.props.auth.user.current_team.id
|
||||||
|
)
|
||||||
|
"
|
||||||
:current="
|
:current="
|
||||||
route().current(
|
route().current(
|
||||||
'teams.show',
|
'organizations.show',
|
||||||
page.props.auth.user.current_team.id
|
page.props.auth.user.current_team.id
|
||||||
)
|
)
|
||||||
"></NavigationSidebarItem>
|
"></NavigationSidebarItem>
|
||||||
|
|||||||
@@ -330,6 +330,7 @@ const OrganizationResource = z
|
|||||||
const OrganizationUpdateRequest = z
|
const OrganizationUpdateRequest = z
|
||||||
.object({
|
.object({
|
||||||
name: z.string().max(255),
|
name: z.string().max(255),
|
||||||
|
currency: z.string(),
|
||||||
billable_rate: z.union([z.number(), z.null()]),
|
billable_rate: z.union([z.number(), z.null()]),
|
||||||
employees_can_see_billable_rates: z.boolean(),
|
employees_can_see_billable_rates: z.boolean(),
|
||||||
employees_can_manage_tasks: z.boolean(),
|
employees_can_manage_tasks: z.boolean(),
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ export function createNavigationCommands(
|
|||||||
icon: Cog6ToothIcon,
|
icon: Cog6ToothIcon,
|
||||||
keywords: ['settings', 'organization', 'configuration'],
|
keywords: ['settings', 'organization', 'configuration'],
|
||||||
group: 'navigation',
|
group: 'navigation',
|
||||||
action: () => navigate('teams.show', { team: currentTeamId() }),
|
action: () => navigate('organizations.show', { organizationId: currentTeamId() }),
|
||||||
permission: permissions.canUpdateOrganization,
|
permission: permissions.canUpdateOrganization,
|
||||||
priority: GROUP_PRIORITIES.navigation - 3,
|
priority: GROUP_PRIORITIES.navigation - 3,
|
||||||
},
|
},
|
||||||
|
|||||||
7
resources/js/ziggy.d.ts
vendored
7
resources/js/ziggy.d.ts
vendored
@@ -114,6 +114,13 @@ declare module 'ziggy-js' {
|
|||||||
'other-browser-sessions.destroy': [];
|
'other-browser-sessions.destroy': [];
|
||||||
'current-user-photo.destroy': [];
|
'current-user-photo.destroy': [];
|
||||||
'current-user.destroy': [];
|
'current-user.destroy': [];
|
||||||
|
'organizations.create': [];
|
||||||
|
'organizations.show': [
|
||||||
|
{
|
||||||
|
'name': 'organizationId';
|
||||||
|
'required': true;
|
||||||
|
},
|
||||||
|
];
|
||||||
'teams.create': [];
|
'teams.create': [];
|
||||||
'teams.store': [];
|
'teams.store': [];
|
||||||
'teams.show': [
|
'teams.show': [
|
||||||
|
|||||||
@@ -197,6 +197,12 @@ const Ziggy = {
|
|||||||
'methods': ['DELETE'],
|
'methods': ['DELETE'],
|
||||||
},
|
},
|
||||||
'current-user.destroy': { 'uri': 'user', 'methods': ['DELETE'] },
|
'current-user.destroy': { 'uri': 'user', 'methods': ['DELETE'] },
|
||||||
|
'organizations.create': { 'uri': 'organizations/create', 'methods': ['GET', 'HEAD'] },
|
||||||
|
'organizations.show': {
|
||||||
|
'uri': 'organizations/{organizationId}',
|
||||||
|
'methods': ['GET', 'HEAD'],
|
||||||
|
'parameters': ['organizationId'],
|
||||||
|
},
|
||||||
'teams.create': { 'uri': 'teams/create', 'methods': ['GET', 'HEAD'] },
|
'teams.create': { 'uri': 'teams/create', 'methods': ['GET', 'HEAD'] },
|
||||||
'teams.store': { 'uri': 'teams', 'methods': ['POST'] },
|
'teams.store': { 'uri': 'teams', 'methods': ['POST'] },
|
||||||
'teams.show': {
|
'teams.show': {
|
||||||
|
|||||||
@@ -382,6 +382,58 @@ class OrganizationEndpointTest extends ApiEndpointTestAbstract
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_update_endpoint_can_update_the_currency_of_the_organization(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'organizations:update',
|
||||||
|
]);
|
||||||
|
$this->assertBillableRateServiceIsUnused();
|
||||||
|
$data->organization->currency = 'EUR';
|
||||||
|
$data->organization->save();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->putJson(route('api.v1.organizations.update', [$data->organization->getKey()]), [
|
||||||
|
'name' => $data->organization->name,
|
||||||
|
'currency' => 'USD',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertJsonPath('data.currency', 'USD');
|
||||||
|
$this->assertDatabaseHas(Organization::class, [
|
||||||
|
'id' => $data->organization->getKey(),
|
||||||
|
'currency' => 'USD',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_update_endpoint_fails_if_currency_is_invalid(): void
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
$data = $this->createUserWithPermission([
|
||||||
|
'organizations:update',
|
||||||
|
]);
|
||||||
|
$this->assertBillableRateServiceIsUnused();
|
||||||
|
$data->organization->currency = 'EUR';
|
||||||
|
$data->organization->save();
|
||||||
|
Passport::actingAs($data->user);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
$response = $this->putJson(route('api.v1.organizations.update', [$data->organization->getKey()]), [
|
||||||
|
'name' => $data->organization->name,
|
||||||
|
'currency' => 'NOT_A_CURRENCY',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
$response->assertStatus(422);
|
||||||
|
$response->assertJsonValidationErrors(['currency']);
|
||||||
|
$this->assertDatabaseHas(Organization::class, [
|
||||||
|
'id' => $data->organization->getKey(),
|
||||||
|
'currency' => 'EUR',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_delete_endpoint_if_user_does_not_have_permission(): void
|
public function test_delete_endpoint_if_user_does_not_have_permission(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|||||||
Reference in New Issue
Block a user