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

Wrap user-facing strings for internalization #334

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Next Next commit
Squashed commit of the following:
commit 7e11c9f
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Thu Oct 26 17:27:21 2023 -0700

    Resolve id and unique key errors

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit 58f5ac7
Merge: e9b6894 fde4421
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Thu Oct 26 17:12:18 2023 -0700

    Merge branch 'refactor/issue-330' of https://github.com/nung22/dashboards-search-relevance into refactor/issue-330

commit e9b6894
Merge: 13f9246 e92057a
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Thu Oct 26 17:08:49 2023 -0700

    Wrap all repo tests with I18nProvider

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit fde4421
Merge: 13f9246 e92057a
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Thu Oct 26 17:08:49 2023 -0700

    Merge branch 'refactor/issue-330' of https://github.com/nung22/dashboards-search-relevance into refactor/issue-330

commit 13f9246
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Thu Oct 26 16:59:05 2023 -0700

    Wrap all repo tests with I18nProvider

commit e92057a
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Thu Oct 26 16:59:05 2023 -0700

    Wrap test with I18nProvider

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit 2b9c0ea
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Thu Oct 26 16:40:25 2023 -0700

    Update duplicate ids in flyout.tsx

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit 7d14e3c
Merge: 6869944 bbb27f4
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Thu Oct 26 10:52:55 2023 -0700

    Merge branch 'refactor/issue-330' of https://github.com/nung22/dashboards-search-relevance into refactor/issue-330

commit 6869944
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Wed Oct 25 14:35:32 2023 -0700

    Refactor code for user-wrapped strings in header.tsx and flyout.tsx

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit b69ff41
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Mon Oct 23 15:06:05 2023 -0700

    Wrap user-facing strings in header.tsx

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit fe99311
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Mon Oct 23 14:09:06 2023 -0700

    Update flyout.tsx snapshot

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit 7a2a97a
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Mon Oct 23 14:03:12 2023 -0700

    Update FormattedMessages blocks in flyout.tsx

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit c58a10b
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Tue Oct 17 10:11:15 2023 -0700

    Wrap user-facing strings in flyout.tsx for internalization

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit bbb27f4
Merge: 38162ca 77db981
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Mon Oct 23 17:00:01 2023 -0700

    Merge branch 'main' of https://github.com/nung22/dashboards-search-relevance into refactor/issue-330

commit 38162ca
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Mon Oct 23 15:06:05 2023 -0700

    Wrap user-facing strings in header.tsx

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit a7ce8f6
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Mon Oct 23 14:09:06 2023 -0700

    Update flyout.tsx snapshot

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit c1cd4fa
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Mon Oct 23 14:03:12 2023 -0700

    Update FormattedMessages blocks in flyout.tsx

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

commit 611546a
Author: Nicholas Ung <nicholasung22@gmail.com>
Date:   Tue Oct 17 10:11:15 2023 -0700

    Wrap user-facing strings in flyout.tsx for internalization

    Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>

Signed-off-by: Nicholas Ung <nicholasung22@gmail.com>
  • Loading branch information
nung22 committed Oct 27, 2023
commit a231956a0f5f8a450c320eda7207a9e1ffa030bd
8,213 changes: 4,252 additions & 3,961 deletions public/components/common/__test__/__snapshots__/flyout.test.tsx.snap

Large diffs are not rendered by default.

275 changes: 197 additions & 78 deletions public/components/common/__test__/__snapshots__/header.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,88 +1,207 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Header component Renders header component 1`] = `
<Header>
<EuiPanel
borderRadius="none"
color="transparent"
grow={false}
hasBorder={false}
hasShadow={false}
<I18nProvider>
<IntlProvider
defaultLocale="en"
formats={
Object {
"date": Object {
"full": Object {
"day": "numeric",
"month": "long",
"weekday": "long",
"year": "numeric",
},
"long": Object {
"day": "numeric",
"month": "long",
"year": "numeric",
},
"medium": Object {
"day": "numeric",
"month": "short",
"year": "numeric",
},
"short": Object {
"day": "numeric",
"month": "numeric",
"year": "2-digit",
},
},
"number": Object {
"currency": Object {
"style": "currency",
},
"percent": Object {
"style": "percent",
},
},
"relative": Object {
"days": Object {
"units": "day",
},
"hours": Object {
"units": "hour",
},
"minutes": Object {
"units": "minute",
},
"months": Object {
"units": "month",
},
"seconds": Object {
"units": "second",
},
"years": Object {
"units": "year",
},
},
"time": Object {
"full": Object {
"hour": "numeric",
"minute": "numeric",
"second": "numeric",
"timeZoneName": "short",
},
"long": Object {
"hour": "numeric",
"minute": "numeric",
"second": "numeric",
"timeZoneName": "short",
},
"medium": Object {
"hour": "numeric",
"minute": "numeric",
"second": "numeric",
},
"short": Object {
"hour": "numeric",
"minute": "numeric",
},
},
}
}
locale="en"
messages={Object {}}
textComponent={Symbol(react.fragment)}
>
<div
className="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusNone euiPanel--transparent euiPanel--noShadow euiPanel--noBorder euiPanel--flexGrowZero"
>
<EuiTitle>
<h1
className="euiTitle euiTitle--medium"
<PseudoLocaleWrapper>
<Header>
<EuiPanel
borderRadius="none"
color="transparent"
grow={false}
hasBorder={false}
hasShadow={false}
>
Compare search results
</h1>
</EuiTitle>
<EuiText>
<div
className="euiText euiText--medium"
>
<p>
Compare results using the same search text with different queries.

<EuiLink
href="https://opensearch.org/docs/latest/search-plugins/search-relevance"
target="_blank"
>
<a
className="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest/search-plugins/search-relevance"
rel="noopener noreferrer"
target="_blank"
<div
className="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusNone euiPanel--transparent euiPanel--noShadow euiPanel--noBorder euiPanel--flexGrowZero"
>
<EuiTitle>
<h1
className="euiTitle euiTitle--medium"
>
Learn more
<EuiIcon
aria-label="External link"
className="euiLink__externalIcon"
size="s"
type="popout"
<FormattedMessage
defaultMessage="Compare search results"
id="searchRelevance.header.title"
values={Object {}}
>
<EuiIconEmpty
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
role="img"
style={null}
>
<svg
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</EuiIconEmpty>
</EuiIcon>
<EuiScreenReaderOnly>
<span
className="euiScreenReaderOnly"
Compare search results
</FormattedMessage>
</h1>
</EuiTitle>
<EuiText>
<div
className="euiText euiText--medium"
>
<p>
<FormattedMessage
defaultMessage="Compare results using the same search text with different queries. {learnMoreLink}"
id="searchRelevance.header.description"
values={
Object {
"learnMoreLink": <EuiLink
href="https://opensearch.org/docs/latest/search-plugins/search-relevance"
target="_blank"
>
<FormattedMessage
defaultMessage="Learn more"
id="searchRelevance.header.description.learnMoreLinkLabel"
values={Object {}}
/>
</EuiLink>,
}
}
>
<EuiI18n
default="(opens in a new tab or window)"
token="euiLink.newTarget.screenReaderOnlyText"
Compare results using the same search text with different queries.
<EuiLink
href="https://opensearch.org/docs/latest/search-plugins/search-relevance"
target="_blank"
>
(opens in a new tab or window)
</EuiI18n>
</span>
</EuiScreenReaderOnly>
</a>
</EuiLink>
</p>
</div>
</EuiText>
</div>
</EuiPanel>
</Header>
<a
className="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest/search-plugins/search-relevance"
rel="noopener noreferrer"
target="_blank"
>
<FormattedMessage
defaultMessage="Learn more"
id="searchRelevance.header.description.learnMoreLinkLabel"
values={Object {}}
>
Learn more
</FormattedMessage>
<EuiIcon
aria-label="External link"
className="euiLink__externalIcon"
size="s"
type="popout"
>
<EuiIconEmpty
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
role="img"
style={null}
>
<svg
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</EuiIconEmpty>
</EuiIcon>
<EuiScreenReaderOnly>
<span
className="euiScreenReaderOnly"
>
<EuiI18n
default="(opens in a new tab or window)"
token="euiLink.newTarget.screenReaderOnlyText"
>
(opens in a new tab or window)
</EuiI18n>
</span>
</EuiScreenReaderOnly>
</a>
</EuiLink>
</FormattedMessage>
</p>
</div>
</EuiText>
</div>
</EuiPanel>
</Header>
</PseudoLocaleWrapper>
</IntlProvider>
</I18nProvider>
`;
9 changes: 6 additions & 3 deletions public/components/common/__test__/flyout.test.tsx
Original file line number Diff line number Diff line change
@@ -9,15 +9,18 @@ import React from 'react';
import { waitFor } from '@testing-library/react';
import { Flyout } from '../flyout';
import { SearchRelevanceContextProvider } from '../../../contexts';
import { I18nProvider } from '@osd/i18n/react';

describe('Flyout component', () => {
configure({ adapter: new Adapter() });

it('Renders flyout component', async () => {
const wrapper = mount(
<SearchRelevanceContextProvider>
<Flyout />
</SearchRelevanceContextProvider>
<I18nProvider>
<SearchRelevanceContextProvider>
<Flyout />
</SearchRelevanceContextProvider>
</I18nProvider>
);

wrapper.update();
7 changes: 6 additions & 1 deletion public/components/common/__test__/header.test.tsx
Original file line number Diff line number Diff line change
@@ -8,12 +8,17 @@ import Adapter from 'enzyme-adapter-react-16';
import React from 'react';
import { waitFor } from '@testing-library/react';
import { Header } from '../header';
import { I18nProvider } from '@osd/i18n/react';

describe('Header component', () => {
configure({ adapter: new Adapter() });

it('Renders header component', async () => {
const wrapper = mount(<Header />);
const wrapper = mount(
<I18nProvider>
<Header />
</I18nProvider>
);

wrapper.update();

Loading