From 2ab014d6d7f35cd7e2c2d7ed4a15a96dee404ca7 Mon Sep 17 00:00:00 2001 From: Jeff Sun Date: Mon, 13 Jun 2022 13:35:55 -0400 Subject: [PATCH 01/10] add test --- examples/self-test-loop/package.json | 1 + examples/self-test-loop/src/config/index.ts | 2 + .../self-test-loop/src/config/search-group.ts | 25 ++++ .../self-test-loop/src/tests/search/index.ts | 136 ++++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 examples/self-test-loop/src/config/search-group.ts create mode 100644 examples/self-test-loop/src/tests/search/index.ts diff --git a/examples/self-test-loop/package.json b/examples/self-test-loop/package.json index 5b394c9d1..cc7102af5 100644 --- a/examples/self-test-loop/package.json +++ b/examples/self-test-loop/package.json @@ -133,6 +133,7 @@ }, "system": {}, "screen": {}, + "search": {}, "keyboard": {}, "whisper": {}, "vault": {}, diff --git a/examples/self-test-loop/src/config/index.ts b/examples/self-test-loop/src/config/index.ts index eecd3dc09..81033cfad 100644 --- a/examples/self-test-loop/src/config/index.ts +++ b/examples/self-test-loop/src/config/index.ts @@ -9,6 +9,7 @@ import { filesystemTestGroup } from './filesystem-group'; import { keyboardTestGroup } from './keyboard-group'; import { networkTestGroup } from './network-group'; import { processTestGroup } from './process-group'; +import { searchTestsGroup } from './search-group'; import { screenTestGroup } from './screen-group'; import { systemTestGroup } from './system-group'; import { uiTestGroup } from './ui-group'; @@ -29,6 +30,7 @@ export const testConfig: { [key: string]: TestGroup } = { keyboard: keyboardTestGroup(), network: networkTestGroup(), process: processTestGroup(), + search: searchTestsGroup(), screen: screenTestGroup(), system: systemTestGroup(), ui: uiTestGroup(), diff --git a/examples/self-test-loop/src/config/search-group.ts b/examples/self-test-loop/src/config/search-group.ts new file mode 100644 index 000000000..51ef5c997 --- /dev/null +++ b/examples/self-test-loop/src/config/search-group.ts @@ -0,0 +1,25 @@ +import TestGroup from '../testingFixtures/testGroup'; +import { LoopTest } from '../testingFixtures/loopTest'; +import * as searchTests from '../tests/search'; + +export const searchTestsGroup = (): TestGroup => + new TestGroup('Search Aptitude', [ + new LoopTest( + 'Search Aptitude - Create Index', + searchTests.testSearchCreateIndex, + 10000, + 'test should pass automatically.', + ), + new LoopTest( + 'Search Aptitude - Create Index Search', + searchTests.testSearchCreateIndexSearch, + 10000, + 'Can you see search result?', + ), + new LoopTest( + 'Search Aptitude - Create Index Query String Search', + searchTests.testSearchCreateIndexQueryStringSearch, + 10000, + 'Can you see search result?', + ), + ]); diff --git a/examples/self-test-loop/src/tests/search/index.ts b/examples/self-test-loop/src/tests/search/index.ts new file mode 100644 index 000000000..9b4d3090b --- /dev/null +++ b/examples/self-test-loop/src/tests/search/index.ts @@ -0,0 +1,136 @@ +/* eslint-disable no-async-promise-executor */ +import { search, whisper, clipboard } from '@oliveai/ldk'; + +export const testSearchCreateIndex = (): Promise => + new Promise(async (resolve, reject) => { + // Whisper to instruct the user to get a test websocket URL from piesocket + await whisper.create({ + label: 'Create index test', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: 'testing create index', + }, + ], + }); + + const document: search.Document[] = [ + { + name: 'test', + data: JSON.stringify([]), + fields: [], + }, + ]; + + const index = await search.createIndex('testIndex', document, {}); + if (index != null) { + resolve(true); + } else { + reject('failed to create index'); + } + }); + +export const testSearchCreateIndexSearch = (): Promise => + new Promise(async (resolve, reject) => { + // Whisper to instruct the user to get a test websocket URL from piesocket + await whisper.create({ + label: 'Create index search test', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: 'testing create index search', + }, + ], + }); + + const document: search.Document[] = [ + { + name: 'test', + data: JSON.stringify([]), + }, + { + name: 'test1', + data: JSON.stringify([]), + }, + ]; + console.log(JSON.stringify(document)); + try { + search.createIndex('testIndex', document, {}).then(async (index) => { + //console.log(JSON.stringify(index)); + if (index != null) { + const searchResult = await index.search(''); + //console.log(JSON.stringify(searchResult)); + const body = 'search result: data:' + searchResult.data + ', total:' + searchResult.total; + await whisper.create({ + label: 'Search Result', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: body, + }, + ], + }); + resolve(true); + } else { + reject('failed to create index'); + } + }); + } catch (err) { + reject(err); + } + }); + +export const testSearchCreateIndexQueryStringSearch = (): Promise => + new Promise(async (resolve, reject) => { + // Whisper to instruct the user to get a test websocket URL from piesocket + await whisper.create({ + label: 'Create index search test', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: 'testing create index search', + }, + ], + }); + + const document: search.Document[] = [ + { + name: 'test', + data: JSON.stringify([]), + }, + { + name: 'test1', + data: JSON.stringify([]), + }, + ]; + console.log(JSON.stringify(document)); + try { + search.createIndex('testIndex', document, {}).then(async (index) => { + //console.log(JSON.stringify(index)); + if (index != null) { + const searchResult = await index.queryStringSearch('test'); + //console.log(JSON.stringify(searchResult)); + const body = 'search result: data:' + searchResult.data + ', total:' + searchResult.total; + await whisper.create({ + label: 'Search Result', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: body, + }, + ], + }); + resolve(true); + } else { + reject('failed to create index'); + } + }); + } catch (err) { + reject(err); + } + }); From 2f5b350d81d42db20c1f7c918e994407f70e3295 Mon Sep 17 00:00:00 2001 From: Jeff Sun Date: Tue, 14 Jun 2022 14:54:13 -0400 Subject: [PATCH 02/10] add test xlsx file --- .../self-test-loop/src/config/search-group.ts | 4 +- .../self-test-loop/src/tests/search/index.ts | 79 ++++++++++-------- examples/self-test-loop/static/test.xlsx | Bin 0 -> 4730 bytes 3 files changed, 46 insertions(+), 37 deletions(-) create mode 100644 examples/self-test-loop/static/test.xlsx diff --git a/examples/self-test-loop/src/config/search-group.ts b/examples/self-test-loop/src/config/search-group.ts index 51ef5c997..7c15505eb 100644 --- a/examples/self-test-loop/src/config/search-group.ts +++ b/examples/self-test-loop/src/config/search-group.ts @@ -10,7 +10,7 @@ export const searchTestsGroup = (): TestGroup => 10000, 'test should pass automatically.', ), - new LoopTest( + /*new LoopTest( 'Search Aptitude - Create Index Search', searchTests.testSearchCreateIndexSearch, 10000, @@ -21,5 +21,5 @@ export const searchTestsGroup = (): TestGroup => searchTests.testSearchCreateIndexQueryStringSearch, 10000, 'Can you see search result?', - ), + ),*/ ]); diff --git a/examples/self-test-loop/src/tests/search/index.ts b/examples/self-test-loop/src/tests/search/index.ts index 9b4d3090b..2ca30784b 100644 --- a/examples/self-test-loop/src/tests/search/index.ts +++ b/examples/self-test-loop/src/tests/search/index.ts @@ -1,8 +1,43 @@ /* eslint-disable no-async-promise-executor */ -import { search, whisper, clipboard } from '@oliveai/ldk'; +import { search, whisper, network, document } from '@oliveai/ldk'; +import { Worksheet, Row } from '@oliveai/ldk/dist/document/types'; + +function workSheet2Document(worksheet: Worksheet) { + const { name, rows } = worksheet; + const data = JSON.stringify( + rows.map((row: Row) => ({ + errorCode: row.cells[0].value, + name: row.cells[1].value, + description: row.cells[2].value, + })), + ); + + return { + name, + data, + }; +} export const testSearchCreateIndex = (): Promise => new Promise(async (resolve, reject) => { + let request = await network.httpRequest({ + url: 'https://github.com/open-olive/loop-development-kit/raw/develop/examples/self-test-loop/static/test.xlsx', + method: 'GET', + }); + let branch = 'develop'; + + // Above URL is used after this feature is finished and merged in + // Before PR is merged and branch is deleted, use the feature branch + // Can delete this block after merge + if (request.statusCode === 404) { + request = await network.httpRequest({ + url: 'https://github.com/open-olive/loop-development-kit/raw/HELPS-4731-search-aptitude-selftest/examples/self-test-loop/static/test.xlsx', + method: 'GET', + }); + branch = 'HELPS-4731-search-aptitude-selftest'; + } + const workbook = await document.xlsxDecode(request.body); + const documents = workbook.worksheets.map(workSheet2Document); // Whisper to instruct the user to get a test websocket URL from piesocket await whisper.create({ label: 'Create index test', @@ -15,15 +50,7 @@ export const testSearchCreateIndex = (): Promise => ], }); - const document: search.Document[] = [ - { - name: 'test', - data: JSON.stringify([]), - fields: [], - }, - ]; - - const index = await search.createIndex('testIndex', document, {}); + const index = await search.createIndex('testIndex', documents, {}); if (index != null) { resolve(true); } else { @@ -31,7 +58,7 @@ export const testSearchCreateIndex = (): Promise => } }); -export const testSearchCreateIndexSearch = (): Promise => +/*export const testSearchCreateIndexSearch = (): Promise => new Promise(async (resolve, reject) => { // Whisper to instruct the user to get a test websocket URL from piesocket await whisper.create({ @@ -45,19 +72,9 @@ export const testSearchCreateIndexSearch = (): Promise => ], }); - const document: search.Document[] = [ - { - name: 'test', - data: JSON.stringify([]), - }, - { - name: 'test1', - data: JSON.stringify([]), - }, - ]; console.log(JSON.stringify(document)); try { - search.createIndex('testIndex', document, {}).then(async (index) => { + search.createIndex('testIndex', document, getConfig()).then(async (index) => { //console.log(JSON.stringify(index)); if (index != null) { const searchResult = await index.search(''); @@ -97,23 +114,15 @@ export const testSearchCreateIndexQueryStringSearch = (): Promise => ], }); - const document: search.Document[] = [ - { - name: 'test', - data: JSON.stringify([]), - }, - { - name: 'test1', - data: JSON.stringify([]), - }, - ]; + const document = getDocuments(); + console.log(JSON.stringify(document)); try { - search.createIndex('testIndex', document, {}).then(async (index) => { + search.createIndex('testIndex', document, getConfig()).then(async (index) => { //console.log(JSON.stringify(index)); if (index != null) { const searchResult = await index.queryStringSearch('test'); - //console.log(JSON.stringify(searchResult)); + const body = 'search result: data:' + searchResult.data + ', total:' + searchResult.total; await whisper.create({ label: 'Search Result', @@ -133,4 +142,4 @@ export const testSearchCreateIndexQueryStringSearch = (): Promise => } catch (err) { reject(err); } - }); + });*/ diff --git a/examples/self-test-loop/static/test.xlsx b/examples/self-test-loop/static/test.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..1c563692ebf3e945561d4bd1a1425f3a2971cd76 GIT binary patch literal 4730 zcmai12Rzh&AIF*DjI+*`6%uEcJrm)q;xZyS^9W@oGtP>$Y1kv9xRAXvuk6toksTq) zNXB#YJpa`5{QuAA*6;Uv-S>U>{d_;4_vihFY6A%A@JLBX@tDnfjPOnc6Yko}NyNs@ z%F`YJcmK}?+*Pv%`Ef6o(-Qg6zuGY82CloH6VJ&6jou9I&@hW_L;QFJmMrP5 z%Rj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Scv?JY|@_yf60 Date: Tue, 14 Jun 2022 15:23:06 -0400 Subject: [PATCH 03/10] update test file --- .../self-test-loop/src/tests/search/index.ts | 60 ++++++++++++++---- examples/self-test-loop/static/test.xlsx | Bin 4730 -> 4767 bytes 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/examples/self-test-loop/src/tests/search/index.ts b/examples/self-test-loop/src/tests/search/index.ts index 2ca30784b..8c51e70c2 100644 --- a/examples/self-test-loop/src/tests/search/index.ts +++ b/examples/self-test-loop/src/tests/search/index.ts @@ -6,9 +6,9 @@ function workSheet2Document(worksheet: Worksheet) { const { name, rows } = worksheet; const data = JSON.stringify( rows.map((row: Row) => ({ - errorCode: row.cells[0].value, - name: row.cells[1].value, - description: row.cells[2].value, + testName: row.cells[0].value, + number: row.cells[1].value, + name: row.cells[2].value, })), ); @@ -38,7 +38,7 @@ export const testSearchCreateIndex = (): Promise => } const workbook = await document.xlsxDecode(request.body); const documents = workbook.worksheets.map(workSheet2Document); - // Whisper to instruct the user to get a test websocket URL from piesocket + await whisper.create({ label: 'Create index test', onClose: () => undefined, @@ -49,7 +49,7 @@ export const testSearchCreateIndex = (): Promise => }, ], }); - + console.log(JSON.stringify(documents)); const index = await search.createIndex('testIndex', documents, {}); if (index != null) { resolve(true); @@ -58,9 +58,26 @@ export const testSearchCreateIndex = (): Promise => } }); -/*export const testSearchCreateIndexSearch = (): Promise => +export const testSearchCreateIndexSearch = (): Promise => new Promise(async (resolve, reject) => { - // Whisper to instruct the user to get a test websocket URL from piesocket + let request = await network.httpRequest({ + url: 'https://github.com/open-olive/loop-development-kit/raw/develop/examples/self-test-loop/static/test.xlsx', + method: 'GET', + }); + let branch = 'develop'; + + // Above URL is used after this feature is finished and merged in + // Before PR is merged and branch is deleted, use the feature branch + // Can delete this block after merge + if (request.statusCode === 404) { + request = await network.httpRequest({ + url: 'https://github.com/open-olive/loop-development-kit/raw/HELPS-4731-search-aptitude-selftest/examples/self-test-loop/static/test.xlsx', + method: 'GET', + }); + branch = 'HELPS-4731-search-aptitude-selftest'; + } + const workbook = await document.xlsxDecode(request.body); + const documents = workbook.worksheets.map(workSheet2Document); await whisper.create({ label: 'Create index search test', onClose: () => undefined, @@ -72,9 +89,9 @@ export const testSearchCreateIndex = (): Promise => ], }); - console.log(JSON.stringify(document)); + console.log(JSON.stringify(documents)); try { - search.createIndex('testIndex', document, getConfig()).then(async (index) => { + search.createIndex('testIndex', documents, {}).then(async (index) => { //console.log(JSON.stringify(index)); if (index != null) { const searchResult = await index.search(''); @@ -102,7 +119,24 @@ export const testSearchCreateIndex = (): Promise => export const testSearchCreateIndexQueryStringSearch = (): Promise => new Promise(async (resolve, reject) => { - // Whisper to instruct the user to get a test websocket URL from piesocket + let request = await network.httpRequest({ + url: 'https://github.com/open-olive/loop-development-kit/raw/develop/examples/self-test-loop/static/test.xlsx', + method: 'GET', + }); + let branch = 'develop'; + + // Above URL is used after this feature is finished and merged in + // Before PR is merged and branch is deleted, use the feature branch + // Can delete this block after merge + if (request.statusCode === 404) { + request = await network.httpRequest({ + url: 'https://github.com/open-olive/loop-development-kit/raw/HELPS-4731-search-aptitude-selftest/examples/self-test-loop/static/test.xlsx', + method: 'GET', + }); + branch = 'HELPS-4731-search-aptitude-selftest'; + } + const workbook = await document.xlsxDecode(request.body); + const documents = workbook.worksheets.map(workSheet2Document); await whisper.create({ label: 'Create index search test', onClose: () => undefined, @@ -114,11 +148,9 @@ export const testSearchCreateIndexQueryStringSearch = (): Promise => ], }); - const document = getDocuments(); - console.log(JSON.stringify(document)); try { - search.createIndex('testIndex', document, getConfig()).then(async (index) => { + search.createIndex('testIndex', documents, {}).then(async (index) => { //console.log(JSON.stringify(index)); if (index != null) { const searchResult = await index.queryStringSearch('test'); @@ -142,4 +174,4 @@ export const testSearchCreateIndexQueryStringSearch = (): Promise => } catch (err) { reject(err); } - });*/ + }); diff --git a/examples/self-test-loop/static/test.xlsx b/examples/self-test-loop/static/test.xlsx index 1c563692ebf3e945561d4bd1a1425f3a2971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C2Y&TltkcYHmv)@;&$MfGk87S)vjr_cCp+P}qQ>sr-^Z?~@BfAU`U_J`}= zc9b7cPYIZ)d6PZsiHM|}_*H=JfA6zEo*n$eU?hN3<7|e%aQ! z-S=O1b(qEB54T_D)y+EN=U-Ov?dVdcy??i}Xe}+f^J;0&-6MbBFZsb9;LXkCB*Lf5NU_-{;76$Uwl=|AFkGH@Ua8lqN0VJ}CTx z(aCySV_J}L@WtEFg%^8If4Ae`ml;?J<}olZ+y!D3 z?_A;FV*+{S30D)?TNykC;M6>e_a#WUm9GrU{mbvdClz}x1Q9Hg{RJ#Q{_hl!VGNtR zOuz`lxdr4zP5v&RBo9)IY^ey)Vgxum*+Nhmq#;&NhH>%aDnS_#XNI7R{bnu(hKd~h z^8BLgr2PDBy^7qN0B=Sn5e8UxI~Oud@?h{QpjkVa7#O4wW&&B}Jd-PUWG3?q@qmnz n6_R1hoNOf|1$Ins$Cdz7V1!BnBUBhgSIFdIAvLyB{2)O92T*-F From 5c2b7612c938a36e165391b414e9cf82eae5c3cc Mon Sep 17 00:00:00 2001 From: Jeff Sun Date: Tue, 14 Jun 2022 16:11:12 -0400 Subject: [PATCH 04/10] update test search --- .../self-test-loop/src/config/search-group.ts | 4 +- .../self-test-loop/src/tests/search/index.ts | 98 ++++++++++--------- 2 files changed, 55 insertions(+), 47 deletions(-) diff --git a/examples/self-test-loop/src/config/search-group.ts b/examples/self-test-loop/src/config/search-group.ts index 7c15505eb..51ef5c997 100644 --- a/examples/self-test-loop/src/config/search-group.ts +++ b/examples/self-test-loop/src/config/search-group.ts @@ -10,7 +10,7 @@ export const searchTestsGroup = (): TestGroup => 10000, 'test should pass automatically.', ), - /*new LoopTest( + new LoopTest( 'Search Aptitude - Create Index Search', searchTests.testSearchCreateIndexSearch, 10000, @@ -21,5 +21,5 @@ export const searchTestsGroup = (): TestGroup => searchTests.testSearchCreateIndexQueryStringSearch, 10000, 'Can you see search result?', - ),*/ + ), ]); diff --git a/examples/self-test-loop/src/tests/search/index.ts b/examples/self-test-loop/src/tests/search/index.ts index 8c51e70c2..bb50b6212 100644 --- a/examples/self-test-loop/src/tests/search/index.ts +++ b/examples/self-test-loop/src/tests/search/index.ts @@ -1,6 +1,7 @@ /* eslint-disable no-async-promise-executor */ import { search, whisper, network, document } from '@oliveai/ldk'; import { Worksheet, Row } from '@oliveai/ldk/dist/document/types'; +import { resolveRejectButtons } from '../whisper/utils'; function workSheet2Document(worksheet: Worksheet) { const { name, rows } = worksheet; @@ -90,28 +91,31 @@ export const testSearchCreateIndexSearch = (): Promise => }); console.log(JSON.stringify(documents)); + const index = await search.createIndex('Test Index', documents, {}); try { - search.createIndex('testIndex', documents, {}).then(async (index) => { - //console.log(JSON.stringify(index)); - if (index != null) { - const searchResult = await index.search(''); - //console.log(JSON.stringify(searchResult)); - const body = 'search result: data:' + searchResult.data + ', total:' + searchResult.total; - await whisper.create({ - label: 'Search Result', - onClose: () => undefined, - components: [ - { - type: whisper.WhisperComponentType.Markdown, - body: body, - }, - ], - }); - resolve(true); - } else { - reject('failed to create index'); - } - }); + //console.log(JSON.stringify(index)); + if (index != null) { + const searchResult = await index.search('Dev'); + //console.log(JSON.stringify(searchResult)); + const body = + 'search result for "Dev": data:' + + JSON.stringify(searchResult.data) + + ', total:' + + searchResult.total; + await whisper.create({ + label: 'Search Result for "Dev" ', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: body, + }, + resolveRejectButtons(resolve, reject), + ], + }); + } else { + reject('failed to create index'); + } } catch (err) { reject(err); } @@ -137,40 +141,44 @@ export const testSearchCreateIndexQueryStringSearch = (): Promise => } const workbook = await document.xlsxDecode(request.body); const documents = workbook.worksheets.map(workSheet2Document); + await whisper.create({ - label: 'Create index search test', + label: 'Index query search test', onClose: () => undefined, components: [ { type: whisper.WhisperComponentType.Markdown, - body: 'testing create index search', + body: 'testing index query string search', }, ], }); - console.log(JSON.stringify(document)); + console.log(JSON.stringify(documents)); + const index = await search.createIndex('Test Index', documents, {}); try { - search.createIndex('testIndex', documents, {}).then(async (index) => { - //console.log(JSON.stringify(index)); - if (index != null) { - const searchResult = await index.queryStringSearch('test'); - - const body = 'search result: data:' + searchResult.data + ', total:' + searchResult.total; - await whisper.create({ - label: 'Search Result', - onClose: () => undefined, - components: [ - { - type: whisper.WhisperComponentType.Markdown, - body: body, - }, - ], - }); - resolve(true); - } else { - reject('failed to create index'); - } - }); + //console.log(JSON.stringify(index)); + if (index != null) { + const searchResult = await index.search('Olive'); + //console.log(JSON.stringify(searchResult)); + const body = + 'search result for "Olive": data:' + + JSON.stringify(searchResult.data) + + ', total:' + + searchResult.total; + await whisper.create({ + label: 'Query String Search Result for "Olive" ', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: body, + }, + resolveRejectButtons(resolve, reject), + ], + }); + } else { + reject('failed to create index'); + } } catch (err) { reject(err); } From 3d7944aad3db717066e05ade6b0b19c5522ec381 Mon Sep 17 00:00:00 2001 From: Jeff Sun Date: Wed, 15 Jun 2022 11:41:20 -0400 Subject: [PATCH 05/10] add check exists test --- .../self-test-loop/src/config/search-group.ts | 6 +++ .../self-test-loop/src/tests/search/index.ts | 48 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/examples/self-test-loop/src/config/search-group.ts b/examples/self-test-loop/src/config/search-group.ts index 51ef5c997..572155d06 100644 --- a/examples/self-test-loop/src/config/search-group.ts +++ b/examples/self-test-loop/src/config/search-group.ts @@ -22,4 +22,10 @@ export const searchTestsGroup = (): TestGroup => 10000, 'Can you see search result?', ), + new LoopTest( + 'Search Aptitude - Search Index Exists', + searchTests.testSearchIndexExsit, + 10000, + 'Test should pass if index exist', + ), ]); diff --git a/examples/self-test-loop/src/tests/search/index.ts b/examples/self-test-loop/src/tests/search/index.ts index bb50b6212..a9086cbf7 100644 --- a/examples/self-test-loop/src/tests/search/index.ts +++ b/examples/self-test-loop/src/tests/search/index.ts @@ -183,3 +183,51 @@ export const testSearchCreateIndexQueryStringSearch = (): Promise => reject(err); } }); + +export const testSearchIndexExsit = (): Promise => + new Promise(async (resolve, reject) => { + let request = await network.httpRequest({ + url: 'https://github.com/open-olive/loop-development-kit/raw/develop/examples/self-test-loop/static/test.xlsx', + method: 'GET', + }); + let branch = 'develop'; + + // Above URL is used after this feature is finished and merged in + // Before PR is merged and branch is deleted, use the feature branch + // Can delete this block after merge + if (request.statusCode === 404) { + request = await network.httpRequest({ + url: 'https://github.com/open-olive/loop-development-kit/raw/HELPS-4731-search-aptitude-selftest/examples/self-test-loop/static/test.xlsx', + method: 'GET', + }); + branch = 'HELPS-4731-search-aptitude-selftest'; + } + const workbook = await document.xlsxDecode(request.body); + const documents = workbook.worksheets.map(workSheet2Document); + + await whisper.create({ + label: 'Search exist index test', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: 'testing index exist', + }, + ], + }); + + const index = await search.createIndex('testIndex', documents, {}); + + const indexExists = await search.exists('testIndex'); + await whisper.create({ + label: 'Search Index Exists ', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: 'Search Index Exists: ' + indexExists.toString(), + }, + resolveRejectButtons(resolve, reject), + ], + }); + }); From a7eca276331198c2ea071d6c0a1ebe924ac5891d Mon Sep 17 00:00:00 2001 From: Jeff Sun Date: Wed, 15 Jun 2022 13:11:17 -0400 Subject: [PATCH 06/10] change create/exist index test to use fake data --- .../self-test-loop/src/tests/search/index.ts | 56 +++++-------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/examples/self-test-loop/src/tests/search/index.ts b/examples/self-test-loop/src/tests/search/index.ts index a9086cbf7..03c7fe624 100644 --- a/examples/self-test-loop/src/tests/search/index.ts +++ b/examples/self-test-loop/src/tests/search/index.ts @@ -21,25 +21,13 @@ function workSheet2Document(worksheet: Worksheet) { export const testSearchCreateIndex = (): Promise => new Promise(async (resolve, reject) => { - let request = await network.httpRequest({ - url: 'https://github.com/open-olive/loop-development-kit/raw/develop/examples/self-test-loop/static/test.xlsx', - method: 'GET', - }); - let branch = 'develop'; - - // Above URL is used after this feature is finished and merged in - // Before PR is merged and branch is deleted, use the feature branch - // Can delete this block after merge - if (request.statusCode === 404) { - request = await network.httpRequest({ - url: 'https://github.com/open-olive/loop-development-kit/raw/HELPS-4731-search-aptitude-selftest/examples/self-test-loop/static/test.xlsx', - method: 'GET', - }); - branch = 'HELPS-4731-search-aptitude-selftest'; - } - const workbook = await document.xlsxDecode(request.body); - const documents = workbook.worksheets.map(workSheet2Document); - + const documents: search.Document[] = [ + { + name: 'test', + data: JSON.stringify([]), + fields: [], + }, + ]; await whisper.create({ label: 'Create index test', onClose: () => undefined, @@ -50,7 +38,6 @@ export const testSearchCreateIndex = (): Promise => }, ], }); - console.log(JSON.stringify(documents)); const index = await search.createIndex('testIndex', documents, {}); if (index != null) { resolve(true); @@ -89,8 +76,6 @@ export const testSearchCreateIndexSearch = (): Promise => }, ], }); - - console.log(JSON.stringify(documents)); const index = await search.createIndex('Test Index', documents, {}); try { //console.log(JSON.stringify(index)); @@ -153,7 +138,6 @@ export const testSearchCreateIndexQueryStringSearch = (): Promise => ], }); - console.log(JSON.stringify(documents)); const index = await search.createIndex('Test Index', documents, {}); try { //console.log(JSON.stringify(index)); @@ -186,25 +170,13 @@ export const testSearchCreateIndexQueryStringSearch = (): Promise => export const testSearchIndexExsit = (): Promise => new Promise(async (resolve, reject) => { - let request = await network.httpRequest({ - url: 'https://github.com/open-olive/loop-development-kit/raw/develop/examples/self-test-loop/static/test.xlsx', - method: 'GET', - }); - let branch = 'develop'; - - // Above URL is used after this feature is finished and merged in - // Before PR is merged and branch is deleted, use the feature branch - // Can delete this block after merge - if (request.statusCode === 404) { - request = await network.httpRequest({ - url: 'https://github.com/open-olive/loop-development-kit/raw/HELPS-4731-search-aptitude-selftest/examples/self-test-loop/static/test.xlsx', - method: 'GET', - }); - branch = 'HELPS-4731-search-aptitude-selftest'; - } - const workbook = await document.xlsxDecode(request.body); - const documents = workbook.worksheets.map(workSheet2Document); - + const documents: search.Document[] = [ + { + name: 'test', + data: JSON.stringify([]), + fields: [], + }, + ]; await whisper.create({ label: 'Search exist index test', onClose: () => undefined, From c49df57cd1c9e3e0e2ba97bfdd805ab5a62d0e05 Mon Sep 17 00:00:00 2001 From: Jeff Sun Date: Thu, 16 Jun 2022 16:33:27 -0400 Subject: [PATCH 07/10] added delete test, comment out now seems delete is not working as expected --- .../self-test-loop/src/config/search-group.ts | 6 +++ .../self-test-loop/src/tests/search/index.ts | 42 +++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/examples/self-test-loop/src/config/search-group.ts b/examples/self-test-loop/src/config/search-group.ts index 572155d06..2463ea3da 100644 --- a/examples/self-test-loop/src/config/search-group.ts +++ b/examples/self-test-loop/src/config/search-group.ts @@ -28,4 +28,10 @@ export const searchTestsGroup = (): TestGroup => 10000, 'Test should pass if index exist', ), + /* new LoopTest( + 'Search Aptitude - Search Index Delete', + searchTests.testSearchIndexDelete, + 10000, + 'Test should pass if index has been deleted', + ), */ ]); diff --git a/examples/self-test-loop/src/tests/search/index.ts b/examples/self-test-loop/src/tests/search/index.ts index 03c7fe624..03c0adcbc 100644 --- a/examples/self-test-loop/src/tests/search/index.ts +++ b/examples/self-test-loop/src/tests/search/index.ts @@ -38,7 +38,7 @@ export const testSearchCreateIndex = (): Promise => }, ], }); - const index = await search.createIndex('testIndex', documents, {}); + const index = await search.createIndex('Create Index', documents, {}); if (index != null) { resolve(true); } else { @@ -188,9 +188,9 @@ export const testSearchIndexExsit = (): Promise => ], }); - const index = await search.createIndex('testIndex', documents, {}); + const index = await search.createIndex('Exist Index', documents, {}); - const indexExists = await search.exists('testIndex'); + const indexExists = await search.exists('Exist Index'); await whisper.create({ label: 'Search Index Exists ', onClose: () => undefined, @@ -203,3 +203,39 @@ export const testSearchIndexExsit = (): Promise => ], }); }); + +/* export const testSearchIndexDelete = (): Promise => + new Promise(async (resolve, reject) => { + const documents: search.Document[] = [ + { + name: 'test', + data: JSON.stringify([]), + fields: [], + }, + ]; + await whisper.create({ + label: 'Search Delete index test', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: 'testing delete index', + }, + ], + }); + + const index = await search.createIndex('Delete Index', documents, {}); + await index.delete(); + const indexExists = await search.exists('Delete Index'); + await whisper.create({ + label: 'Search Index Delete ', + onClose: () => undefined, + components: [ + { + type: whisper.WhisperComponentType.Markdown, + body: 'Search Index Exists(should be false): ' + indexExists.toString(), + }, + resolveRejectButtons(resolve, reject), + ], + }); + }); */ From e29e2a8c3f40261400728205df01dddfa80731ee Mon Sep 17 00:00:00 2001 From: Jeff Sun Date: Thu, 16 Jun 2022 16:38:47 -0400 Subject: [PATCH 08/10] update property name --- examples/self-test-loop/src/config/index.ts | 4 ++-- examples/self-test-loop/src/config/search-group.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/self-test-loop/src/config/index.ts b/examples/self-test-loop/src/config/index.ts index 81033cfad..89742df00 100644 --- a/examples/self-test-loop/src/config/index.ts +++ b/examples/self-test-loop/src/config/index.ts @@ -9,7 +9,7 @@ import { filesystemTestGroup } from './filesystem-group'; import { keyboardTestGroup } from './keyboard-group'; import { networkTestGroup } from './network-group'; import { processTestGroup } from './process-group'; -import { searchTestsGroup } from './search-group'; +import { searchTestGroup } from './search-group'; import { screenTestGroup } from './screen-group'; import { systemTestGroup } from './system-group'; import { uiTestGroup } from './ui-group'; @@ -30,7 +30,7 @@ export const testConfig: { [key: string]: TestGroup } = { keyboard: keyboardTestGroup(), network: networkTestGroup(), process: processTestGroup(), - search: searchTestsGroup(), + search: searchTestGroup(), screen: screenTestGroup(), system: systemTestGroup(), ui: uiTestGroup(), diff --git a/examples/self-test-loop/src/config/search-group.ts b/examples/self-test-loop/src/config/search-group.ts index 2463ea3da..b54bfea71 100644 --- a/examples/self-test-loop/src/config/search-group.ts +++ b/examples/self-test-loop/src/config/search-group.ts @@ -2,7 +2,7 @@ import TestGroup from '../testingFixtures/testGroup'; import { LoopTest } from '../testingFixtures/loopTest'; import * as searchTests from '../tests/search'; -export const searchTestsGroup = (): TestGroup => +export const searchTestGroup = (): TestGroup => new TestGroup('Search Aptitude', [ new LoopTest( 'Search Aptitude - Create Index', From 70a4de3cac86e59b206b1d3c0d2d96dfa68cb6ae Mon Sep 17 00:00:00 2001 From: Jeff Sun Date: Fri, 17 Jun 2022 12:38:29 -0400 Subject: [PATCH 09/10] update tests name --- examples/self-test-loop/src/config/search-group.ts | 4 ++-- examples/self-test-loop/src/tests/search/index.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/self-test-loop/src/config/search-group.ts b/examples/self-test-loop/src/config/search-group.ts index b54bfea71..f8d5cf884 100644 --- a/examples/self-test-loop/src/config/search-group.ts +++ b/examples/self-test-loop/src/config/search-group.ts @@ -11,13 +11,13 @@ export const searchTestGroup = (): TestGroup => 'test should pass automatically.', ), new LoopTest( - 'Search Aptitude - Create Index Search', + 'Search Aptitude - Index Search', searchTests.testSearchCreateIndexSearch, 10000, 'Can you see search result?', ), new LoopTest( - 'Search Aptitude - Create Index Query String Search', + 'Search Aptitude - Index Query String Search', searchTests.testSearchCreateIndexQueryStringSearch, 10000, 'Can you see search result?', diff --git a/examples/self-test-loop/src/tests/search/index.ts b/examples/self-test-loop/src/tests/search/index.ts index 03c0adcbc..ffd4b2919 100644 --- a/examples/self-test-loop/src/tests/search/index.ts +++ b/examples/self-test-loop/src/tests/search/index.ts @@ -67,7 +67,7 @@ export const testSearchCreateIndexSearch = (): Promise => const workbook = await document.xlsxDecode(request.body); const documents = workbook.worksheets.map(workSheet2Document); await whisper.create({ - label: 'Create index search test', + label: 'Index search test', onClose: () => undefined, components: [ { @@ -204,6 +204,7 @@ export const testSearchIndexExsit = (): Promise => }); }); +//TODO: track what causes delete functon doesn't work as expected. /* export const testSearchIndexDelete = (): Promise => new Promise(async (resolve, reject) => { const documents: search.Document[] = [ From 4116a5963b41fd8eb22025a744b87e326b27c8d2 Mon Sep 17 00:00:00 2001 From: Jeff Sun Date: Fri, 17 Jun 2022 16:24:34 -0400 Subject: [PATCH 10/10] update whisper to show document contents --- .../self-test-loop/src/tests/search/index.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/self-test-loop/src/tests/search/index.ts b/examples/self-test-loop/src/tests/search/index.ts index ffd4b2919..3da634700 100644 --- a/examples/self-test-loop/src/tests/search/index.ts +++ b/examples/self-test-loop/src/tests/search/index.ts @@ -72,7 +72,11 @@ export const testSearchCreateIndexSearch = (): Promise => components: [ { type: whisper.WhisperComponentType.Markdown, - body: 'testing create index search', + body: 'Document Contents: ', + }, + { + type: whisper.WhisperComponentType.Markdown, + body: JSON.stringify(documents), }, ], }); @@ -128,22 +132,25 @@ export const testSearchCreateIndexQueryStringSearch = (): Promise => const documents = workbook.worksheets.map(workSheet2Document); await whisper.create({ - label: 'Index query search test', + label: 'Index query string search test', onClose: () => undefined, components: [ { type: whisper.WhisperComponentType.Markdown, - body: 'testing index query string search', + body: 'Document Contents: ', + }, + { + type: whisper.WhisperComponentType.Markdown, + body: JSON.stringify(documents), }, ], }); const index = await search.createIndex('Test Index', documents, {}); try { - //console.log(JSON.stringify(index)); if (index != null) { const searchResult = await index.search('Olive'); - //console.log(JSON.stringify(searchResult)); + const body = 'search result for "Olive": data:' + JSON.stringify(searchResult.data) +