Skip to content

Commit

Permalink
Get ready to extract having-problems strings
Browse files Browse the repository at this point in the history
Refs #1834, #1817
  • Loading branch information
thewilkybarkid committed Nov 29, 2024
1 parent 9d1a7eb commit 79c7a3d
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 34 deletions.
14 changes: 14 additions & 0 deletions src/HavingProblemsPage/HavingProblemsPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { StatusCodes } from 'http-status-codes'
import { html, plainText } from '../html.js'
import { PageResponse } from '../response.js'

export const createHavingProblemsPage = (): PageResponse =>
PageResponse({
status: StatusCodes.SERVICE_UNAVAILABLE,
title: plainText`Sorry, we’re having problems`,
main: html`
<h1>Sorry, we’re having problems</h1>
<p>Please try again later.</p>
`,
})
5 changes: 5 additions & 0 deletions src/HavingProblemsPage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Effect } from 'effect'
import type { PageResponse } from '../response.js'
import { createHavingProblemsPage } from './HavingProblemsPage.js'

export const HavingProblemsPage: Effect.Effect<PageResponse> = Effect.sync(createHavingProblemsPage)
11 changes: 2 additions & 9 deletions src/http-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Status } from 'hyper-ts'
import * as RM from 'hyper-ts/lib/ReaderMiddleware.js'
import { match } from 'ts-pattern'
import { Locale } from './Context.js'
import { HavingProblemsPage } from './HavingProblemsPage/index.js'
import { html, plainText, sendHtml } from './html.js'
import { DefaultLocale } from './locales/index.js'
import { templatePage } from './page.js'
Expand Down Expand Up @@ -66,15 +67,7 @@ function problemsPage(user?: User) {

export const pageNotFound = Effect.runSync(Effect.provideService(PageNotFound, Locale, DefaultLocale))

export const havingProblemsPage = PageResponse({
status: Status.ServiceUnavailable,
title: plainText`Sorry, we’re having problems`,
main: html`
<h1>Sorry, we’re having problems</h1>
<p>Please try again later.</p>
`,
})
export const havingProblemsPage = Effect.runSync(HavingProblemsPage)

export const noPermissionPage = PageResponse({
status: Status.Forbidden,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createHavingProblemsPage } from '../../src/HavingProblemsPage/HavingProblemsPage.js'
import { expect, test } from '../base.js'

test('content looks right', async ({ showPage }) => {
const content = await showPage(createHavingProblemsPage())

await expect(content).toHaveScreenshot()
})
8 changes: 1 addition & 7 deletions visual-regression/http-errors.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { havingProblemsPage, noPermissionPage } from '../src/http-error.js'
import { noPermissionPage } from '../src/http-error.js'
import { expect, test } from './base.js'

test('having-problems page content looks right', async ({ showPage }) => {
const content = await showPage(havingProblemsPage)

await expect(content).toHaveScreenshot()
})

test('no-permission page content looks right', async ({ showPage }) => {
const content = await showPage(noPermissionPage)

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 79c7a3d

Please sign in to comment.