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

🧑‍💻 ✅ updated release notes link to point… #360

Merged
merged 2 commits into from
Nov 29, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

import { ReleaseNoteType } from '../ReleaseNotesTypes/ReleaseNotesTypes.types';
import FilterHeader from './FilterHeader';
import { EnvironmentType } from 'src/components/Navigation/TopBar/TopBar';
import { AuthProvider, ReleaseNotesProvider } from 'src/providers';
import { render, screen, userEvent } from 'src/tests/test-utils';

Expand Down Expand Up @@ -41,6 +42,60 @@ test('should confirm that there is a link button', () => {
expect(actual).toBeVisible();
});

test('should link to correct environment given that it is not prod or empty', () => {
vi.stubEnv('VITE_ENVIRONMENT_NAME', EnvironmentType.STAGING);
render(<FilterHeader />, {
wrapper: Wrappers,
});
const actual = screen.getByRole('link');
expect(actual).toBeInTheDocument();
expect(actual).toBeVisible();
screen.logTestingPlaygroundURL();
expect(actual.getAttribute('href')).toBe(
`https://client-amplify-portal-${EnvironmentType.STAGING}.radix.equinor.com/releasenotes?applications=%5B"Amplify components"%5D`
);
});

test('should link to development environment given that its environment is localhost', () => {
vi.stubEnv('VITE_ENVIRONMENT_NAME', EnvironmentType.LOCALHOST);
render(<FilterHeader />, {
wrapper: Wrappers,
});
const actual = screen.getByRole('link');
expect(actual).toBeInTheDocument();
expect(actual).toBeVisible();
screen.logTestingPlaygroundURL();
expect(actual.getAttribute('href')).toBe(
`https://client-amplify-portal-${EnvironmentType.DEVELOP}.radix.equinor.com/releasenotes?applications=%5B"Amplify components"%5D`
);
});
test('should link to production environment using the external dns, amplify.equinor.com given environment is set to production', () => {
vi.stubEnv('VITE_ENVIRONMENT_NAME', EnvironmentType.PRODUCTION);
render(<FilterHeader />, {
wrapper: Wrappers,
});
const actual = screen.getByRole('link');
expect(actual).toBeInTheDocument();
expect(actual).toBeVisible();
screen.logTestingPlaygroundURL();
expect(actual.getAttribute('href')).toBe(
'https://amplify.equinor.com/releasenotes?applications=%5B"Amplify components"%5D'
);
});
test('should link to production environment using the external dns, amplify.equinor.com as a fallback when no environment is set', () => {
vi.stubEnv('VITE_ENVIRONMENT_NAME', '');
render(<FilterHeader />, {
wrapper: Wrappers,
});
const actual = screen.getByRole('link');
expect(actual).toBeInTheDocument();
expect(actual).toBeVisible();
screen.logTestingPlaygroundURL();
expect(actual.getAttribute('href')).toBe(
'https://amplify.equinor.com/releasenotes?applications=%5B"Amplify components"%5D'
);
});

test('should check that typing a value in the sieve input is indeed present', async () => {
render(<FilterHeader />, {
wrapper: Wrappers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ import {
FilterValues,
SieveValue,
} from 'src/components/Inputs/Sieve/Sieve.types';
import { EnvironmentType } from 'src/components/Navigation/TopBar/TopBar';
import { useReleaseNotes } from 'src/providers/ReleaseNotesProvider';
import { environment } from 'src/utils';

const { getAppName } = environment;
const { getEnvironmentName, getAppName } = environment;

const FilterHeader: FC = () => {
const applicationName = getAppName(import.meta.env.VITE_NAME);
const environmentName = getEnvironmentName(
import.meta.env.VITE_ENVIRONMENT_NAME
);
const environmentNameWithoutLocalHost =
environmentName === EnvironmentType.LOCALHOST
? EnvironmentType.DEVELOP
: environmentName;
const { setSearch, setOpen } = useReleaseNotes();
const [sieveValue, setSieveValue] = useState<SieveValue>({
searchValue: undefined,
Expand Down Expand Up @@ -83,8 +91,12 @@ const FilterHeader: FC = () => {
<ButtonContainer>
<Button
variant="ghost_icon"
// TODO: this url should be built from the current environment instead of simply pointing to the portal's prod environment
href={`https://amplify.equinor.com/releasenotes?applications=%5B"${applicationName}"%5D`}
href={
environmentNameWithoutLocalHost &&
environmentNameWithoutLocalHost !== EnvironmentType.PRODUCTION
? `https://client-amplify-portal-${environmentNameWithoutLocalHost}.radix.equinor.com/releasenotes?applications=%5B"${applicationName}"%5D`
: `https://amplify.equinor.com/releasenotes?applications=%5B"${applicationName}"%5D`
}
>
<Icon data={external_link} />
</Button>
Expand Down