Skip to content

Commit

Permalink
Merge pull request #590 from serlo/move-legal-to-frontend
Browse files Browse the repository at this point in the history
refactor(legal): move legal pages to frontend, simplify `ui`
  • Loading branch information
kulla authored Nov 20, 2023
2 parents 1d20453 + 44eb77c commit 8fd632b
Show file tree
Hide file tree
Showing 48 changed files with 209 additions and 1,421 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 1 addition & 3 deletions __tests__/__utils__/expect-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export async function expectIsNotFoundResponse(
response: Response,
): Promise<void> {
expect(response.status).toBe(404)
expect(await response.text()).toEqual(
expect.stringContaining('Page not found'),
)
await expectContainsText(response, ['Page Not Found'])
}

export async function expectIsJsonResponse(
Expand Down
5 changes: 3 additions & 2 deletions __tests__/__utils__/test-environment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CfProperties } from '@cloudflare/workers-types'
import TOML from '@iarna/toml'
import fs from 'fs'
import path from 'path'
Expand Down Expand Up @@ -63,8 +64,8 @@ export abstract class TestEnvironment {

public abstract fetchRequest(request: Request): Promise<Response>

public createRequest(spec: UrlSpec, init?: RequestInit) {
return new Request(this.createUrl(spec), init)
public createRequest(spec: UrlSpec, init?: RequestInit<CfProperties>) {
return new Request<unknown, CfProperties>(this.createUrl(spec), init)
}

public createUrl({
Expand Down
2 changes: 1 addition & 1 deletion __tests__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Enforce HTTPS', () => {
test('HTTP URL', async () => {
const response = await env.fetch({ subdomain: 'en', protocol: 'http' })

expectToBeRedirectTo(response, env.createUrl({ subdomain: 'en' }), 302)
expectToBeRedirectTo(response, env.createUrl({ subdomain: 'en' }), 301)
})

test('HTTPS URL', async () => {
Expand Down
301 changes: 0 additions & 301 deletions __tests__/legal-pages.tsx

This file was deleted.

22 changes: 16 additions & 6 deletions __tests__/redirects.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
expectIsNotFoundResponse,
expectToBeRedirectTo,
givenApi,
givenUuid,
Expand Down Expand Up @@ -37,7 +36,8 @@ describe('meet.serlo.org', () => {
pathname: '/foo',
})

await expectIsNotFoundResponse(response)
const target = `https://serlo.org/___cf_not_found`
expectToBeRedirectTo(response, target, 302)
})
})

Expand All @@ -57,7 +57,17 @@ test('de.serlo.org/impressum', async () => {
pathname: '/impressum',
})

const target = 'https://de.serlo.org/imprint'
const target = 'https://de.serlo.org/legal'
expectToBeRedirectTo(response, target, 301)
})

test('de.serlo.org/impressum', async () => {
const response = await env.fetch({
subdomain: 'de',
pathname: '/imprint',
})

const target = 'https://de.serlo.org/legal'
expectToBeRedirectTo(response, target, 301)
})

Expand Down Expand Up @@ -85,7 +95,7 @@ test('*.serlo.org/user/public -> *serlo.org/user/me', async () => {
})

const target = env.createUrl({ subdomain: 'hi', pathname: '/user/me' })
expectToBeRedirectTo(response, target, 302)
expectToBeRedirectTo(response, target, 301)
})

test.each(['/neuerechtsform', '/neuerechtsform/'])(
Expand Down Expand Up @@ -164,7 +174,7 @@ test('serlo.org/* redirects to de.serlo.org/*', async () => {
const response = await env.fetch({ pathname: '/foo' })

const target = env.createUrl({ subdomain: 'de', pathname: '/foo' })
expectToBeRedirectTo(response, target, 302)
expectToBeRedirectTo(response, target, 301)
})

test('www.serlo.org/* redirects to de.serlo.org/*', async () => {
Expand All @@ -174,7 +184,7 @@ test('www.serlo.org/* redirects to de.serlo.org/*', async () => {
})

const target = env.createUrl({ subdomain: 'de', pathname: '/foo' })
expectToBeRedirectTo(response, target, 302)
expectToBeRedirectTo(response, target, 301)
})

test('/page/view/:id redirects to /:id', async () => {
Expand Down
Loading

0 comments on commit 8fd632b

Please sign in to comment.