-
-
Notifications
You must be signed in to change notification settings - Fork 218
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(#9544): add offline freetext search indexes #9661
Open
jkuester
wants to merge
10
commits into
master
Choose a base branch
from
9544_offline_freetext
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e270148
Add offline ddoc logic to webapp along with initial contacts_by_freet…
jkuester 710fdb0
Emit key:value entries from offline freetext index.
jkuester c2e3122
Fix ngOnInit to not be async
jkuester def8409
Hack shared-libs/search to use offline freetext search
jkuester eab8896
Move offline ddoc logic to the bootstrapper js code.
jkuester 24f4869
Update search e2e test to run for both online and offline users
jkuester 54981cc
Refactor bootstrapper to use proper async/await code
jkuester 8c01ca1
Add offline contacts_by_type_freetext index
jkuester 6ee1020
Fix SONAR issues
jkuester cb6abd9
Add offline index for reports_by_freetext
jkuester File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -5,63 +5,101 @@ const contactPage = require('@page-objects/default/contacts/contacts.wdio.page') | |||||
const commonPage = require('@page-objects/default/common/common.wdio.page'); | ||||||
const placeFactory = require('@factories/cht/contacts/place'); | ||||||
const personFactory = require('@factories/cht/contacts/person'); | ||||||
const userFactory = require('@factories/cht/users/users'); | ||||||
|
||||||
describe('Contact Search', () => { | ||||||
const places = placeFactory.generateHierarchy(); | ||||||
const districtHospitalId = places.get('district_hospital')._id; | ||||||
|
||||||
const sittuHospital = placeFactory.place().build({ | ||||||
name: 'Sittu Hospital', | ||||||
type: 'district_hospital', | ||||||
parent: { _id: '', parent: { _id: '' } } | ||||||
const sittuHealthCenter = placeFactory.place().build({ | ||||||
name: 'Sittu Health Center', | ||||||
type: 'health_center', | ||||||
parent: { _id: districtHospitalId, parent: { _id: '' } } | ||||||
}); | ||||||
|
||||||
const potuHospital = placeFactory.place().build({ | ||||||
name: 'Potu Hospital', | ||||||
type: 'district_hospital', | ||||||
parent: { _id: '', parent: { _id: '' } } | ||||||
const potuHealthCenter = placeFactory.place().build({ | ||||||
Comment on lines
+14
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: what's a |
||||||
name: 'Potu Health Center', | ||||||
type: 'health_center', | ||||||
parent: { _id: districtHospitalId, parent: { _id: '' } } | ||||||
}); | ||||||
|
||||||
const sittuPerson = personFactory.build({ | ||||||
name: 'Sittu', | ||||||
parent: { _id: sittuHospital._id, parent: sittuHospital.parent } | ||||||
parent: { _id: sittuHealthCenter._id, parent: sittuHealthCenter.parent } | ||||||
}); | ||||||
|
||||||
const potuPerson = personFactory.build({ | ||||||
name: 'Potu', | ||||||
parent: { _id: sittuHospital._id, parent: sittuHospital.parent } | ||||||
parent: { _id: sittuHealthCenter._id, parent: sittuHealthCenter.parent } | ||||||
}); | ||||||
|
||||||
before(async () => { | ||||||
await utils.saveDocs([...places.values(), sittuHospital, sittuPerson, potuHospital, potuPerson]); | ||||||
await loginPage.cookieLogin(); | ||||||
await commonPage.goToPeople(); | ||||||
const supervisorPerson = personFactory.build({ | ||||||
name: 'Supervisor', | ||||||
parent: { _id: districtHospitalId } | ||||||
}); | ||||||
|
||||||
it('search by NON empty string should display results with contains match and clears search', async () => { | ||||||
await contactPage.getAllLHSContactsNames(); | ||||||
|
||||||
await searchPage.performSearch('sittu'); | ||||||
expect(await contactPage.getAllLHSContactsNames()).to.have.members([ | ||||||
sittuPerson.name, | ||||||
sittuHospital.name, | ||||||
]); | ||||||
const offlineUser = userFactory.build({ | ||||||
username: 'offline-search-user', | ||||||
place: districtHospitalId, | ||||||
roles: ['chw_supervisor'], | ||||||
contact: supervisorPerson._id | ||||||
}); | ||||||
const onlineUser = userFactory.build({ | ||||||
username: 'online-search-user', | ||||||
place: districtHospitalId, | ||||||
roles: ['program_officer'], | ||||||
contact: supervisorPerson._id | ||||||
}); | ||||||
|
||||||
await searchPage.clearSearch(); | ||||||
expect(await contactPage.getAllLHSContactsNames()).to.have.members([ | ||||||
potuHospital.name, | ||||||
sittuHospital.name, | ||||||
places.get('district_hospital').name, | ||||||
before(async () => { | ||||||
await utils.saveDocs([ | ||||||
...places.values(), sittuHealthCenter, sittuPerson, potuHealthCenter, potuPerson, supervisorPerson | ||||||
]); | ||||||
await utils.createUsers([offlineUser, onlineUser]); | ||||||
}); | ||||||
|
||||||
it('search should clear RHS selected contact', async () => { | ||||||
await contactPage.selectLHSRowByText(potuHospital.name, false); | ||||||
await contactPage.waitForContactLoaded(); | ||||||
expect(await (await contactPage.contactCardSelectors.contactCardName()).getText()).to.equal(potuHospital.name); | ||||||
after(() => utils.deleteUsers([offlineUser, onlineUser])); | ||||||
|
||||||
await searchPage.performSearch('sittu'); | ||||||
await contactPage.waitForContactUnloaded(); | ||||||
const url = await browser.getUrl(); | ||||||
expect(url.endsWith('/contacts')).to.equal(true); | ||||||
}); | ||||||
[ | ||||||
['online', onlineUser], | ||||||
['offline', offlineUser], | ||||||
].forEach(([userType, user]) => describe(`Logged in as an ${userType} user`, () => { | ||||||
before(async () => { | ||||||
await loginPage.login(user); | ||||||
await commonPage.goToPeople(); | ||||||
}); | ||||||
|
||||||
after(commonPage.logout); | ||||||
|
||||||
it('search by NON empty string should display results with contains match and clears search', async () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
await contactPage.getAllLHSContactsNames(); | ||||||
|
||||||
await searchPage.performSearch('sittu'); | ||||||
expect(await contactPage.getAllLHSContactsNames()).to.have.members([ | ||||||
sittuPerson.name, | ||||||
sittuHealthCenter.name, | ||||||
]); | ||||||
|
||||||
await searchPage.clearSearch(); | ||||||
expect(await contactPage.getAllLHSContactsNames()).to.have.members([ | ||||||
potuHealthCenter.name, | ||||||
sittuHealthCenter.name, | ||||||
places.get('district_hospital').name, | ||||||
places.get('health_center').name, | ||||||
]); | ||||||
}); | ||||||
|
||||||
it('search should clear RHS selected contact', async () => { | ||||||
await contactPage.selectLHSRowByText(potuHealthCenter.name, false); | ||||||
await contactPage.waitForContactLoaded(); | ||||||
expect( | ||||||
await (await contactPage.contactCardSelectors.contactCardName()).getText() | ||||||
).to.equal(potuHealthCenter.name); | ||||||
|
||||||
await searchPage.performSearch('sittu'); | ||||||
await contactPage.waitForContactUnloaded(); | ||||||
const url = await browser.getUrl(); | ||||||
expect(url.endsWith('/contacts')).to.equal(true); | ||||||
}); | ||||||
})); | ||||||
}); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes in
shared-libs/search
are just temporary. The proper changes will need to be made against the cht-datasource code once we re-base on top of that.This is why I have not added any additional unit tests to cover this logic (or worried too much about code structure).