Added Selenium tests for inventory page#75
Added Selenium tests for inventory page#75BenMueller1 wants to merge 29 commits intollemr-conspiracy:reactfrom
Conversation
osler/inventory/views.py
Outdated
| drug = models.Drug.objects.get(pk=pk) | ||
| patient = Patient.objects.get(pk=patient_pk) | ||
| can_dispense = drug.can_dispense(int(num)) | ||
| can_dispense = drug.can_dispense(int(num)) |
There was a problem hiding this comment.
don't want extra space at end of line
osler/inventory/views.py
Outdated
| @@ -1,5 +1,6 @@ | |||
| # -*- coding: utf-8 -*- | |||
| from __future__ import unicode_literals | |||
| import pdb | |||
osler/inventory/tests/test_live.py
Outdated
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
| const nameComparator = simpleComparator('name'); | ||
| const categoryComparator = simpleComparator('category'); | ||
| const expirationDateComparator = simpleComparator('expiration_date'); | ||
| const stockComparator = simpleComparator('stock'); | ||
| const doseComparator = React.useMemo(() => (rowA,rowB,columnId,desc) => { |
There was a problem hiding this comment.
When I checked with the drugExample data, sorting is not working for stock, expiration date, dose. Sort by manufacturer should ignore case differences
| {<SearchBar | ||
| globalFilter={state.globalFilter} | ||
| setGlobalFilter={setGlobalFilter} | ||
| /> | ||
| />} |
wwick
left a comment
There was a problem hiding this comment.
The sorting issue was not fixed with the last revision. See comments. There should be selenium tests to catch this and similar issues.
A big thing is that this PR has almost no comments (my fault mostly). A standard rule is that every function should have a comment explaining what it does. There should also be comments explaining why things are coded as they are
| const manufacturerComparator = React.useMemo(() => (rowA,rowB,columnId,desc) => { | ||
| let cmp = compare(rowA.original.unit,rowB.original.unit); | ||
| if (cmp == 0) { | ||
| cmp = compare(rowA.original.manufacturer.toLowerCase(), rowB.original.manufacturer.toLowerCase()); | ||
| } | ||
| return cmp; | ||
| }); |
There was a problem hiding this comment.
There shouldn't be any comparison of units. The simple lowerCase() comparator should work fine here
| const nameComparator = simpleComparator('name'); | ||
| const categoryComparator = simpleComparator('category'); | ||
| const expirationDateComparator = simpleComparator('expiration_date'); | ||
| const stockComparator = simpleComparator('stock'); |
There was a problem hiding this comment.
There's still a bug with the comparators. It seems that all the comparators after nameComparator are just returning the same result as the name comparator. I'm fairly certain this is a bug related to the memoization in simpleComparator. useMemo() is required by React Table, and it allows you to specify dependencies, which I'm guessing we need to do
There was a problem hiding this comment.
Correct sorting is something that the selenium tests really need to check for
| By.XPATH, | ||
| "/html[@class='no-js']/body[@class='modal-open']/div[@class='fade modal show']/div[@class='modal-dialog']/div[@class='modal-content']/form/div[@class='modal-footer']/button[@class='btn btn-primary']" | ||
| ).click() |
There was a problem hiding this comment.
is it possible to find by ID instead of XPATH?
| def drug_dispense(request): | ||
| pk = request.POST['pk'] | ||
| num = request.POST['num'] | ||
|
|
No description provided.