Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
feature: migrated express to fastify
Browse files Browse the repository at this point in the history
feature: migrated express to fastify
  • Loading branch information
giulianok authored Dec 5, 2022
1 parent 4a0d032 commit 31ce34e
Show file tree
Hide file tree
Showing 79 changed files with 9,569 additions and 8,547 deletions.
9 changes: 4 additions & 5 deletions __tests__/client/initClient.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

import { fromJS } from 'immutable';

jest.mock('@americanexpress/one-app-router', () => {
const reactRouter = jest.requireActual('@americanexpress/one-app-router');
jest.spyOn(reactRouter, 'matchPromise');
return reactRouter;
});
jest.mock('@americanexpress/one-app-router', () => ({
...jest.requireActual('@americanexpress/one-app-router'),
matchPromise: jest.fn(),
}));

jest.mock('../../src/client/prerender', () => {
const prerender = jest.requireActual('../../src/client/prerender');
Expand Down
2 changes: 2 additions & 0 deletions __tests__/integration/__snapshots__/one-app.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ exports[`Tests that require Docker setup one-app successfully started metrics ha
"nodejs_active_handles_total",
"nodejs_active_requests",
"nodejs_active_requests_total",
"nodejs_active_resources",
"nodejs_active_resources_total",
"nodejs_eventloop_lag_max_seconds",
"nodejs_eventloop_lag_mean_seconds",
"nodejs_eventloop_lag_min_seconds",
Expand Down
60 changes: 32 additions & 28 deletions __tests__/integration/one-app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ describe('Tests that require Docker setup', () => {
headers: {
origin: 'test.example.com',
},
body: JSON.stringify({}),
});
const rawHeaders = response.headers.raw();
expect(response.status).toBe(200);
expect(rawHeaders).not.toHaveProperty('access-control-allow-origin');
expect(rawHeaders).not.toHaveProperty('access-control-expose-headers');
expect(rawHeaders).not.toHaveProperty('access-control-allow-credentials');
});
Expand Down Expand Up @@ -210,9 +210,9 @@ describe('Tests that require Docker setup', () => {
headers: {
origin: 'test.example.com',
},
body: {
body: JSON.stringify({
message: 'Hello!',
},
}),
}
);
const rawHeaders = response.headers.raw();
Expand Down Expand Up @@ -1335,9 +1335,6 @@ describe('Tests that require Docker setup', () => {
date: [
expect.any(String),
],
etag: [
expect.any(String),
],
'one-app-version': [
expect.any(String),
],
Expand All @@ -1348,14 +1345,23 @@ describe('Tests that require Docker setup', () => {
'max-age=15552000; includeSubDomains',
],
vary: [
'Accept-Encoding',
'accept-encoding',
],
'x-content-type-options': [
'nosniff',
],
'x-dns-prefetch-control': [
'off',
],
'x-download-options': [
'noopen',
],
'x-frame-options': [
'DENY',
],
'x-permitted-cross-domain-policies': [
'none',
],
'x-xss-protection': [
'1; mode=block',
],
Expand All @@ -1369,6 +1375,7 @@ describe('Tests that require Docker setup', () => {
headers: {
origin: 'test.example.com',
},
body: {},
});

expect(response.headers.raw()).toEqual({
Expand Down Expand Up @@ -1421,6 +1428,7 @@ describe('Tests that require Docker setup', () => {
headers: {
origin: 'test.example.com',
},
body: {},
});

expect(response.headers.raw()).toEqual({
Expand All @@ -1439,9 +1447,6 @@ describe('Tests that require Docker setup', () => {
date: [
expect.any(String),
],
etag: [
expect.any(String),
],
'one-app-version': [
expect.any(String),
],
Expand All @@ -1452,7 +1457,7 @@ describe('Tests that require Docker setup', () => {
'max-age=15552000; includeSubDomains',
],
vary: [
'Accept-Encoding',
'accept-encoding',
],
'x-content-type-options': [
'nosniff',
Expand Down Expand Up @@ -1485,8 +1490,11 @@ describe('Tests that require Docker setup', () => {
origin: 'test.example.com',
'content-type': 'application/json',
},
body: JSON.stringify({}),
});

// expect(response.status).toBe(204);
expect(await response.text()).toBe('');
expect(response.headers.raw()).toEqual({
connection: [
'close',
Expand All @@ -1497,9 +1505,6 @@ describe('Tests that require Docker setup', () => {
date: [
expect.any(String),
],
etag: [
expect.any(String),
],
'one-app-version': [
expect.any(String),
],
Expand Down Expand Up @@ -1528,8 +1533,6 @@ describe('Tests that require Docker setup', () => {
'0',
],
});
expect(response.status).toBe(204);
expect(await response.text()).toBe('');
});

test('Request: /foo/invalid.json', async () => {
Expand All @@ -1542,6 +1545,7 @@ describe('Tests that require Docker setup', () => {
});

expect(response.status).toBe(404);
expect(await response.text()).toBe('Not found');
expect(response.headers.raw()).toEqual({
'cache-control': [
'no-store',
Expand All @@ -1561,8 +1565,8 @@ describe('Tests that require Docker setup', () => {
date: [
expect.any(String),
],
etag: [
expect.any(String),
'expect-ct': [
'max-age=0',
],
'one-app-version': [
expect.any(String),
Expand All @@ -1571,13 +1575,13 @@ describe('Tests that require Docker setup', () => {
'no-cache',
],
'referrer-policy': [
'no-referrer',
'same-origin',
],
'strict-transport-security': [
'max-age=15552000; includeSubDomains',
],
vary: [
'Accept-Encoding',
'accept-encoding',
],
'x-content-type-options': [
'nosniff',
Expand All @@ -1589,13 +1593,13 @@ describe('Tests that require Docker setup', () => {
'noopen',
],
'x-frame-options': [
'SAMEORIGIN',
'DENY',
],
'x-permitted-cross-domain-policies': [
'none',
],
'x-xss-protection': [
'0',
'1; mode=block',
],
});
});
Expand Down Expand Up @@ -1655,9 +1659,9 @@ describe('Tests that can run against either local Docker setup or remote One App
headers: {
origin: 'test.example.com',
},
body: {
body: JSON.stringify({
message: 'Hello!',
},
}),
}
);
expect(response.status).toBe(200);
Expand All @@ -1669,11 +1673,10 @@ describe('Tests that can run against either local Docker setup or remote One App
const response = await fetch(`${appInstanceUrls.fetchUrl}/success`, {
...defaultFetchOpts,
method: 'POST',
body: {},
});
const pageHtml = await response.text();
expect(pageHtml.includes('Hello! One App is successfully rendering its Modules!')).toBe(
true
);
expect(pageHtml).toContain('Hello! One App is successfully rendering its Modules!');
});

test('app passes vitruvius data to modules', async () => {
Expand Down Expand Up @@ -1702,7 +1705,7 @@ describe('Tests that can run against either local Docker setup or remote One App
method: 'GET',
originalUrl: '/vitruvius',
params: {
0: '/vitruvius',
'*': 'vitruvius',
},
protocol: expect.stringMatching(/^https?$/),
query: {},
Expand Down Expand Up @@ -1732,6 +1735,7 @@ describe('Tests that can run against either local Docker setup or remote One App
sendingData: 'in POSTs',
});
});

test('app passes urlencoded POST data to modules via vitruvius', async () => {
const response = await fetch(`${appInstanceUrls.fetchUrl}/vitruvius`, {
...defaultFetchOpts,
Expand Down
5 changes: 0 additions & 5 deletions __tests__/server/middleware/__snapshots__/csp.spec.js.snap

This file was deleted.

15 changes: 0 additions & 15 deletions __tests__/server/middleware/__snapshots__/sendHtml.spec.js.snap

This file was deleted.

This file was deleted.

36 changes: 0 additions & 36 deletions __tests__/server/middleware/addCacheHeaders.spec.js

This file was deleted.

60 changes: 0 additions & 60 deletions __tests__/server/middleware/addFrameOptionsHeader.spec.js

This file was deleted.

Loading

0 comments on commit 31ce34e

Please sign in to comment.