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

[REFACTOR] React to HTML plugin #856

Merged
merged 2 commits into from
Nov 28, 2022

Conversation

giulianok
Copy link
Member

Description

Fastify plugin that takes care of creating the redux store, converting react into html, and responding

Motivation and Context

This is part of the ExpressJS -> Fastify migration. The plugin allows us to simply reply with reply.sendHtml() from any route

How Has This Been Tested?

Manual, Unit Testing, Integration Testing

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update
  • Security update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • These changes should be applied to a maintenance branch.
  • This change requires cross browser checks.
  • Performance tests should be ran against the server prior to merging.
  • This change impacts caching for client browsers.
  • This change impacts HTTP headers.
  • This change adds additional environment variable requirements for One App users.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using One App?

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2022

Size Change: 0 B

Total Size: 681 kB

ℹ️ View Unchanged
Filename Size
./build/app/app.js 165 kB
./build/app/app~vendors.js 387 kB
./build/app/runtime.js 7.07 kB
./build/app/service-worker-client.js 7.26 kB
./build/app/vendors.js 114 kB

compressed-size-action

@@ -1,5 +1,5 @@
/*
* Copyright 2019 American Express Travel Related Services Company, Inc.
* Copyright 2022 American Express Travel Related Services Company, Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not need to be updated

expect(response.body).toContain('Sorry, we are unable to load this page at this time. Please try again later.');
});

it('invites the user to try again if the status code is 404', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why try again on a 404?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "try again" is related to the message that's being rendered: "Please try again later." (see

it('invites the user to try again if the status code is 404', () => {
)

res.timeout = timeout;
return res;
.then((reply) => {
// eslint-disable-next-line no-param-reassign
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment explaining any rules being disabled

jest.spyOn(console, 'log').mockImplementation(() => {});
jest.spyOn(console, 'error').mockImplementation(() => {});
jest.spyOn(console, 'warn').mockImplementationOnce(() => {});
jest.spyOn(console, 'info').mockImplementation(() => { });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a lint error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just copy/paste from another test

it('warns if url cannot be fetched', async () => {
const fetchError = new Error('getaddrinfo ENOTFOUND');
global.fetch = jest.fn(() => Promise.reject(fetchError));
test('calls the expected hooks to render html', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use it rather than test throughout

@@ -53,10 +52,10 @@ const renderForStaticMarkupSpy = jest.spyOn(reactRendering, 'renderForStaticMark

describe('createRequestHtmlFragment', () => {
jest.spyOn(console, 'error').mockImplementation(() => {});
console.error = jest.fn();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed

@giulianok giulianok merged commit 1f2063b into feature/fastify-migration Nov 28, 2022
@giulianok giulianok deleted the refactor/render-html-plugin branch November 28, 2022 20:10
@giulianok giulianok mentioned this pull request Dec 5, 2022
14 tasks
@giulianok giulianok mentioned this pull request Mar 2, 2023
14 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants