-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ea3386
commit ff79786
Showing
24 changed files
with
223 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { BorrowingCapacityCalculationInput } from './BorrowingCapacityCalculationInput'; | ||
|
||
export type DetailedBorrowerProfile = BorrowingCapacityCalculationInput & { | ||
export type DetailedBorrowerProfile = { | ||
age: number; | ||
employmentStatus: 'FULL_TIME' | 'PART_TIME' | 'CASUAL' | 'SELF_EMPLOYED'; | ||
grossAnnualIncome: number; | ||
monthlyExpenses: number; | ||
creditScore: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ tags: | |
|
||
| Name | Type | Example | Description | | ||
|-------------|--------|----------------------|--------------------------------------------------------------| | ||
| pk | string | [email protected] | Primary Key: The borrower's email address | | ||
| pk | string | [email protected] | Partition Key: The borrower's email address | | ||
| sk | string | BORROWER | Sort Key: The entity type (BORROWER) | | ||
| creditScore | number | 500 | Borrower's credit score. This is a number between 0 and 1000 | | ||
| dob | string | '1985-09-01' | Borrower's date of birth as an ISO8061 date string | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ tags: | |
|
||
| Name | Type | Example | Description | | ||
|--------------------------------|--------|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------| | ||
| pk | string | [email protected] | Primary Key: The borrower's email address | | ||
| pk | string | [email protected] | Partition Key: The borrower's email address | | ||
| sk | string | BORROWING_CAPACITY_CALCULATION#2dd0ce10-4d28-4275-af31-b2e5edc7430a#TIMESTAMP#2024-03-15T00:00:00.000Z | Sort Key: The entity type ('BORROWING_CAPACITY_CALCULATION'), borrowingCapacityCalculationId and timestamp separated by '#' | | ||
| estimatedBorrowingCapacity | number | 100000 | The borrower's borrowing capacity. This is a number >= 0 | | ||
| grossAnnualIncome | number | 40000 | The borrower's gross annual income. This is a number >= 0 | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
sidebar_position: 10 | ||
tags: | ||
- clean-up | ||
--- | ||
|
||
|
||
# Clean Up | ||
|
||
|
||
Run the following command in your terminal: | ||
|
||
```shell | ||
pnpm run remove | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ tags: | |
|
||
| Name | Type | Example | Description | | ||
|-----------------------|--------|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| | ||
| pk | string | [email protected] | Primary Key: The borrower's email address | | ||
| pk | string | [email protected] | Partition Key: The borrower's email address | | ||
| sk | string | LOAN_APPLICATION#2dd0ce10-4d28-4275-af31-b2e5edc7430a#TIMESTAMP#2024-03-15T00:00:00.000Z | Sort Key: The entity type ('LOAN_APPLICATION'), loanApplicationId and timestamp separated by '#' | | ||
| loanApplicationStatus | string | 'APPROVED' | The borrower's employment status. One of 'APPROVED', 'REJECTED', 'REVIEW' | | ||
| creditScore | number | 700 | Borrower's credit score. This is a number between 0 and 1000 | | ||
|
138 changes: 138 additions & 0 deletions
138
docs/docs/loan-application/workshop-activities/integration.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
--- | ||
sidebar_position: 5 | ||
tags: | ||
- integration | ||
--- | ||
|
||
# Integration | ||
|
||
## Scenario 1 | ||
|
||
Unskip the next test case. Remove the `.todo`: `it.todo(...)` --> `it(...)`: | ||
|
||
|
||
```typescript title="backend/tests/integration/api-gw-apply-for-loan.spec.ts" | ||
// ... | ||
describe.concurrent('api-aw-apply-for-loan', () => { | ||
const apiClient = openApiFetch<paths>({ | ||
baseUrl: baseUrl, | ||
}); | ||
// highlight-next | ||
it.todo('responds with a 400 Bad Request given the user does not provide the required request body', async ({ | ||
expect, | ||
}) => { | ||
await expect( | ||
apiClient.POST('/loan', { | ||
body: {} as unknown as ApplyForLoanRequestBody, | ||
}) | ||
).resolves.toEqual({ | ||
error: { | ||
message: 'Invalid request body', | ||
}, | ||
response: expect.objectContaining({ | ||
status: 400, | ||
statusText: 'Bad Request', | ||
}), | ||
}); | ||
}); | ||
// ... | ||
}); | ||
``` | ||
|
||
## Scenario 2 | ||
|
||
Unskip the next test case. Remove the `.todo`: `it.todo(...)` --> `it(...)`: | ||
|
||
|
||
```typescript title="backend/tests/integration/api-gw-apply-for-loan.spec.ts" | ||
// ... | ||
describe.concurrent('api-aw-apply-for-loan', () => { | ||
const apiClient = openApiFetch<paths>({ | ||
baseUrl: baseUrl, | ||
}); | ||
// ... | ||
// highlight-next | ||
it('response with a 400 Bad Request given the user provides the required request body but the borrower profile does not exist', async ({ | ||
expect, | ||
}) => { | ||
const borrowerEmail = `loan-application+${randomUUID()}@example.com`; | ||
await expect( | ||
apiClient.POST('/loan', { | ||
body: { | ||
borrowerEmail: borrowerEmail, | ||
grossAnnualIncome: 100_000, | ||
employmentStatus: 'FULL_TIME', | ||
monthlyExpenses: 1000, | ||
}, | ||
}) | ||
).resolves.toEqual({ | ||
error: { | ||
message: 'Borrower with the provided email does not exist', | ||
}, | ||
response: expect.objectContaining({ | ||
status: 400, | ||
statusText: 'Bad Request', | ||
}), | ||
}); | ||
|
||
await Promise.all([ | ||
deleteBorrowerProfile(borrowerEmail), | ||
deleteLoanApplications(borrowerEmail), | ||
]); | ||
}); | ||
// ... | ||
}); | ||
``` | ||
|
||
## Scenario 3 | ||
|
||
Unskip the next test case. Remove the `.todo`: `it.todo(...)` --> `it(...)`: | ||
|
||
|
||
```typescript title="backend/tests/integration/api-gw-apply-for-loan.spec.ts" | ||
// ... | ||
describe.concurrent('api-aw-apply-for-loan', () => { | ||
const apiClient = openApiFetch<paths>({ | ||
baseUrl: baseUrl, | ||
}); | ||
// ... | ||
// highlight-next | ||
it('responds with a 201 Submitted with the loan application status given the user provides the required request body when the borrower profile exists', async ({ | ||
expect, | ||
}) => { | ||
const borrowerEmail = `loan-application+${randomUUID()}@example.com`; | ||
await apiClient.POST('/borrower', { | ||
body: { | ||
email: borrowerEmail, | ||
name: 'John Doe', | ||
creditScore: 800, | ||
dob: '1999-01-01', | ||
}, | ||
}); | ||
await expect( | ||
apiClient.POST('/loan', { | ||
body: { | ||
borrowerEmail: borrowerEmail, | ||
grossAnnualIncome: 100_000, | ||
employmentStatus: 'FULL_TIME', | ||
monthlyExpenses: 1000, | ||
}, | ||
}) | ||
).resolves.toEqual({ | ||
data: { | ||
loanApplicationStatus: 'APPROVED', | ||
}, | ||
response: expect.objectContaining({ | ||
status: 201, | ||
statusText: 'Created', | ||
}), | ||
}); | ||
|
||
await Promise.all([ | ||
deleteBorrowerProfile(borrowerEmail), | ||
deleteLoanApplications(borrowerEmail), | ||
]); | ||
}); | ||
// ... | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.