Skip to content

Commit b4b7a77

Browse files
committed
Update copy and remove language object
1 parent 269f67f commit b4b7a77

File tree

2 files changed

+35
-44
lines changed

2 files changed

+35
-44
lines changed

site/src/pages/UsersPage/UsersPage.test.tsx

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Role } from "api/typesGenerated";
1313
import { Language as ResetPasswordDialogLanguage } from "./ResetPasswordDialog";
1414
import { renderWithAuth } from "testHelpers/renderHelpers";
1515
import { server } from "testHelpers/server";
16-
import { Language as UsersPageLanguage, UsersPage } from "./UsersPage";
16+
import { UsersPage } from "./UsersPage";
1717

1818
const renderPage = () => {
1919
return renderWithAuth(<UsersPage />);
@@ -34,17 +34,14 @@ const suspendUser = async (setupActionSpies: () => void) => {
3434

3535
// Check if the confirm message is displayed
3636
const confirmDialog = await screen.findByRole("dialog");
37-
expect(confirmDialog).toHaveTextContent(
38-
`${UsersPageLanguage.suspendDialogMessagePrefix} ${MockUser.username}?`,
39-
);
4037

4138
// Setup spies to check the actions after
4239
setupActionSpies();
4340

4441
// Click on the "Confirm" button
45-
const confirmButton = await within(confirmDialog).findByText(
46-
UsersPageLanguage.suspendDialogAction,
47-
);
42+
const confirmButton = await within(confirmDialog).findByText("suspend", {
43+
exact: false,
44+
});
4845
await user.click(confirmButton);
4946
};
5047

@@ -93,17 +90,14 @@ const activateUser = async (setupActionSpies: () => void) => {
9390

9491
// Check if the confirm message is displayed
9592
const confirmDialog = screen.getByRole("dialog");
96-
expect(confirmDialog).toHaveTextContent(
97-
`${UsersPageLanguage.activateDialogMessagePrefix} ${SuspendedMockUser.username}?`,
98-
);
9993

10094
// Setup spies to check the actions after
10195
setupActionSpies();
10296

10397
// Click on the "Confirm" button
104-
const confirmButton = within(confirmDialog).getByText(
105-
UsersPageLanguage.activateDialogAction,
106-
);
98+
const confirmButton = within(confirmDialog).getByText("activate", {
99+
exact: false,
100+
});
107101
fireEvent.click(confirmButton);
108102
};
109103

@@ -175,7 +169,7 @@ describe("UsersPage", () => {
175169
});
176170

177171
// Check if the success message is displayed
178-
await screen.findByText("User suspended");
172+
await screen.findByText("Successfully suspended the user.");
179173

180174
// Check if the API was called correctly
181175
expect(API.suspendUser).toBeCalledTimes(1);
@@ -194,7 +188,7 @@ describe("UsersPage", () => {
194188
});
195189

196190
// Check if the error message is displayed
197-
await screen.findByText("Error suspending user");
191+
await screen.findByText("Error suspending user.");
198192

199193
// Check if the API was called correctly
200194
expect(API.suspendUser).toBeCalledTimes(1);
@@ -251,7 +245,7 @@ describe("UsersPage", () => {
251245
});
252246

253247
// Check if the success message is displayed
254-
await screen.findByText("User deleted");
248+
await screen.findByText("Successfully deleted the user.");
255249

256250
// Check if the API was called correctly
257251
expect(API.deleteUser).toBeCalledTimes(1);
@@ -273,7 +267,7 @@ describe("UsersPage", () => {
273267
});
274268

275269
// Check if the error message is displayed
276-
await screen.findByText("Error deleting user");
270+
await screen.findByText("Error deleting user.");
277271

278272
// Check if the API was called correctly
279273
expect(API.deleteUser).toBeCalledTimes(1);
@@ -300,7 +294,7 @@ describe("UsersPage", () => {
300294
});
301295

302296
// Check if the success message is displayed
303-
await screen.findByText("User activated");
297+
await screen.findByText("Successfully activated the user.");
304298

305299
// Check if the API was called correctly
306300
expect(API.activateUser).toBeCalledTimes(1);
@@ -316,7 +310,7 @@ describe("UsersPage", () => {
316310
});
317311

318312
// Check if the error message is displayed
319-
await screen.findByText("Error activating user");
313+
await screen.findByText("Error activating user.");
320314

321315
// Check if the API was called correctly
322316
expect(API.activateUser).toBeCalledTimes(1);
@@ -337,7 +331,7 @@ describe("UsersPage", () => {
337331
});
338332

339333
// Check if the success message is displayed
340-
await screen.findByText("Password reset");
334+
await screen.findByText("Successfully updated the user password.");
341335

342336
// Check if the API was called correctly
343337
expect(API.updateUserPassword).toBeCalledTimes(1);
@@ -356,7 +350,7 @@ describe("UsersPage", () => {
356350
});
357351

358352
// Check if the error message is displayed
359-
await screen.findByText("Error resetting password");
353+
await screen.findByText("Error on resetting the user password.");
360354

361355
// Check if the API was called correctly
362356
expect(API.updateUserPassword).toBeCalledTimes(1);
@@ -405,7 +399,9 @@ describe("UsersPage", () => {
405399
}, MockAuditorRole);
406400

407401
// Check if the error message is displayed
408-
await waitFor(() => expect("Error updating user roles").toBeDefined());
402+
await waitFor(() =>
403+
expect("Error on updating the user roles.").toBeDefined(),
404+
);
409405

410406
// Check if the API was called correctly
411407
const currentRoles = MockUser.roles.map((r) => r.name);

site/src/pages/UsersPage/UsersPage.tsx

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ import { displayError, displaySuccess } from "components/GlobalSnackbar/utils";
3131
import { getErrorMessage } from "api/errors";
3232
import { generateRandomString } from "utils/random";
3333

34-
export const Language = {
35-
suspendDialogTitle: "Suspend user",
36-
suspendDialogAction: "Suspend",
37-
suspendDialogMessagePrefix: "Do you want to suspend the user",
38-
activateDialogTitle: "Activate user",
39-
activateDialogAction: "Activate",
40-
activateDialogMessagePrefix: "Do you want to activate the user",
41-
};
42-
4334
export const UsersPage: FC<{ children?: ReactNode }> = () => {
4435
const queryClient = useQueryClient();
4536
const navigate = useNavigate();
@@ -145,9 +136,11 @@ export const UsersPage: FC<{ children?: ReactNode }> = () => {
145136
userId: user.id,
146137
roles,
147138
});
148-
displaySuccess("User roles updated");
139+
displaySuccess("Successfully updated the user roles.");
149140
} catch (e) {
150-
displayError(getErrorMessage(e, "Error updating user roles"));
141+
displayError(
142+
getErrorMessage(e, "Error on updating the user roles."),
143+
);
151144
}
152145
}}
153146
isUpdatingUserRoles={updateRolesMutation.isLoading}
@@ -179,9 +172,9 @@ export const UsersPage: FC<{ children?: ReactNode }> = () => {
179172
try {
180173
await deleteUserMutation.mutateAsync(confirmDeleteUser!.id);
181174
setConfirmDeleteUser(undefined);
182-
displaySuccess("User deleted");
175+
displaySuccess("Successfully deleted the user.");
183176
} catch (e) {
184-
displayError(getErrorMessage(e, "Error deleting user"));
177+
displayError(getErrorMessage(e, "Error deleting user."));
185178
}
186179
}}
187180
onCancel={() => {
@@ -200,9 +193,9 @@ export const UsersPage: FC<{ children?: ReactNode }> = () => {
200193
try {
201194
await suspendUserMutation.mutateAsync(confirmSuspendUser!.id);
202195
setConfirmSuspendUser(undefined);
203-
displaySuccess("User suspended");
196+
displaySuccess("Successfully suspended the user.");
204197
} catch (e) {
205-
displayError(getErrorMessage(e, "Error suspending user"));
198+
displayError(getErrorMessage(e, "Error suspending user."));
206199
}
207200
}}
208201
onClose={() => {
@@ -221,23 +214,23 @@ export const UsersPage: FC<{ children?: ReactNode }> = () => {
221214
hideCancel={false}
222215
open={confirmActivateUser !== undefined}
223216
confirmLoading={activateUserMutation.isLoading}
224-
title={Language.activateDialogTitle}
225-
confirmText={Language.activateDialogAction}
217+
title="Activate user"
218+
confirmText="Activate"
226219
onConfirm={async () => {
227220
try {
228221
await activateUserMutation.mutateAsync(confirmActivateUser!.id);
229222
setConfirmActivateUser(undefined);
230-
displaySuccess("User activated");
223+
displaySuccess("Successfully activated the user.");
231224
} catch (e) {
232-
displayError(getErrorMessage(e, "Error activating user"));
225+
displayError(getErrorMessage(e, "Error activating user."));
233226
}
234227
}}
235228
onClose={() => {
236229
setConfirmActivateUser(undefined);
237230
}}
238231
description={
239232
<>
240-
{Language.activateDialogMessagePrefix}{" "}
233+
Do you want to activate the user{" "}
241234
<strong>{confirmActivateUser?.username ?? ""}</strong>?
242235
</>
243236
}
@@ -260,9 +253,11 @@ export const UsersPage: FC<{ children?: ReactNode }> = () => {
260253
old_password: "",
261254
});
262255
setConfirmResetPassword(undefined);
263-
displaySuccess("Password reset");
256+
displaySuccess("Successfully updated the user password.");
264257
} catch (e) {
265-
displayError(getErrorMessage(e, "Error resetting password"));
258+
displayError(
259+
getErrorMessage(e, "Error on resetting the user password."),
260+
);
266261
}
267262
}}
268263
/>

0 commit comments

Comments
 (0)