Skip to content

Commit

Permalink
Merge branch 'staging' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
krischarbonneau committed Jun 6, 2024
2 parents 57d8e22 + fddcb15 commit 77b1375
Show file tree
Hide file tree
Showing 69 changed files with 2,137 additions and 2,441 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ AUTH_ECAS_USERINFO="ECAS userinfo endpoint"
AUTH_PRIVATE={ "kty": "RSA", "n": "example private key" }
AUTH_DISABLED="set to 'true' to disable authentiation"
SWAP_USER_TESTING_LINKS = "Set true to use UT links"
MSCA_NG_CERT_LOCATION="./env.crt"

# OpenTelemetry/Dynatrace settings
# Note: to disable metrics and/or tracing exporting, leave the respective endpoint undefined
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/default-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ jobs:
run: npm run test:coverage -- -u
env:
CI: true

AUTH_DISABLED: true

- name: Store Results
uses: actions/upload-artifact@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ yarn-error.log*
.env
.env.local

#cert
env.crt

# typescript
*.tsbuildinfo
next-env.d.ts
Expand Down
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug MSCA-D frontend",
"command": "npm run dev",
"request": "launch",
"type": "node-terminal",
"cwd": "${workspaceFolder}"
},
{
"type": "pwa-chrome",
"request": "launch",
Expand Down
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20-alpine3.18 AS base
FROM node:20-alpine3.20 AS base
WORKDIR /base
COPY package*.json ./
RUN npm ci && npm cache clean --force
Expand All @@ -7,6 +7,8 @@ COPY . .
FROM base AS build

# Build envs
ARG HOSTALIAS_CERT
ENV HOSTALIAS_CERT=$HOSTALIAS_CERT
ARG LOGGING_LEVEL=info
ENV LOGGING_LEVEL=$LOGGING_LEVEL
ARG AEM_GRAPHQL_ENDPOINT=https://www.canada.ca/graphql/execute.json/decd-endc/
Expand All @@ -23,15 +25,19 @@ ENV MSCA_ECAS_RASC_BASE_URL=$MSCA_ECAS_RASC_BASE_URL
ENV NODE_ENV=production
WORKDIR /build
COPY --from=base /base ./
RUN npm run build

FROM node:20-alpine3.18 AS production
RUN mkdir -p /usr/local/share/ca-certificates/ && echo ${HOSTALIAS_CERT} | sed 's/\\n/\n/g' | xargs > /usr/local/share/ca-certificates/env.crt && chmod 644 /usr/local/share/ca-certificates/env.crt && npm run build

FROM node:20-alpine3.20 AS production
ENV NODE_ENV=production

ARG user=nodeuser
ARG group=nodegroup
ARG home=/srv/app

ARG MSCA_NG_CERT_LOCATION=/usr/local/share/ca-certificates/env.crt
ENV MSCA_NG_CERT_LOCATION=$MSCA_NG_CERT_LOCATION

RUN addgroup \
-S ${group} \
--gid 1001 && \
Expand All @@ -45,6 +51,10 @@ RUN addgroup \

WORKDIR ${home}

COPY --from=build --chown=${user}:${group} /usr/local/share/ca-certificates/env.crt ${MSCA_NG_CERT_LOCATION}

RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* && update-ca-certificates

USER ${user}

COPY --from=build --chown=${user}:${group} /build/next.config.js ./
Expand Down
4 changes: 4 additions & 0 deletions __tests__/components/Breadcrumb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('BreadCrumb', () => {
<Breadcrumb
id="breadcrumbID"
items={[{ text: 'Canada.ca', link: '/' }]}
refPageAA="dashboard"
/>,
)
expect(primary).toBeTruthy()
Expand All @@ -36,6 +37,7 @@ describe('BreadCrumb', () => {
{ text: 'Link2', link: '/' },
{ text: 'Link3', link: '/' },
]}
refPageAA="dashboard"
/>,
)
expect(withItems).toBeTruthy()
Expand All @@ -52,6 +54,7 @@ describe('BreadCrumb', () => {
{ text: 'Max length of breadcrumb 28', link: '/' },
{ text: 'Link3', link: '/' },
]}
refPageAA="dashboard"
/>,
)
expect(withItemsWithLongText).toBeTruthy()
Expand All @@ -62,6 +65,7 @@ describe('BreadCrumb', () => {
<Breadcrumb
id="breadcrumbID"
items={[{ text: 'Canada.ca', link: '/' }]}
refPageAA="dashboard"
/>,
)
const results = await axe(container)
Expand Down
12 changes: 6 additions & 6 deletions __tests__/components/ContextualAlert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ describe('ContextualAlert', () => {
id="alert_icon_id"
alert_icon_id="icon-id"
alert_icon_alt_text="alt"
type="info"
message_heading="Information"
message_body="You may wish to print this page..."
type="information"
alertHeading="Information"
alertBody="You may wish to print this page..."
/>,
)
it('renders this Contectual Alert component', () => {
Expand All @@ -36,9 +36,9 @@ describe('ContextualAlert', () => {
id="alert_icon_id"
alert_icon_id="icon-id"
alert_icon_alt_text="alt"
type="info"
message_heading="Information"
message_body="You may wish to print this page..."
type="information"
alertHeading="Information"
alertBody="You may wish to print this page..."
/>,
)
const results = await axe(container)
Expand Down
54 changes: 0 additions & 54 deletions __tests__/components/ExitBetaModal.test.js

This file was deleted.

1 change: 1 addition & 0 deletions __tests__/components/Header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('Header', () => {
{ text: 'Max length of breadcrumb 28', link: '/' },
{ text: 'Link3', link: '/' },
],
refPageAA: 'dashboard',
}
test('renders Header component with default props', () => {
render(<Header {...defaultProps} />)
Expand Down
27 changes: 27 additions & 0 deletions __tests__/components/IdleTimeout.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import '@testing-library/jest-dom'
import { render, screen, waitFor } from '@testing-library/react'
import IdleTimeout from '../../components/IdleTimeout'

jest.mock('next/router', () => ({
useRouter: () => ({}),
}))

describe('IdleTimeout', () => {
it('renders with modal opened after 1 second timeout', async () => {
render(
<IdleTimeout
promptBeforeIdle={4000}
timeout={5000}
locale="en"
refPageAA="test"
/>,
)
await waitFor(
() => {
const modal = screen.getByTestId('modal')
expect(modal).toBeInTheDocument()
},
{ timeout: 3000 },
)
})
})
40 changes: 40 additions & 0 deletions __tests__/components/InfoMessage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom'
import { axe, toHaveNoViolations } from 'jest-axe'
import InfoMessage from '../../components/InfoMessage'

expect.extend(toHaveNoViolations)

describe('InfoMessage', () => {
it('renders InfoMessage', () => {
render(
<InfoMessage
data-testid={'label'}
messageText={'messageText'}
messageLinkText={'messageLinkText'}
icon={'arrow-up-right-from-square'}
></InfoMessage>,
)
const label = screen.getAllByTestId('label')
const messageText = screen.getByText('messageText')
const messageLinkText = screen.getByText('messageLinkText')

expect.arrayContaining(label)
expect(messageText).toBeInTheDocument()
expect(messageLinkText).toBeInTheDocument()
})

it('has no a11y viollations', async () => {
const { container } = render(
<InfoMessage
label={'label'}
messageText={'messageText'}
messageLinkText={'messageLinkText'}
messageLinkHref={'messageLinkHref'}
icon={'arrow-up-right-from-square'}
></InfoMessage>,
)
const results = await axe(container)
expect(results).toHaveNoViolations()
})
})
93 changes: 0 additions & 93 deletions __tests__/components/PhaseBanner.test.js

This file was deleted.

Loading

0 comments on commit 77b1375

Please sign in to comment.