[] = [
{
id: 'firstName',
@@ -113,21 +109,31 @@ export default function Users() {
{t('dashboard_users_download_info')}
{t('dashboard_users_download_id')}
-
- {columns && (
- ({
- ...column,
- label: t(column.label),
- }))}
- items={dataUsers || []}
- totalItems={dataUsers?.length || 0}
- className="mt-4"
- />
+
+ {isLoadingUsers || isLoadingLicenceDetail ? (
+
+ ) : (
+ <>
+
+ ({
+ ...column,
+ label: t(column.label),
+ }))}
+ items={dataUsers || []}
+ totalItems={dataUsers?.length || 0}
+ className="mt-4"
+ />
+ >
)}
);
diff --git a/packages/manager/apps/web-office/src/pages/dashboard/users/__test__/Users.spec.tsx b/packages/manager/apps/web-office/src/pages/dashboard/users/__test__/Users.spec.tsx
index 9ef80afb3336..72a5785ba22f 100644
--- a/packages/manager/apps/web-office/src/pages/dashboard/users/__test__/Users.spec.tsx
+++ b/packages/manager/apps/web-office/src/pages/dashboard/users/__test__/Users.spec.tsx
@@ -2,21 +2,54 @@ import React from 'react';
import { describe, expect, vi } from 'vitest';
import Users from '../Users';
import { render } from '@/utils/test.provider';
-import usersTranslation from '@/public/translations/dashboard/users/Messages_fr_FR.json';
-import { licensesMock, usersMock } from '@/api/_mock_';
+import {
+ licensesMock,
+ licensesPrepaidExpandedMock,
+ usersMock,
+} from '@/api/_mock_';
+
+const hoistedMock = vi.hoisted(() => ({
+ useOfficeUsers: vi.fn(),
+ useOfficeLicenseDetail: vi.fn(),
+}));
+
+vi.mock('@/hooks', async (importActual) => {
+ const actual = await importActual();
+ return {
+ ...actual,
+ useOfficeUsers: hoistedMock.useOfficeUsers,
+ useOfficeLicenseDetail: hoistedMock.useOfficeLicenseDetail,
+ };
+});
describe('Users page', () => {
- vi.mock('@/hooks', () => {
- return {
- useOfficeUsers: vi.fn(() => usersMock),
- useOfficeLicenseDetail: vi.fn(() => licensesMock),
- };
+ it('Page for payAsYouGo', () => {
+ hoistedMock.useOfficeLicenseDetail.mockReturnValue({
+ data: licensesMock[0],
+ isLoading: false,
+ });
+ hoistedMock.useOfficeUsers.mockReturnValue({
+ data: usersMock,
+ isLoading: false,
+ });
+
+ const { getByTestId } = render();
+ const orderButton = getByTestId('user-or-licenses-order-button');
+ expect(orderButton).toHaveAttribute('label', 'Ajouter un utilisateur');
});
- it('Page should display correctly', async () => {
- const { findByText } = render();
- expect(
- await findByText(usersTranslation.dashboard_users_download_info),
- ).toBeVisible();
+ it('Page for prepaid', () => {
+ hoistedMock.useOfficeLicenseDetail.mockReturnValue({
+ data: licensesPrepaidExpandedMock[0],
+ isLoading: false,
+ });
+ hoistedMock.useOfficeUsers.mockReturnValue({
+ data: licensesPrepaidExpandedMock[0],
+ isLoading: false,
+ });
+
+ const { getByTestId } = render();
+ const orderButton = getByTestId('user-or-licenses-order-button');
+ expect(orderButton).toHaveAttribute('label', 'Commander plus de licences');
});
});
diff --git a/packages/manager/apps/web-office/src/utils/test.setup.tsx b/packages/manager/apps/web-office/src/utils/test.setup.tsx
index 21c7021685a7..9b891afd92a2 100644
--- a/packages/manager/apps/web-office/src/utils/test.setup.tsx
+++ b/packages/manager/apps/web-office/src/utils/test.setup.tsx
@@ -54,7 +54,9 @@ vi.mock('@/api/license', async (importActual) => {
}),
getOfficeLicenseDetails: vi.fn((serviceName) => {
return Promise.resolve(
- licensesMock.find((license) => license.serviceName === serviceName),
+ [...licensesMock, ...licensesPrepaidExpandedMock].find(
+ (license) => license.serviceName === serviceName,
+ ),
);
}),
getOfficePrepaidLicenses: vi.fn(() => {