Skip to content
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

[Issue #1937] Translate Loading component text #2186

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 10 additions & 4 deletions frontend/src/app/[locale]/search/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import React from "react";

import Spinner from "src/components/Spinner";

export default function Loading() {
// TODO (Issue #1937): Use translation utility for strings in this file
export interface LoadingProps {
message?: string;
}

export default function Loading({ message }: LoadingProps) {
return (
<div className="display-flex flex-align-center flex-justify-center margin-bottom-15 margin-top-15">
<Spinner />
<span className="font-body-2xl text-bold margin-left-2">
Loading results...
<span
className="font-body-2xl text-bold margin-left-2"
data-testid="loading-message"
>
{message || "Loading"}...
</span>
</div>
);
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/app/[locale]/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ function Search({ searchParams }: { searchParams: searchParamsTypes }) {
scroll={false}
/>
</Suspense>
<Suspense key={key} fallback={<Loading />}>
<Suspense
key={key}
fallback={<Loading message={t("loading")} />}
>
<SearchResultsListFetch
searchParams={convertedSearchParams}
/>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/i18n/messages/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,5 +497,6 @@ export const messages = {
select: "Select All",
clear: "Clear All",
},
loading: "Loading Results",
},
};
14 changes: 14 additions & 0 deletions frontend/stories/pages/loading.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Meta } from "@storybook/react";

import Loading from "../../src/app/[locale]/search/loading";

const meta: Meta<typeof Loading> = {
component: Loading,
};
export default meta;

export const Default = {
args: {
message: "Loading Storybook",
},
};
2 changes: 1 addition & 1 deletion frontend/tests/e2e/search/search-loading.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test.describe("Search page tests", () => {
const searchTerm = "advanced";
await fillSearchInputAndSubmit(searchTerm, page);

const loadingIndicator = page.locator("text='Loading results...'");
const loadingIndicator = page.getByTestId("loading-message");
await expect(loadingIndicator).toBeVisible();
await expect(loadingIndicator).toBeHidden();

Expand Down
Loading