8000 chore: remove i18next by aslilac · Pull Request #9608 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: remove i18next #9608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 67 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
0b0725c
remove i18next packages
aslilac Sep 8, 2023
6a585bc
remove provider
aslilac Sep 8, 2023
7e63f30
refactor `DeleteDialog`
aslilac Sep 8, 2023
6636ed7
refactor `Expander`
aslilac Sep 8, 2023
202c9fa
refactor `IconField`
aslilac Sep 8, 2023
18c04b4
refactor `AgentOutdatedTooltip`
aslilac Sep 8, 2023
9d93117
refactor `AgentRowPreview`
aslilac Sep 8, 2023
8d79655
refactor `AgentStatus`
aslilac Sep 8, 2023
9164286
refactor `ShareIcon`
aslilac Sep 8, 2023
7ff932b
refactor `UserAutocomplete`
aslilac Sep 8, 2023
9ae7372
remove stale comment
aslilac Sep 8, 2023
6678f40
refactor `AuditPageView`
aslilac Sep 8, 2023
fc043ed
refactor `AuditPaywall`
aslilac Sep 8, 2023
3eb8d69
`AuditLogRow`
aslilac Sep 8, 2023
8000
b57d555
refactor `AuditLogDescription`
aslilac Sep 8, 2023
b27f918
refactor `BuildAuditDescription`
aslilac Sep 8, 2023
f0a9296
refactor `CreateTemplateForm`
aslilac Sep 8, 2023
61fdfe5
refactor `CreateTemplatePage`
aslilac Sep 8, 2023
f769e69
refactor `TemplateUpload`
aslilac Sep 8, 2023
3127d57
refactor `CreateTokenForm`
aslilac Sep 8, 2023
9c76a7b
refactor `CreateTokenPage`
aslilac Sep 8, 2023
16a3f21
refactor `CreateWorkspacePageView`
aslilac Sep 8, 2023
026ddaa
refactor `AppearanceSettingsPageView`
aslilac Sep 8, 2023
5784b91
refactor `SettingsGroupPageView`
aslilac Sep 8, 2023
f5cb010
refactor utils.ts
aslilac Sep 8, 2023
b1d8c5c
refactor `VersionRow`
aslilac Sep 8, 2023
b448bb0
refactor `TemplateSettingsForm`
aslilac Sep 8, 2023
39438e1
refactor `LoginPage` and `SignInForm`
aslilac Sep 8, 2023
adbb256
refactor `StarterTemplatePageView`
aslilac Sep 8, 2023
0f181e8
refactor `StarterTemplatesPage`
aslilac Sep 8, 2023
5800e18
refactor `Workspace`
aslilac Sep 8, 2023
7278c0d
refactor `EditRolesButton`
aslilac Sep 8, 2023
78b7cc0
refactor `TemplateScheduleForm`
aslilac Sep 8, 2023
29652ea
refactor `TemplateVariableField`
aslilac Sep 8, 2023
337c21d
refactor `EmptyTemplates`
aslilac Sep 8, 2023
89867ff
refactor `TemplateVariablesPage`
aslilac Sep 8, 2023
5e71acb
refactor `userSecuritySettingsXService`
aslilac Sep 8, 2023
46cddf5
refactor `ConfirmDeleteDialog`
aslilac Sep 8, 2023
633e574
refactor workspace.tsx
aslilac Sep 8, 2023
76c78ea
refactor `WorkspaceDeletedBanner`
aslilac Sep 8, 2023
90165f7
refactor `TokensPage`
aslilac Sep 8, 2023
4dde5f2
refactor formHelpers.tsx
aslilac Sep 8, 2023
61e7571
refactor `UsersTableBody`
aslilac Sep 8, 2023
106a6fe
refactor `TemplateSettingsPage`
aslilac Sep 8, 2023
b2d644f
refactor `AutostopRequirementHelperText`
aslilac Sep 8, 2023
441803b
refactor `TemplateVariablesForm`
aslilac Sep 8, 2023
8ec0f96
refactor `TemplateVersionPage`
aslilac Sep 8, 2023
72abadb
remove stale comment
aslilac Sep 8, 2023
ef93712
refactor `TokensPageView`
aslilac Sep 8, 2023
32252f3
refactor `BuildRow`
aslilac Sep 8, 2023
66da852
refactor `WorkspaceReadyPage`
aslilac Sep 8, 2023
87a1654
refactor `WorkspacesTable`
aslilac Sep 8, 2023
2ab4c40
refactor `useValidationSchemaForRichParameters`
aslilac Sep 8, 2023
9a4ba70
refactor `UpdateBuildParametersDialog`
aslilac Sep 8, 2023
1440b5a
refactor `WorkspaceSchedulePage`
aslilac Sep 8, 2023
d1a2905
refactor `WorkspaceParametersForm`
aslilac Sep 8, 2023
622ce4a
refactor `WorkspaceSettingsPageView`
aslilac Sep 8, 2023
bd51244
refactor `CreateWorkspacePage` test
aslilac Sep 8, 2023
f1c5909
refactor all the remaining tests
aslilac Sep 8, 2023
4e26e98
refactor `TTLHelperText`
aslilac Sep 8, 2023
1ee252d
stragglers
aslilac Sep 8, 2023
a85cd71
linting
aslilac Sep 8, 2023
4a7b127
fix tests
aslilac Sep 8, 2023
366d513
remove remaining translation files
aslilac Sep 8, 2023
7359de0
fix storybook build
aslilac Sep 8, 2023
45c3335
Merge branch 'main' into axe-i18next
aslilac Sep 11, 2023
9216208
fix a couple stories
aslilac Sep 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor all the remaining tests
  • Loading branch information
aslilac committed Sep 8, 2023
commit f1c5909b21063497959d912c513fca4c9c8dab0a
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import {
} from "testHelpers/renderHelpers";
import { TemplateScheduleFormValues, getValidationSchema } from "./formHelpers";
import TemplateSchedulePage from "./TemplateSchedulePage";
import i18next from "i18next";

const { t } = i18next;

const validFormValues: TemplateScheduleFormValues = {
default_ttl_ms: 1,
Expand Down Expand Up @@ -55,17 +52,15 @@ const fillAndSubmitForm = async ({
const user = userEvent.setup();

if (default_ttl_ms) {
const defaultTtlLabel = t("defaultTtlLabel", {
ns: "templateSettingsPage",
});
const defaultTtlField = await screen.findByLabelText(defaultTtlLabel);
const defaultTtlField = await screen.findByLabelText(
"Default autostop (hours)",
);
await user.clear(defaultTtlField);
await user.type(defaultTtlField, default_ttl_ms.toString());
}

if (max_ttl_ms) {
const maxTtlLabel = t("maxTtlLabel", { ns: "templateSettingsPage" });
const maxTtlField = await screen.findByLabelText(maxTtlLabel);
const maxTtlField = await screen.findByLabelText("Max lifetime (hours)");
await user.clear(maxTtlField);
await user.type(maxTtlField, max_ttl_ms.toString());
}
Expand Down Expand Up @@ -203,7 +198,7 @@ describe("TemplateSchedulePage", () => {
};
const validate = () => getValidationSchema().validateSync(values);
expect(validate).toThrowError(
t("defaultTTLMaxError", { ns: "templateSettingsPage" }).toString(),
"Please enter a limit that is less than or equal to 720 hours (30 days).",
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
waitForLoaderToBeRemoved,
} from "testHelpers/renderHelpers";
import * as API from "api/api";
import i18next from "i18next";
import TemplateVariablesPage from "./TemplateVariablesPage";
import { Language as FooterFormLanguage } from "components/FormFooter/FormFooter";
import {
Expand All @@ -17,18 +16,12 @@ import {
MockTemplateVersionVariable5,
} from "testHelpers/entities";

const { t } = i18next;

const validFormValues = {
first_variable: "Hello world",
second_variable: "123",
};

const pageTitleText = t("title", { ns: "templateVariablesPage" });

const validationRequiredField = t("validationRequiredVariable", {
ns: "templateVariablesPage",
});
const validationRequiredField = "Variable is required.";

const renderTemplateVariablesPage = async () => {
renderWithTemplateSettingsLayout(<TemplateVariablesPage />, {
Expand All @@ -54,9 +47,6 @@ describe("TemplateVariablesPage", () => {

await renderTemplateVariablesPage();

const element = await screen.findByText(pageTitleText);
expect(element).toBeDefined();

const firstVariable = await screen.findByLabelText(
MockTemplateVersionVariable1.name,
);
Expand Down Expand Up @@ -88,9 +78,6 @@ describe("TemplateVariablesPage", () => {

await renderTemplateVariablesPage();

const element = await screen.findByText(pageTitleText);
expect(element).toBeDefined();

const firstVariable = await screen.findByLabelText(
MockTemplateVersionVariable1.name,
);
Expand Down Expand Up @@ -144,9 +131,6 @@ describe("TemplateVariablesPage", () => {

await renderTemplateVariablesPage();

const element = await screen.findByText(pageTitleText);
expect(element).toBeDefined();

const firstVariable = await screen.findByLabelText(
MockTemplateVersionVariable1.name,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import * as AccountForm from "./AccountForm";
import { renderWithAuth } from "testHelpers/renderHelpers";
import * as AuthXService from "xServices/auth/authXService";
import { AccountPage } from "./AccountPage";
import i18next from "i18next";
import { mockApiError } from "testHelpers/entities";

const { t } = i18next;

const renderPage = () => {
return renderWithAuth(<AccountPage />);
};
Expand Down Expand Up @@ -86,10 +83,7 @@ describe("AccountPage", () => {
const { user } = renderPage();
await fillAndSubmitForm();

const errorText = t("warningsAndErrors.somethingWentWrong", {
ns: "common",
});
const errorMessage = await screen.findByText(errorText);
const errorMessage = await screen.findByText("Something went wrong.");
expect(errorMessage).toBeDefined();
expect(API.updateProfile).toBeCalledTimes(1);
expect(API.updateProfile).toBeCalledWith(user.id, newData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
waitForLoaderToBeRemoved,
} from "../../../testHelpers/renderHelpers";
import { SecurityPage } from "./SecurityPage";
import i18next from "i18next";
import {
MockAuthMethodsWithPasswordType,
mockApiError,
Expand All @@ -15,8 +14,6 @@ import userEvent from "@testing-library/user-event";
import * as SSO from "./SingleSignOnSection";
import { OAuthConversionResponse } from "api/typesGenerated";

const { t } = i18next;

const renderPage = async () => {
const utils = renderWithAuth(<SecurityPage />);
await waitForLoaderToBeRemoved();
Expand Down Expand Up @@ -58,10 +55,7 @@ test("update password successfully", async () => {
const { user } = await renderPage();
fillAndSubmitSecurityForm();

const expectedMessage = t("securityUpdateSuccessMessage", {
ns: "userSettingsPage",
});
const successMessage = await screen.findByText(expectedMessage);
const successMessage = await screen.findByText("Updated password.");
expect(successMessage).toBeDefined();
expect(API.updateUserPassword).toBeCalledTimes(1);
expect(API.updateUserPassword).toBeCalledWith(user.id, newSecurityFormValues);
Expand Down Expand Up @@ -113,10 +107,7 @@ test("update password when submit returns an unknown error", async () => {
const { user } = await renderPage();
fillAndSubmitSecurityForm();

const errorText = t("warningsAndErrors.somethingWentWrong", {
ns: "common",
});
const errorMessage = await screen.findByText(errorText);
const errorMessage = await screen.findByText("Something went wrong.");
expect(errorMessage).toBeDefined();
expect(API.updateUserPassword).toBeCalledTimes(1);
expect(API.updateUserPassword).toBeCalledWith(user.id, newSecurityFormValues);
Expand Down
66 changes: 13 additions & 53 deletions site/src/pages/WorkspacePage/WorkspacePage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import EventSourceMock from "eventsourcemock";
import i18next from "i18next";
import { rest } from "msw";
import {
MockTemplate,
Expand Down Expand Up @@ -34,8 +33,6 @@ import {
import { server } from "../../testHelpers/server";
import { WorkspacePage } from "./WorkspacePage";

const { t } = i18next;

// It renders the workspace page and waits for it be loaded
const renderWorkspacePage = async () => {
jest.spyOn(api, "getTemplate").mockResolvedValueOnce(MockTemplate);
Expand Down Expand Up @@ -114,18 +111,14 @@ describe("WorkspacePage", () => {
// open the workspace action popover so we have access to all available ctas
const trigger = screen.getByTestId("workspace-options-button");
await user.click(trigger);
const buttonText = t("actionButton.delete", { ns: "workspacePage" });

// Click on delete
const button = await screen.findByText(buttonText);
const button = await screen.findByText("Delete");
await user.click(button);

// Get dialog and confirm
const dialog = await screen.findByTestId("dialog");
const labelText = t("deleteDialog.confirmLabel", {
ns: "common",
entity: "workspace",
});
const labelText = "Name of workspace to delete";
const textField = within(dialog).getByLabelText(labelText);
await user.type(textField, MockWorkspace.name);
const confirmButton = within(dialog).getByRole("button", {
Expand All @@ -148,21 +141,15 @@ describe("WorkspacePage", () => {
const startWorkspaceMock = jest
.spyOn(api, "startWorkspace")
.mockImplementation(() => Promise.resolve(MockWorkspaceBuild));
await testButton(
t("actionButton.start", { ns: "workspacePage" }),
startWorkspaceMock,
);
await testButton("Start", startWorkspaceMock);
});

it("requests a stop job when the user presses Stop", async () => {
const stopWorkspaceMock = jest
.spyOn(api, "stopWorkspace")
.mockResolvedValueOnce(MockWorkspaceBuild);

await testButton(
t("actionButton.stop", { ns: "workspacePage" }),
stopWorkspaceMock,
);
await testButton("Stop", stopWorkspaceMock);
});

it("requests a stop when the user presses Restart", async () => {
Expand Down Expand Up @@ -319,66 +306,39 @@ describe("WorkspacePage", () => {
});

it("shows the Stopping status when the workspace is stopping", async () => {
await testStatus(
MockStoppingWorkspace,
t("workspaceStatus.stopping", { ns: "common" }),
);
await testStatus(MockStoppingWorkspace, "Stopping");
});

it("shows the Stopped status when the workspace is stopped", async () => {
await testStatus(
MockStoppedWorkspace,
t("workspaceStatus.stopped", { ns: "common" }),
);
await testStatus(MockStoppedWorkspace, "Stopped");
});

it("shows the Building status when the workspace is starting", async () => {
await testStatus(
MockStartingWorkspace,
t("workspaceStatus.starting", { ns: "common" }),
);
await testStatus(MockStartingWorkspace, "Starting");
});

it("shows the Running status when the workspace is running", async () => {
await testStatus(
MockWorkspace,
t("workspaceStatus.running", { ns: "common" }),
);
await testStatus(MockWorkspace, "Running");
});

it("shows the Failed status when the workspace is failed or canceled", async () => {
await testStatus(
MockFailedWorkspace,
t("workspaceStatus.failed", { ns: "common" }),
);
await testStatus(MockFailedWorkspace, "Failed");
});

it("shows the Canceling status when the workspace is canceling", async () => {
await testStatus(
MockCancelingWorkspace,
t("workspaceStatus.canceling", { ns: "common" }),
);
await testStatus(MockCancelingWorkspace, "Canceling");
});

it("shows the Canceled status when the workspace is canceling", async () => {
await testStatus(
MockCanceledWorkspace,
t("workspaceStatus.canceled", { ns: "common" }),
);
await testStatus(MockCanceledWorkspace, "Canceled");
});

it("shows the Deleting status when the workspace is deleting", async () => {
await testStatus(
MockDeletingWorkspace,
t("workspaceStatus.deleting", { ns: "common" }),
);
await testStatus(MockDeletingWorkspace, "Deleting");
});

it("shows the Deleted status when the workspace is deleted", async () => {
await testStatus(
MockDeletedWorkspace,
t("workspaceStatus.deleted", { ns: "common" }),
);
await testStatus(MockDeletedWorkspace, "Deleted");
});

it("shows the Impending deletion status when the workspace is impending deletion", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ import {
Language as FormLanguage,
} from "./WorkspaceScheduleForm";
import { WorkspaceSchedulePage } from "./WorkspaceSchedulePage";
import i18next from "i18next";
import { server } from "testHelpers/server";
import { rest } from "msw";
import { MockUser, MockWorkspace } from "testHelpers/entities";

const { t } = i18next;

const validValues: WorkspaceScheduleFormValues = {
autostartEnabled: true,
sunday: false,
Expand Down Expand Up @@ -306,8 +303,7 @@ describe("WorkspaceSchedulePage", () => {
name: /submit/i,
});
await user.click(submitButton);
const title = t("dialogTitle", { ns: "workspaceSchedulePage" });
const dialog = await screen.findByText(title);
const dialog = await screen.findByText("Restart workspace?");
expect(dialog).toBeInTheDocument();
});

Expand All @@ -328,8 +324,7 @@ describe("WorkspaceSchedulePage", () => {
name: /submit/i,
});
await user.click(submitButton);
const title = t("dialogTitle", { ns: "workspaceSchedulePage" });
const dialog = screen.queryByText(title);
const dialog = screen.queryByText("Restart workspace?");
expect(dialog).not.toBeInTheDocument();
});
});
Expand Down
0