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

feat(message-queue): confirm registration via graphql api #1138

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9531d88
chore!: add route to serve record notification (#274)
Nil20 Sep 19, 2024
04c1e21
update create declaration function to use same polling mechanism as i…
rikukissa Sep 23, 2024
8193f1f
fix data reference path
rikukissa Sep 23, 2024
ef493b5
update e2e pipeline trigger workflow
rikukissa Sep 23, 2024
bb441ac
send graphql fetch record status query as a string
rikukissa Sep 23, 2024
a78855b
fix response data reference
rikukissa Sep 23, 2024
5c5aef4
fix formatting of e2e pipeline file
rikukissa Sep 23, 2024
8b06a57
update expected result from record creation
rikukissa Sep 23, 2024
a0f8c88
remove expected typename from assertations
rikukissa Sep 23, 2024
142c7d3
one more replace
rikukissa Sep 23, 2024
5f58e23
feat: ask for COUNTRY in setup environment (#276)
naftis Sep 24, 2024
8628a34
small updates to tests to cater for API changes
rikukissa Sep 25, 2024
31af83d
refactor: remove all graphql related stuff
naftis Sep 26, 2024
858e0c7
chore: remove unused code
naftis Sep 30, 2024
9c90e71
feat: allow graphql type hints
naftis Sep 30, 2024
0053906
feat: allow confirming registration via the new graphql api
naftis Sep 30, 2024
7ee30bf
refactor: use graphql comment so no package needed
naftis Sep 30, 2024
2b9e238
refactor: use graphql comment in the last query as well
naftis Sep 30, 2024
1dac6e8
refactor: throw if the composition doesn't have an id
naftis Oct 2, 2024
e520ffc
fix: throw if the id is not found as the function is _get_
naftis Oct 2, 2024
ce3c46d
Merge branch 'ocrvs-6208-reject-registration' of github.com:opencrvs/…
naftis Oct 7, 2024
e2e59b4
fix: add removed deps back
naftis Oct 7, 2024
3d1ba7d
fix: add missing imports
naftis Oct 8, 2024
f78a42d
Merge branch 'ocrvs-6208' of github.com:opencrvs/opencrvs-farajaland …
naftis Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/trigger-e2e-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,24 @@ jobs:

// Check if deploy job has completed
while (!deployJobCompleted) {
const workflowRun = await github.rest.actions.getWorkflowRun({
owner,
repo,
run_id: runId
});
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: runId
});

const deployJob = jobs.data.jobs.find(job => job.name === 'deploy / seed-data / seed-data');
const cancelled = jobs.data.jobs.find(job => job.conclusion === 'cancelled');

if (cancelled) {
throw new Error('E2E workflow was cancelled');
}

if (deployJob && deployJob.status === 'completed') {
deployJobCompleted = true;

Expand All @@ -153,6 +164,14 @@ jobs:
console.log('Deploy job completed successfully');
}

if(workflowRun.data.status === 'completed') {
deployJobCompleted = true;

if (workflowRun.data.conclusion !== 'success') {
throw new Error('E2E workflow failed');
}
}

if (!deployJobCompleted) {
await new Promise(resolve => setTimeout(resolve, 10000));
}
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"apollographql.vscode-apollo"
]
}
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
### Improvements

- Auth token, ip address, remote address, mobile number, email redacted/masked from server log
- Country alpha3 ISO code now is derived from variables to the Docker Compose files and don't need to be hard coded

### Infrastructure breaking changes

Expand All @@ -39,6 +40,10 @@ INSERT CSV ROWS IN ENGLISH ONLY

### Breaking changes

- **Notification Flags** The configuration of various notifications is now controlled from `countryconfig` instead of being handled in the UI, as notification settings are not something that should be changed on the fly. To simplify this process, we have moved the settings to the `application-config.ts` file. From now on, the notifications can be managed in the `notificationForRecord` object defined in the mentioned file. Any changes will take effect after a new deployment.

**_Country implementors must define the `notificationForRecord` object in the `application-config.ts` file to enable the notifications they want. Not doing so will keep notifications disabled by default._**

- **Gateways searchEvents API updated** `operationHistories` only returns `operationType` & `operatedOn` due to the other fields being unused in OpenCRVS
- **Config changes to review/preview and signatures** Core used to provide review/preview section by default which are now removed and need to be provided from countryconfig. The signature field definitions (e.g. informant signature, bride signature etc.) were hard coded in core which also have now been removed. The signatures can now be added through the review/preview sections defined in countryconfig just like any other field. You can use the following section definition as the default which is without any additional fields. We highly recommend checking out our reference country repository which has the signature fields in it's review/preview sections

Expand Down Expand Up @@ -87,12 +92,20 @@ INSERT CSV ROWS IN ENGLISH ONLY
- If there is only one option in the document uploader select, then it stays hidden and only the upload button is showed with the only option being selected by default
- The select options in DOCUMENT_UPLOADER_WITH_OPTION field can now be hidden using the new `optionCondition` property. It works similarly to the same property available in SELECT_WITH_OPTIONS field

* **ElasticSearch reindexing**

Allows reindexing ElasticSearch via a new search-service endpoint `reindex`. We're replacing the original `ocrvs` index with timestamped ones. This is done automatically when upgrading and migrating, but this is an important architectural change that should be noted. More details in [#7033](https://github.com/opencrvs/opencrvs-core/pull/7033).
* **ElasticSearch reindexing** Allows reindexing ElasticSearch via a new search-service endpoint `reindex`. We're replacing the original `ocrvs` index with timestamped ones. This is done automatically when upgrading and migrating, but this is an important architectural change that should be noted. More details in [#7033](https://github.com/opencrvs/opencrvs-core/pull/7033).

- Introduce a new certificate handlebar "preview" which can be used to conditionally render some svg element when previewing the certificate e.g. background image similar to security paper

- **Notification flags**: Added notification flags for `BIRTH`, `DEATH`, and `MARRIAGE` events, including:

- `sent-notification`
- `sent-notification-for-review`
- `sent-for-approval`
- `registered`
- `sent-for-updates`

- **`/record-notification` API**: Endpoint to check enabled notifications for records. The API returns the `notificationForRecord` object for `BIRTH` and `DEATH` events, listing their respective flags. Route configuration includes description and tags for API documentation.

### New content keys requiring translation

```
Expand Down
8 changes: 8 additions & 0 deletions apollo.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"client": {
"service": {
"name": "@opencrvs/gateway",
"url": "http://localhost:7070/graphql"
}
}
}
19 changes: 0 additions & 19 deletions codegen.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ test.describe
})
expect(res).toStrictEqual({
trackingId: expect.any(String),
compositionId: expect.any(String),
isPotentiallyDuplicate: false,
__typename: 'CreatedIds'
recordId: expect.any(String),
isPotentiallyDuplicate: false
})
})

Expand Down
5 changes: 2 additions & 3 deletions e2e/testcases/birth/1-birth-event-declaration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,8 @@ test.describe('1. Birth event declaration', () => {
})
expect(res).toStrictEqual({
trackingId: expect.any(String),
compositionId: expect.any(String),
isPotentiallyDuplicate: false,
__typename: 'CreatedIds'
recordId: expect.any(String),
isPotentiallyDuplicate: false
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1398,8 +1398,8 @@ test.describe.serial('8. Validate declaration review page', () => {
*/
expect(page.url().includes('registration-home')).toBeTruthy()

await page.getByRole('button', { name: 'Ready to print' }).click()
await expectOutboxToBeEmpty(page)
await page.getByRole('button', { name: 'Ready to print' }).click()

/*
* Expected result: The declaration should be in Ready to print
Expand All @@ -1425,3 +1425,5 @@ test.describe.serial('8. Validate declaration review page', () => {
})
})
})

function refreshQueuesUntil() {}
65 changes: 63 additions & 2 deletions e2e/testcases/birth/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
} from './queries'
import { random } from 'lodash'
import { generateRandomSuffix } from '../../helpers'
import gql from 'graphql-tag'
import { print } from 'graphql/language/printer'

export type BirthDetails = {
informant: {
Expand Down Expand Up @@ -64,9 +66,68 @@ function getLocationIdByName(locations: fhir.Location[], name: string) {
}
return location.id
}

const FETCH_RECORD_STATUS = gql`
query fetchRecordStatus($draftId: ID!) {
fetchRecordStatus(draftId: $draftId) {
__typename
... on RecordProcessing {
processed
}
... on RecordProcessed {
processed
trackingId
hasPotentialDuplicates
recordId
}
}
}
`

export async function waitUntilRecordDetails(
token: string,
draftId: string,
maxTries = 10
) {
let nthTry = 0

// eslint-disable-next-line no-constant-condition
while (true) {
const response = await fetch(`${GATEWAY_HOST}/graphql`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
},
body: JSON.stringify({
query: print(FETCH_RECORD_STATUS),
variables: {
draftId: draftId
}
})
}).then((res) => res.json())

const result = response.data
if (result.fetchRecordStatus.__typename === 'RecordProcessed') {
return {
recordId: result.fetchRecordStatus.recordId,
trackingId: result.fetchRecordStatus.trackingId,
isPotentiallyDuplicate: result.fetchRecordStatus.hasPotentialDuplicates
}
}

await new Promise((resolve) => setTimeout(resolve, 1000 + nthTry * 1000))
if (nthTry >= maxTries) {
throw new Error('Max tries exceeded')
}
nthTry++
}
}

export async function createDeclaration(token: string, details: BirthDetails) {
const locations = await getAllLocations('ADMIN_STRUCTURE')
const facilities = await getAllLocations('HEALTH_FACILITY')
const draftId = uuid.v4()

const res = await fetch(`${GATEWAY_HOST}/graphql`, {
method: 'POST',
Expand Down Expand Up @@ -94,7 +155,7 @@ export async function createDeclaration(token: string, details: BirthDetails) {
informantType: details.informant.type,
contactPhoneNumber: '0' + faker.random.numeric(9),
contactEmail: faker.internet.email(),
draftId: uuid.v4()
draftId
},
child: {
name: [
Expand Down Expand Up @@ -320,7 +381,7 @@ export async function createDeclaration(token: string, details: BirthDetails) {
}
})
})
return res.json().then((r) => r.data.createBirthRegistration)
return res.json().then(() => waitUntilRecordDetails(token, draftId))
}

export const fetchDeclaration = async (
Expand Down
7 changes: 1 addition & 6 deletions e2e/testcases/birth/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import { print } from 'graphql/language/printer'

export const CREATE_BIRTH_REGISTRATION = print(gql`
mutation createBirthRegistration($details: BirthRegistrationInput!) {
createBirthRegistration(details: $details) {
trackingId
compositionId
isPotentiallyDuplicate
__typename
}
createBirthRegistration(details: $details)
}
`)

Expand Down
7 changes: 3 additions & 4 deletions e2e/testcases/correction-birth/correct-birth-record-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,15 @@ test.describe('1. Correct record - 1', () => {
const res = await createDeclaration(token, declarationInput)
expect(res).toStrictEqual({
trackingId: expect.any(String),
compositionId: expect.any(String),
isPotentiallyDuplicate: false,
__typename: 'CreatedIds'
recordId: expect.any(String),
isPotentiallyDuplicate: false
})

trackingId = res.trackingId

token = await getToken('f.katongo', 'test')

declaration = (await fetchDeclaration(token, res.compositionId)).data
declaration = (await fetchDeclaration(token, res.recordId)).data
.fetchBirthRegistration as BirthDeclaration
})

Expand Down
9 changes: 4 additions & 5 deletions e2e/testcases/correction-birth/correct-birth-record-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,15 @@ test.describe.serial('Correct record - 2', () => {
const res = await createDeclaration(token, declarationInput)
expect(res).toStrictEqual({
trackingId: expect.any(String),
compositionId: expect.any(String),
isPotentiallyDuplicate: false,
__typename: 'CreatedIds'
recordId: expect.any(String),
isPotentiallyDuplicate: false
})

trackingId = res.trackingId

token = await getToken('f.katongo', 'test')

declaration = (await fetchDeclaration(token, res.compositionId)).data
declaration = (await fetchDeclaration(token, res.recordId)).data
.fetchBirthRegistration as BirthDeclaration
})

Expand Down Expand Up @@ -942,7 +941,7 @@ test.describe.serial('Correct record - 2', () => {
)
).toBeVisible()

/*
/*
@ToDo: assert this after https://github.com/opencrvs/opencrvs-core/issues/7505 is solved
await expect(
page.getByText(
Expand Down
9 changes: 4 additions & 5 deletions e2e/testcases/correction-birth/correct-birth-record-3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,15 @@ test.describe.serial(' Correct record - 3', () => {
const res = await createDeclaration(token, declarationInput)
expect(res).toStrictEqual({
trackingId: expect.any(String),
compositionId: expect.any(String),
isPotentiallyDuplicate: false,
__typename: 'CreatedIds'
recordId: expect.any(String),
isPotentiallyDuplicate: false
})

trackingId = res.trackingId

token = await getToken('f.katongo', 'test')

declaration = (await fetchDeclaration(token, res.compositionId)).data
declaration = (await fetchDeclaration(token, res.recordId)).data
.fetchBirthRegistration as BirthDeclaration
})

Expand Down Expand Up @@ -919,7 +918,7 @@ test.describe.serial(' Correct record - 3', () => {
page.getByText('Comments' + declaration.registration.registrationNumber)
).toBeVisible()

/*
/*
@ToDo: assert this after https://github.com/opencrvs/opencrvs-core/issues/7505 is solved
await expect(
page.getByText(
Expand Down
7 changes: 3 additions & 4 deletions e2e/testcases/correction-birth/correct-birth-record-4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,15 @@ test.describe.serial(' Correct record - 4', () => {
const res = await createDeclaration(token, declarationInput)
expect(res).toStrictEqual({
trackingId: expect.any(String),
compositionId: expect.any(String),
isPotentiallyDuplicate: false,
__typename: 'CreatedIds'
recordId: expect.any(String),
isPotentiallyDuplicate: false
})

trackingId = res.trackingId

token = await getToken('k.mweene', 'test')

declaration = (await fetchDeclaration(token, res.compositionId)).data
declaration = (await fetchDeclaration(token, res.recordId)).data
.fetchBirthRegistration as BirthDeclaration
})

Expand Down
7 changes: 3 additions & 4 deletions e2e/testcases/correction-birth/correct-birth-record-5.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@ test.describe.serial(' Correct record - 5', () => {
const res = await createDeclaration(token, declarationInput)
expect(res).toStrictEqual({
trackingId: expect.any(String),
compositionId: expect.any(String),
isPotentiallyDuplicate: false,
__typename: 'CreatedIds'
recordId: expect.any(String),
isPotentiallyDuplicate: false
})

trackingId = res.trackingId

token = await getToken('k.mweene', 'test')
declaration = (await fetchDeclaration(token, res.compositionId)).data
declaration = (await fetchDeclaration(token, res.recordId)).data
.fetchBirthRegistration as BirthDeclaration
})

Expand Down
Loading
Loading