-
Notifications
You must be signed in to change notification settings - Fork 44
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
Added Selenium tests for inventory page #75
base: react
Are you sure you want to change the base?
Conversation
osler/inventory/views.py
Outdated
patient_pk = request.POST['patient_pk'] | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
remove
osler/inventory/tests/test_live.py
Outdated
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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.
get rid of extra space
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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} | ||
/> | ||
/>} |
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.
remove extra brackets
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to find by ID instead of XPATH?
@@ -132,6 +132,7 @@ def form_valid(self, form): | |||
def drug_dispense(request): | |||
pk = request.POST['pk'] | |||
num = request.POST['num'] | |||
|
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.
remove extra line
No description provided.