-
Notifications
You must be signed in to change notification settings - Fork 4
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
71bc0a0
commit 0239936
Showing
6 changed files
with
281 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { gql } from "graphql-request"; | ||
|
||
export default gql` | ||
fragment PieceJustificativeFragment on PieceJustificativeChamp { | ||
id | ||
files { | ||
...FileFragment | ||
} | ||
} | ||
`; |
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,36 @@ | ||
import { gql } from "graphql-request"; | ||
import FileFragment from "./fragment/FileFragment"; | ||
import PieceJustificativeFragment from "./fragment/PieceJustificativeFragment"; | ||
|
||
export default gql` | ||
query getFilesFromDossier($dossierNumber: Int!) { | ||
dossier(number: $dossierNumber) { | ||
id | ||
annotations { | ||
...PieceJustificativeFragment | ||
... on RepetitionChamp { | ||
rows { | ||
champs { | ||
...PieceJustificativeFragment | ||
} | ||
} | ||
} | ||
} | ||
champs { | ||
...PieceJustificativeFragment | ||
... on RepetitionChamp { | ||
rows { | ||
champs { | ||
...PieceJustificativeFragment | ||
} | ||
} | ||
} | ||
} | ||
attestation { | ||
...FileFragment | ||
} | ||
} | ||
} | ||
${FileFragment} | ||
${PieceJustificativeFragment} | ||
`; |
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,37 @@ | ||
import { gql } from "graphql-request"; | ||
import FileFragment from "./fragment/FileFragment"; | ||
import PieceJustificativeFragment from "./fragment/PieceJustificativeFragment"; | ||
|
||
export default gql` | ||
query getOneFileFromDossier( | ||
$dossierNumber: Int! | ||
$champId: ID | ||
$includeAnnotations: Boolean = false | ||
$includeChamps: Boolean = false | ||
$includeMessages: Boolean = false | ||
$includeAttestation: Boolean = false | ||
) { | ||
dossier(number: $dossierNumber) { | ||
id | ||
number | ||
annotations(id: $champId) @include(if: $includeAnnotations) { | ||
...PieceJustificativeFragment | ||
} | ||
attestation @include(if: $includeAttestation) { | ||
...FileFragment | ||
} | ||
champs(id: $champId) @include(if: $includeChamps) { | ||
...PieceJustificativeFragment | ||
} | ||
messages(id: $champId) @include(if: $includeMessages) { | ||
attachments { | ||
...FileFragment | ||
} | ||
id | ||
} | ||
} | ||
} | ||
${FileFragment} | ||
${PieceJustificativeFragment} | ||
`; |
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,76 @@ | ||
import { DsApiClient } from "../src/index"; | ||
|
||
const { API_URL, API_TOKEN } = process.env; | ||
|
||
describe.skip("ds api", () => { | ||
let dsApiClient; | ||
|
||
beforeAll(() => { | ||
dsApiClient = new DsApiClient(API_URL, API_TOKEN); | ||
}); | ||
it("Has to retrieve demarche number 1", async () => { | ||
const response = await dsApiClient.demarche(1); | ||
expect(response).toMatchObject({ | ||
demarche: { | ||
number: 1, | ||
title: "test procedure 20220920", | ||
description: "test procedure 20220920", | ||
}, | ||
}); | ||
}); | ||
|
||
it("Has to retrieve demarche number 1", async () => { | ||
const response = await dsApiClient.demarche(1); | ||
expect(response?.demarche?.number).toBe(1); | ||
}); | ||
|
||
it("get demarche with dossier ids number 1", async () => { | ||
const response = await dsApiClient.demarcheDossierIds(1); | ||
expect(response?.demarche?.number).toBe(1); | ||
expect(response?.demarche?.dossiers.nodes).toHaveLength(1); | ||
expect(response?.demarche?.dossiers.nodes).toMatchObject([ | ||
{ | ||
number: 220, | ||
}, | ||
]); | ||
}); | ||
|
||
it("get one files from dossiers in annatation", async () => { | ||
const response = await dsApiClient.dossierFile(221, "Q2hhbXAtMTQ1Ng=="); | ||
expect(response?.champ).toMatchObject({ | ||
id: "Q2hhbXAtMTQ1Ng==", | ||
dossierNumber: 221, | ||
}); | ||
expect(response?.champ.files).toHaveLength(1); | ||
}); | ||
|
||
it("get one files from dossiers in repetable of annotation ", async () => { | ||
const response = await dsApiClient.dossierFile( | ||
221, | ||
"Q2hhbXAtMTQ1OHwwMUhOWVkyMENWR1pNMUtUOEI2RTk5Q1QyMg==", | ||
); | ||
expect(response?.champ).toMatchObject({ | ||
id: "Q2hhbXAtMTQ1OHwwMUhOWVkyMENWR1pNMUtUOEI2RTk5Q1QyMg==", | ||
dossierNumber: 221, | ||
}); | ||
expect(response?.champ.files).toHaveLength(1); | ||
}); | ||
|
||
it("get one files from dossiers in message ", async () => { | ||
const response = await dsApiClient.dossierFile(221, "Q29tbWVudGFpcmUtMjM3"); | ||
expect(response?.champ).toMatchObject({ | ||
id: "Q29tbWVudGFpcmUtMjM3", | ||
dossierNumber: 221, | ||
}); | ||
expect(response?.champ.files).toHaveLength(1); | ||
}); | ||
|
||
it("get attestation from dossiers ", async () => { | ||
const response = await dsApiClient.dossierAttestation(222); | ||
expect(response?.champ.id).toBeUndefined(); | ||
expect(response?.champ).toMatchObject({ | ||
dossierNumber: 222, | ||
}); | ||
expect(response?.champ.files).toHaveLength(1); | ||
}); | ||
}); |