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

Add data.application.type for PreApplication schema #281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pixeltrix
Copy link
Contributor

This mirrors the Application schema and reduces the need for branching when submitting to an endpoint that handles both pre-application and application requests.

In BOPS we're planning to create pre-applications as a type of planning application as the workflow closely mirrors that of an application and by having applicationType at the root it makes it difficult to handle cleanly. I've left applicationType in the root so that the change wouldn't break anyone depending on that.

This mirrors the Application schema and reduces the need for
branching when submitting to an endpoint that handles both
pre-application and application requests.
build
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tsconfig.json file specifies build for the outDir option. The only thing in there is tsconfig.tsbuildinfo but just to be safe I've added it to the list of ignored files.

@@ -33,14 +33,14 @@ const walkDirectory = async (dir: string) => {
// Write file to mirrored directory, outside the /data folder where the TS examples are stored
const jsonExampleFilePath = path.join(
dir.replace('/data', ''),
`${path.basename(file, '.ts')}.json`
`${path.basename(file, '.ts')}.json`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added by the linter

);
await convertTypeScriptObjectToJSON(filePath, jsonExampleFilePath);
}
}
};

(async () => {
void (async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The linter was complaining about this so i added void to keep it quiet

@@ -1,5 +1,8 @@
#!/bin/bash

set -e
set -o pipefail

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 so the script fails if a subprocess fails - the pre-application schema was failing but it continued on and there was just a single 'Error' line so it was hard to spot in the output.

@@ -53,46 +60,49 @@ const schemas = [
describe.each(schemas)('$name', ({schema, examples}) => {
const validator = new Validator();

const _applicationTypeProperty =
'$data.application.type.description' || '$applicationType';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed as we don't need this now it's in the same place

expect(result.errors).not.toHaveLength(0);
});
});
describe.each<Application | PreApplication>(examples)(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Jest couldn't infer the type so we have to be explicit

@@ -4,10 +4,14 @@
"rootDir": ".",
"outDir": "build",
"skipLibCheck": true,
"esModuleInterop": true,
"resolveJsonModule": true
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 is so we can use import with the JSON files in the tests

@@ -1,4 +1,4 @@
import {Entity} from '../../../shared/Constraints';
import {Entity} from '../../../shared/Entity';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Entity was being defined twice so I moved it to the shared directory

preApp: 'Pre-application advice',
'preApp.householder': 'Pre-application advice - Householder',
'preApp.minor': 'Pre-application advice - Minor',
'preApp.major': 'Pre-application advice - Major',
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're just using the one type for now (preApp) but it's possible there may be others later so this is more an indication of intent

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.

1 participant