Skip to content
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
2 changes: 1 addition & 1 deletion .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ module.exports = function (eleventyConfig) {
// Copies the 11ty base layout and partials to the contributions app layouts directory
eleventyConfig.on('eleventy.before', async ({ directories }) => {
const srcDir = `${directories.includes}layouts`
const destDir = './views/common'
const destDir = './app/views/common'
const templates = [
'base.njk',
'404.njk',
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ jobs:
run: ENV=test npm run build:package
- name: Build docs
run: ENV=test npm run build:docs
- name: Create .env file
run: |
echo "ENV=test" >> app/.env.test
echo "APP_PORT=3003" >> app/.env.test
echo "APP_URL='http://localhost:3003'" >> app/.env.test
echo "DEV_VERIFIED_EMAIL='test.user@justice.gov.uk'" >> app/.env.test
echo "DEV_DUMMY_DATA='false'" >> app/.env.test
echo "SKIP_VERIFICATION='true'" >> app/.env.test
echo "VERIFICATION_TOKEN='12345abcde'" >> app/.env.test
- name: Run Playwright tests
env:
ENV: test
APP_PORT: 3003
APP_URL: http://localhost:3003
DEV_VERIFIED_EMAIL: test.user@justice.gov.uk
SKIP_VERIFICATION: 'true'
VERIFICATION_TOKEN: 12345abcde
run: npx playwright test
run: ENV=test npm run test:e2e
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
path: ./playwright-report/
retention-days: 30
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ tests/e2e/screenshots/*
/blob-report/
/playwright/.cache/

playwright/.state
app/tests/playwright/.state/session.json
playwright/.state/session.json
33 changes: 9 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,58 +87,43 @@ FROM base AS staging-express-app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY src src
COPY app.js app.js
COPY config.js config.js
COPY app app
COPY filters filters
COPY helpers helpers
COPY schema schema
COPY middleware middleware
COPY routes routes
COPY views views
COPY playwright playwright
COPY --from=staging-build /app/public public
ENV ENV=staging
# run express app as a non root user
RUN useradd -u 1001 -m nonrootuser
USER 1001
EXPOSE 3001
CMD ["node", "app.js"]
CMD ["node", "app/app.js"]

FROM base AS preview-express-app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY src src
COPY app.js app.js
COPY config.js config.js
COPY app app
COPY filters filters
COPY helpers helpers
COPY schema schema
COPY middleware middleware
COPY routes routes
COPY views views
COPY playwright playwright
COPY --from=preview-build /app/public public
ENV ENV=staging
# run express app as a non root user
RUN useradd -u 1001 -m nonrootuser
USER 1001
EXPOSE 3001
CMD ["node", "app.js"]
CMD ["node", "app/app.js"]

FROM base AS production-express-app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
COPY src src
COPY app.js app.js
COPY config.js config.js
COPY app app
COPY filters filters
COPY helpers helpers
COPY schema schema
COPY middleware middleware
COPY routes routes
COPY views views
COPY playwright playwright
COPY --from=production-build /app/public public
ENV ENV=production
# run express app as a non root user
RUN useradd -u 1001 -m nonrootuser
USER 1001
EXPOSE 3001
CMD ["node", "app.js"]
CMD ["node", "app/app.js"]
15 changes: 7 additions & 8 deletions app.js → app/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint import/order: "off" */
/* eslint n/no-unpublished-require: "off" */

require('dotenv').config({ path: `./.env.${process.env.ENV || 'development'}` })
const path = require('path')
const envPath = path.join(__dirname, `.env.${process.env.ENV || 'development'}`)
require('dotenv').config({ path: envPath })

const Sentry = require('@sentry/node')
const {
Expand All @@ -23,8 +24,6 @@ if (!(isDev || isTest)) {
environment: ENV
})
}

const path = require('path')
const redisClient = require('./helpers/redis-client')
const crypto = require('crypto')

Expand All @@ -37,7 +36,7 @@ const helmet = require('helmet')
const nunjucks = require('nunjucks')
const { xss } = require('express-xss-sanitizer')

const rev = require('./filters/rev')
const rev = require('../filters/rev')

const addComponentRoutes = require('./routes/add-component')

Expand Down Expand Up @@ -115,8 +114,8 @@ app.set('views', [
path.join(__dirname, 'views/common'),
path.join(__dirname, 'views/community/pages'),
// path.join(__dirname, 'node_modules/@ministryofjustice/frontend'),
path.join(__dirname, 'src'),
path.join(__dirname, 'node_modules/govuk-frontend/dist')
path.join(__dirname, '../src'),
path.join(__dirname, '../node_modules/govuk-frontend/dist')
])

app.set('view engine', 'njk')
Expand All @@ -135,7 +134,7 @@ app.locals.env = {

// Static files and body parsing
app.use(express.urlencoded({ extended: true }))
app.use(express.static(path.join(__dirname, 'public')))
app.use(express.static(path.join(__dirname, '../public')))
app.use(express.json())
// Component Code needs to be handled separately as it cannot sanitize js
app.use(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const sendEmail = async (
retries = NOTIFY_EMAIL_MAX_RETRIES,
backoff = NOTIFY_EMAIL_RETRY_MS
) => {
if (process.env.ENV === 'test') return false
for (let attempt = 1; attempt <= retries; attempt++) {
try {
console.log(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions routes/add-component.js → app/routes/add-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ if (ENV === 'development') {

// Start
router.get('/start', (req, res) => {
console.log(process.env.NOTIFY_VERIFICATION_TEMPLATE)
delete req.session.checkYourAnswers
req.session.started = true
res.render('start', {
Expand Down Expand Up @@ -262,6 +263,8 @@ router.post(
// send email
async (req, res) => {
if (req.emailDomainAllowed) {
console.log(process.env.SKIP_VERIFICATION)
console.log(process.env.DEV_VERIFIED_EMAIL)
if (
process.env.SKIP_VERIFICATION === 'true' &&
process.env.DEV_VERIFIED_EMAIL
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const schema = addAnotherSchema.append({
.messages({
'any.required': 'Enter the link to the Figma design file',
'string.empty': 'Enter the link to the Figma design file',
'string.uri': 'Add a real URL',
'string.uri': 'Add a link to a Figma design file',
'string.pattern.base': 'Add a link to a Figma design file'
}),
figmaLinkAdditionalInformation: Joi.string()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ test.describe('validations', async () => {
await testPage.linkInput.fill('not a url')
await testPage.clickContinue()

await testPage.expectErrorSummaryWithMessages(['Add a real URL'])
await testPage.expectErrorSummaryWithMessages([
'Add a link to a Figma design file'
])

await expect(testPage.errorMessages).toHaveCount(1)
await expect(testPage.errorMessages).toContainText(['Add a real URL'])
await expect(testPage.errorMessages).toContainText([
'Add a link to a Figma design file'
])
})

test.describe('character count', async () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion e2e/session.setup.js → app/tests/e2e/session.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import path from 'path'

import { test as setup, expect } from '@playwright/test'

const sessionFile = path.join(__dirname, '../playwright/.state/session.json')
const sessionFile = path.join(
__dirname,
'../../../playwright/.state/session.json'
)

setup('session', async ({ page }) => {
// Perform authentication steps. Replace these actions with your own.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading