-
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.
fall back to romeRepository when appellationGateway (diagoriente) tak…
…es more than 700ms
- Loading branch information
Showing
4 changed files
with
110 additions
and
15 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
81 changes: 81 additions & 0 deletions
81
back/src/domains/core/rome/use-cases/AppellationSearch.manual.test.ts
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,81 @@ | ||
import { AppellationAndRomeDto, expectToEqual } from "shared"; | ||
import { InMemoryUowPerformer } from "../../unit-of-work/adapters/InMemoryUowPerformer"; | ||
import { createInMemoryUow } from "../../unit-of-work/adapters/createInMemoryUow"; | ||
import { InMemoryAppellationsGateway } from "../adapters/InMemoryAppellationsGateway"; | ||
import { InMemoryRomeRepository } from "../adapters/InMemoryRomeRepository"; | ||
import { AppellationSearch } from "./AppellationSearch"; | ||
|
||
describe("AppellationSearch Manual test, which take to long to run in CI", () => { | ||
let romeRepo: InMemoryRomeRepository; | ||
let appellationsGateway: InMemoryAppellationsGateway; | ||
let appellationSearch: AppellationSearch; | ||
|
||
beforeEach(() => { | ||
romeRepo = new InMemoryRomeRepository(); | ||
appellationsGateway = new InMemoryAppellationsGateway(); | ||
appellationSearch = new AppellationSearch( | ||
new InMemoryUowPerformer({ | ||
...createInMemoryUow(), | ||
romeRepository: romeRepo, | ||
}), | ||
appellationsGateway, | ||
); | ||
}); | ||
|
||
it("has a fallback when diagoriente searchAppellations takes too long", async () => { | ||
appellationsGateway.setNextSearchAppellationsResult([ | ||
{ appellationCode: "19364", appellationLabel: "Secrétaire" }, | ||
]); | ||
|
||
const appellation: AppellationAndRomeDto = { | ||
romeCode: "M1607", | ||
appellationCode: "19364", | ||
appellationLabel: "Secrétaire", | ||
romeLabel: "Secrétariat", | ||
}; | ||
|
||
const appellationFallback: AppellationAndRomeDto = { | ||
romeCode: "M1607", | ||
appellationCode: "19367", | ||
appellationLabel: | ||
"Secrétaire bureautique spécialisé / spécialisée - FALLBACK", | ||
romeLabel: "Secrétariat", | ||
}; | ||
|
||
romeRepo.appellations = [appellation, appellationFallback]; | ||
|
||
appellationsGateway.setDelayInMs(680); | ||
|
||
expectToEqual( | ||
await appellationSearch.execute({ | ||
searchText: "secretaire", | ||
fetchAppellationsFromNaturalLanguage: true, | ||
}), | ||
[ | ||
{ | ||
appellation: appellation, | ||
matchRanges: [{ startIndexInclusive: 0, endIndexExclusive: 10 }], | ||
}, | ||
], | ||
); | ||
|
||
appellationsGateway.setDelayInMs(720); | ||
|
||
expectToEqual( | ||
await appellationSearch.execute({ | ||
searchText: "secretaire", | ||
fetchAppellationsFromNaturalLanguage: true, | ||
}), | ||
[ | ||
{ | ||
appellation: appellation, | ||
matchRanges: [{ startIndexInclusive: 0, endIndexExclusive: 10 }], | ||
}, | ||
{ | ||
appellation: appellationFallback, | ||
matchRanges: [{ startIndexInclusive: 0, endIndexExclusive: 10 }], | ||
}, | ||
], | ||
); | ||
}); | ||
}); |
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