[ACS-8664] generic question redirection to hx insight (#10174)

* ACS-8664 Loading HX insight url

* ACS-8664 Added documentation for loading config of Knowledge Retrieval

* ACS-8664 Unit tests

* ACS-8664 Fixed unit tests

* ACS-8664 Fixed unit tests after rebase

* ACS-8664 Addressed comment
This commit is contained in:
AleksanderSklorz
2024-09-09 11:55:01 +02:00
committed by Aleksander Sklorz
parent 13fc92e62c
commit 0a717d612f
10 changed files with 184 additions and 72 deletions

View File

@@ -44,27 +44,17 @@ describe('SearchAiApi', () => {
{
question: 'some question 1',
nodeIds: ['some node id 1'],
agentId: 'some id 1'
},
{
question: 'some question 2',
nodeIds: ['some node id 2', 'some node id 3'],
agentId: 'some id 2'
agentId: 'id1'
}
])
.then((questions) => {
assert.deepStrictEqual(questions, [
{
questionId: 'some id 1',
question: 'some question 1',
restrictionQuery: 'some node id 1'
},
{
questionId: 'some id 2',
question: 'some question 2',
restrictionQuery: 'some node id 2,some node id 3'
assert.deepStrictEqual(questions, {
questionId: 'some id 1',
question: 'some question 1',
restrictionQuery: {
nodesIds: ['some node id 1']
}
]);
});
done();
});
});
@@ -91,4 +81,19 @@ describe('SearchAiApi', () => {
});
});
});
describe('getConfig', () => {
it('should load knowledge retrieval configuration', (done) => {
searchAiMock.mockGetConfig200Response();
searchAiApi.getConfig().then((config) => {
assert.deepStrictEqual(config, {
entry: {
knowledgeRetrievalUrl: 'https://some-url'
}
});
done();
});
});
});
});

View File

@@ -21,68 +21,49 @@ import nock from 'nock';
export class SearchAiMock extends BaseMock {
mockGetAsk200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/private/hxi/versions/1/questions', [
.post('/alfresco/api/-default-/private/hxi/versions/1/agents/id1/questions', [
{
question: 'some question 1',
restrictionQuery: 'some node id 1'
},
{
question: 'some question 2',
restrictionQuery: 'some node id 2,some node id 3'
restrictionQuery: {
nodesIds: ['some node id 1']
}
}
])
.reply(200, [
{
.reply(200, {
entry: {
question: 'some question 1',
questionId: 'some id 1',
restrictionQuery: 'some node id 1'
},
{
question: 'some question 2',
questionId: 'some id 2',
restrictionQuery: 'some node id 2,some node id 3'
restrictionQuery: {
nodesIds: ['some node id 1']
}
}
]);
});
}
mockGetAnswer200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/private/hxi/versions/1/answers/-default-?questionId=id1')
.get('/alfresco/api/-default-/private/hxi/versions/1/questions/id1/answers/-default-')
.reply(200, {
list: {
pagination: {
count: 2,
hasMoreItems: false,
skipCount: 0,
maxItems: 100
},
entries: [
entry: {
answer: 'Some answer 1',
questionId: 'some id 1',
references: [
{
entry: {
answer: 'Some answer 1',
questionId: 'some id 1',
references: [
{
referenceId: 'some reference id 1',
referenceText: 'some reference text 1'
}
]
}
},
{
entry: {
answer: 'Some answer 2',
questionId: 'some id 2',
references: [
{
referenceId: 'some reference id 2',
referenceText: 'some reference text 2'
}
]
}
referenceId: 'some reference id 1',
referenceText: 'some reference text 1'
}
]
}
});
}
mockGetConfig200Response(): void {
nock(this.host, { encodedQueryParams: true })
.get('/alfresco/api/-default-/private/hxi/versions/1/config/-default-')
.reply(200, {
entry: {
knowledgeRetrievalUrl: 'https://some-url'
}
});
}
}