-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add Room Combobox to Initial Room Schedule page #557
Conversation
The new room schedule path was added so that it appears in the list of tabs in the app header.
The existing API that is getting the room availability was updated so that its path is /api/rooms/availability instead so that this more general retrieval of rooms without availability can have the path /api/rooms. In order to get the room information, we are querying the existing roomListingViewRepository. While we do not technically need the capacity or campus information to build the room dropdown, we can reuse this service for the future room admin tab.
The existing room API's path was updated from /api/rooms/ to /api/rooms/availability so that our more general querying of room information can use the path /api/rooms/, so this is fixing the existing tests checking the room availability path.
This room schedule component includes a combobox that has a filter function that uses the mark-one regex filter function which allows a case insensitive search. It also allows you to search the middle of a word (e.g. if the room is 1414 Massachusetts Avenue 230, you could search "ave" to see this room as one of the search results). Two NoteText components were also added to the menu that show the (for now) hardcoded semester and currently selected room.
These tests check the results of calling the room controller. All rooms are returned as a result of calling the controller when the user is authenticated, and unauthenticated users will receive a forbidden status.
Codecov Report
@@ Coverage Diff @@
## develop #557 +/- ##
===========================================
- Coverage 96.12% 96.06% -0.07%
===========================================
Files 179 181 +2
Lines 3768 3812 +44
Branches 443 446 +3
===========================================
+ Hits 3622 3662 +40
- Misses 68 71 +3
- Partials 78 79 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
…e to use it The RoomMeetingResponse DTO has all of the properties that the original RoomResponse DTO had. The existing code related to room availability was updated to use the RoomMeetingResponse DTO, and the code related to the room combobox on the RoomSchedule page uses the RoomResponse DTO, which has the propeties id, name, campus, and capacity.
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.
This looks great, just a few small notes.
I'm also having some difficulty testing this in my browser - when I make a room selection, the room seems to have been successfully chosen, but the selection box is blank, the table is blank and no AJAX request seems to be being made to retrieve data. Is there something I'm doing wrong?
}); | ||
it('should return a nonempty array of data', function () { | ||
strictEqual(Array.isArray(result), true); | ||
notStrictEqual(result, 0); |
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.
Should this be result.length
?
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.
Yep, good call! I fixed this in dcd4821.
.createQueryBuilder() | ||
.select('id') | ||
.addSelect('name') | ||
.addSelect('campus') | ||
.addSelect('capacity') | ||
.getRawMany(); |
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.
I think you should be able to just replace this query builder call with Repository.find()
.
.createQueryBuilder() | |
.select('id') | |
.addSelect('name') | |
.addSelect('campus') | |
.addSelect('capacity') | |
.getRawMany(); | |
.find({ | |
select: ['name', 'campus', 'capacity'] | |
}); |
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.
This is good to know - thanks for the suggestion. I updated this in 68cdf9b.
const rawRooms = await locationRepo.createQueryBuilder('r') | ||
.select('CONCAT_WS(\' \', b.name, r.name)', 'name') | ||
.leftJoin('r.building', 'b') | ||
.leftJoin('b.campus', 'c') |
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.
Since you're not selecting anything from the campus
table, you can probably get rid of this JOIN
.
.leftJoin('b.campus', 'c') |
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.
Ah, that's a good point.. This was removed in b8221b7
|
||
const loadRooms = useCallback(async (): Promise<void> => { | ||
try { | ||
const roomList = await LocationAPI.getRooms(); |
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.
const roomList = await LocationAPI.getRooms(); | |
const roomList = await getRooms(); |
I'd suggest importing and using getRooms
instead of LocationAPI.getRooms()
here as the latter was producing a type error for me (likely due to the way things are exported/imported).
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.
It looks like we updated all the client APIs to export the functions in this style in this commit as a result of no longer being able to stub free-standing functions in Typescript 3.9.2+:
- Sinon stubbing failed after upgrade to 3.9.2 microsoft/TypeScript#38568
- Possible to stub a standalone utility function? sinonjs/sinon#562
What type error are you seeing in importing with LocationAPI
?
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.
I was getting Unsafe call of an any typed value
from @typescript-eslint/no-unsafe-call
.
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.
I wouldn't think this would be related to Sinon as this error was thrown in the production code. I think it has more to do with the way it's being imported here (from client/api/rooms
) and the way it's being exported (or rather isn't being exported ) from client/api
.
Adding export * from './rooms';
to src/client/api/index.ts
and then changing the import
statement to import { LocationApi } from 'client/api'
fixes this error.
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.
diff --git a/src/client/api/index.ts b/src/client/api/index.ts
index f19ee6b4..4c61a767 100644
--- a/src/client/api/index.ts
+++ b/src/client/api/index.ts
@@ -6,3 +6,4 @@ export * from './nonClassMeeting';
export * from './meetings';
export * from './reports';
export * from './httpStatus';
+export * from './rooms';
diff --git a/src/client/components/pages/RoomSchedule/RoomSchedule.tsx b/src/client/components/pages/RoomSchedule/RoomSchedule.tsx
index 3f9927cb..da1f7f57 100644
--- a/src/client/components/pages/RoomSchedule/RoomSchedule.tsx
+++ b/src/client/components/pages/RoomSchedule/RoomSchedule.tsx
@@ -1,4 +1,4 @@
-import { LocationAPI } from 'client/api/rooms';
+import { LocationAPI } from 'client/api';
import { AppMessage, MESSAGE_TYPE, MESSAGE_ACTION } from 'client/classes';
import { MenuFlex } from 'client/components/general';
import { VerticalSpace } from 'client/components/layout';
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.
@rmainseas Ah ok thanks for looking into this. I can make the update, but for some reason I am not seeing this error - do you think we have different versions of the linter or something like that?
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.
Yeah of course. Not sure, that's an interesting question and probably something we should look into....
This test was meant to check that the length of the data that is returned from the API was not 0.
Nothing is being queried in the campus table, so the join is not necessary.
…h of the columns individually
Thanks for reviewing this, Robert! As of now, the only thing that happens when selecting a room is that the text next to "Current Room:" is updated as an indication of what room was selected. The next ticket (#551) will implement the Room Schedule table for the selected room and the (for now) hardcoded semester. |
Ah, gotcha. For some reason, I'd thought it was meant to populate a schedule view below the dropdown. In that case, I'm going to approve this. Merge away. |
This PR adds the initial Room Schedule tab/page, which includes a combobox that contains all of the rooms in the database. The previously existing location controller method
getRoomAvailability
was using the/
route, and I updated the new controller methodgetRooms
to use this route instead. This was becausegetRooms
is more general and does not take parameters in order to find the room availability for a specific time (term/calendar year/day, etc).Types of changes
to change)
Checklist:
eslint
on the codePriority:
Related Issues:
Fixes #550