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

[84] Use env variable for setting the data dictionary link #124

Merged
merged 2 commits into from
Apr 22, 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
1 change: 1 addition & 0 deletions dev/docker-compose.dev.full.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ services:
REACT_APP_PUBLIC_MAPBOX_TOKEN: "${REACT_APP_PUBLIC_MAPBOX_TOKEN}"
REACT_APP_POLICY_PUBLIC_ID: "${REACT_APP_POLICY_PUBLIC_ID}"
REACT_APP_COOKIE_CONSENT_PUBLIC_ID: "${REACT_APP_COOKIE_CONSENT_PUBLIC_ID}"
REACT_APP_DATA_DICTIONARY_LINK: "${REACT_APP_DATA_DICTIONARY_LINK}"
ENABLE_LOCAL_AUTH: "true"
localstack:
image: localstack/localstack-pro
Expand Down
1 change: 1 addition & 0 deletions dev/docker-compose.dev.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ services:
REACT_APP_POLICY_PUBLIC_ID: "${REACT_APP_POLICY_PUBLIC_ID}"
REACT_APP_COOKIE_CONSENT_PUBLIC_ID: "${REACT_APP_COOKIE_CONSENT_PUBLIC_ID}"
REACT_APP_RECAPTCHA_SITE_KEY: "${REACT_APP_RECAPTCHA_SITE_KEY}"
REACT_APP_DATA_DICTIONARY_LINK: "${REACT_APP_DATA_DICTIONARY_LINK}"
ENABLE_LOCAL_AUTH: "true"
DISEASE_NAME: "${DISEASE_NAME}"
localstack:
Expand Down
1 change: 1 addition & 0 deletions dev/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ services:
REACT_APP_COOKIE_CONSENT_PUBLIC_ID: "${REACT_APP_COOKIE_CONSENT_PUBLIC_ID}"
REACT_APP_RECAPTCHA_SITE_KEY: "${REACT_APP_RECAPTCHA_SITE_KEY}"
REACT_APP_DISEASE_NAME: "${REACT_APP_DISEASE_NAME}"
REACT_APP_DATA_DICTIONARY_LINK: "${REACT_APP_DATA_DICTIONARY_LINK}"
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import { Role } from '../../api/models/User';

jest.mock('axios');
const mockedAxios = axios as jest.Mocked<typeof axios>;
const mockedDataDictionaryLink = 'https://global.health/data-dictionary';
const env = validateEnv();

beforeEach(() => {
jest.clearAllMocks();
});

beforeAll(() => {
process.env.REACT_APP_DATA_DICTIONARY_LINK = mockedDataDictionaryLink;
});

describe('<App />', () => {
it('renders without crashing when logged in', async () => {
const axiosResponse = {
Expand Down Expand Up @@ -129,7 +134,7 @@ describe('<App />', () => {
);
expect(await screen.findByTestId('dictionaryButton')).toHaveAttribute(
'href',
'https://raw.githubusercontent.com/globaldothealth/list/main/data-serving/scripts/export-data/data_dictionary.txt',
mockedDataDictionaryLink,
);
expect(await screen.findByTestId('termsButton')).toHaveAttribute(
'href',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function ProfileMenu(props: { user: User; version: string }): JSX.Element {
<a
rel="noopener noreferrer"
target="_blank"
href="https://raw.githubusercontent.com/globaldothealth/list/main/data-serving/scripts/export-data/data_dictionary.txt"
href={process.env.REACT_APP_DATA_DICTIONARY_LINK}
onClick={handleClose}
className={classes.link}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export function DownloadButton(): JSX.Element {

<Typography variant="body2">
<a
href="https://raw.githubusercontent.com/globaldothealth/list/main/data-serving/scripts/export-data/data_dictionary.txt"
href={process.env.REACT_APP_DATA_DICTIONARY_LINK}
target="_blank"
rel="noreferrer"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const Footer = ({ drawerOpen }: FooterProps): JSX.Element => {

<section>
<a
href="https://raw.githubusercontent.com/globaldothealth/list/main/data-serving/scripts/export-data/data_dictionary.txt"
href={process.env.REACT_APP_DATA_DICTIONARY_LINK}
rel="noopener noreferrer"
target="_blank"
data-testid="dictionaryButton"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import { setupServer } from 'msw/node';
import { Route } from 'react-router-dom';

const server = setupServer();
const mockedDataDictionaryLink = 'https://global.health/data-dictionary';

beforeAll(() => server.listen());
beforeAll(() => {
server.listen();
process.env.REACT_APP_DATA_DICTIONARY_LINK = mockedDataDictionaryLink;
});
afterEach(() => server.resetHandlers());
afterAll(() => server.close());

Expand Down Expand Up @@ -62,7 +66,7 @@ describe('<LandingPage />', () => {
);
expect(screen.getByText('Data dictionary')).toHaveAttribute(
'href',
'https://raw.githubusercontent.com/globaldothealth/list/main/data-serving/scripts/export-data/data_dictionary.txt',
mockedDataDictionaryLink,
);
expect(screen.getByText('Terms of use')).toHaveAttribute(
'href',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const MoreInformationLinks = ({
</div>
<div className={classes.link}>
<a
href="https://raw.githubusercontent.com/globaldothealth/list/main/data-serving/scripts/export-data/data_dictionary.txt"
href={process.env.REACT_APP_DATA_DICTIONARY_LINK}
rel="noopener noreferrer"
target="_blank"
>
Expand Down
Loading