Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/lp 212 name page #49

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft

Feature/lp 212 name page #49

wants to merge 13 commits into from

Conversation

lduranteau
Copy link
Contributor

@lduranteau lduranteau commented Nov 15, 2024

JIRA link

https://companieshouse.atlassian.net/browse/LP-212

Change description

  • add Name page
  • architecture proposal

Work checklist

  • Tests added where applicable
  • UI changes look good on mobile
  • UI changes meet accessibility criteria

Merge instructions

We are committed to keeping commit history clean, consistent and linear. To achieve this commit should be structured as follows:

<type>[optional scope]: <description>

and contain the following structural elements:

  • fix: a commit that patches a bug in your codebase (this correlates with PATCH in semantic versioning),
  • feat: a commit that introduces a new feature to the codebase (this correlates with MINOR in semantic versioning),
  • BREAKING CHANGE: a commit that has a footer BREAKING CHANGE: introduces a breaking API change (correlating with MAJOR in semantic versioning). A BREAKING CHANGE can be part of commits of any type,
  • types other than fix: and feat: are allowed, for example build:, chore:, ci:, docs:, style:, refactor:, perf:, test:, and others,
  • footers other than BREAKING CHANGE: <description> may be provided.

  - create code structure
  - unit test
  - create transaction
  - unit test
  - create controller
  - integration test
  - create controller
  - integration test
  - disable submit if no name ending
  - integration test errors
  - integration test for next-2 page (demo)
@@ -14,6 +14,11 @@
"start": "node dist/bin/www.js",
"dev": "nodemon src/bin/www.ts",
"test": "jest",
"test:watch": "jest --watch",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the 'watch' changes should go in a separate PR (together with README updates, explaining what they do/how to make use of them), then this PR is entirely focussed on the new page and encompassing framework?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use watch mode when I am working
I can update the readme


import TransactionRegistrationType from "../application/registration/TransactionRegistrationType";

interface IRegistrationGateway {
Copy link
Contributor

Choose a reason for hiding this comment

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

See what others think, but I think some light documentation in the code on these key interfaces would be helpful (this would be in addition to the Confluence design).

@@ -0,0 +1,7 @@
enum TransactionRegistrationType {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is simply a list of all the pages in the Registration journey. If yes, could we maybe remove 'Transaction' from the name as it's confusing me and get 'Page' in there? RegistrationPageType perhaps?

I'm also wondering why the value matches the constant name and is in uppercase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We said we were going to change the name, maybe use submission instead of transaction.
But certainly not page because these are not pages

): TransactionRouting {
const coordination = this.transactionMap.get(registrationType);

if (!coordination) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally speaking, getting some debug log statements into the f/w will be really useful. E.g. here when the routing is and isn't called, based on whether the 'coordination' (or should it be named coordinator?) is found.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not a big fan of logging everywhere, that makes reading very hard.
But we can add logs if we really need to

} from "../../config/constants";
import TransactionRegistrationType from "./TransactionRegistrationType";

export const NAME_TEMPLATE = TransactionRegistrationType.NAME.toLowerCase();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why bother converting to lowercase - shouldn't the page names just be named correctly to start with? What if we wanted to use/have camelCase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did this to match the template name with the transaction type
But this can be done differently

The only trick is that when a get request is made, the controller extracts the last part of the url and uses it to find out the TransactionType and retrieve the correct routing.

import { START_URL } from "../../config/constants";
import { NAME_URL } from "../../application/registration/Routing";

export type TransactionRouting = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so 'transaction' confusing things here. Would 'PageRequestRouting' be a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Submission maybe but not page

transactionId: string,
data: Record<string, any>
): Promise<string> {
if (!data.partnership_name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't HTML page validation be trapping this? Plan was to not implement custom validation in the web (initially).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This simulates errors coming from API after sending the request

const globalErrorHandler = (err: Error, req: Request, res: Response, _next: NextFunction) => {
logger.errorRequest(req, `An error has occurred. Re-routing to the error screen - ${err.stack}`);
const globalErrorHandler = (
err: Error,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these are just formatting changes. Could they be reverted (for now)? This PR is already big and then review can be focussed on the new f/w and not reformatting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use eslint and prettier
everyone is supposed to have plugins activated

import { TransactionRouting } from "../../domain/entities/TransactionRouting";

class RegistrationController {
private registrationService: RegistrationService;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering why the controller also has a reference to the RegistrationService as this seems to also sit alongside the controller in the IDependencies interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has no reference
It uses the injected service

private getTransactionType(path: string) {
let id = this.templateName(path);
if (id.includes("-")) {
id = id.replace("-", "_");
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems significant... what is it for/doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the template name has a hyphen but TransactionType underscore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants