-
Notifications
You must be signed in to change notification settings - Fork 1
[PER-10357] Add fallback for stela folder calls #836
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #836 +/- ##
==========================================
+ Coverage 47.02% 47.10% +0.07%
==========================================
Files 372 372
Lines 11495 11496 +1
Branches 1909 1912 +3
==========================================
+ Hits 5406 5415 +9
+ Misses 5900 5898 -2
+ Partials 189 183 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8ce47af to
8120567
Compare
cecilia-donnelly
left a comment
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 don't think we should make properties optional to make tests pass - it seems to me that the test setup should match reality. It feels much better to me to include the location and files in the fakeRecordVO` than to adjust the record model to not always have those properties.
One housekeeping note is that the first two commit messages are the same, which confused me a little. I love the overall organization though!
That is indeed a very good point, properties should not be optional just to make a test pass. The reason I added some checks in the mappings for location, files, thumbnailUrls and paths(convertStelaFolderToFolderVO, convertStelaRecordToRecordVO, convertStelaLocationToLocnVOData) is to make sure that even if they do not come from BE, we do not block the whole flow with FE errors. The reasons the buttons "My Archive" and "View in my archive" were not working were:
Even though we should make sure those properties are defined from the BE, if it happens that they are not there for some reason, I believe it is better to show an empty field or some inconsistent value than blocking the whole interface.
They are the same, indeed 🫣 the only difference is that one says folder, the other one record. I chose to do this because it adds the same fallback functionality in both places😅. I am very glad that you like the organization, I also believe it looks so much cleaner and structured having distinctive commits with good descriptions. Big thanks to @slifty for being patient and helping me get here with it! |
This is a good point! I worry a bit about unintended/unexpected behavior if we don't have, say, a file. I can imagine what would happen with no thumbnails or location, though.
I missed that! 🤦♀️ Thanks :) |
cecilia-donnelly
left a comment
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 might be something local for me, but I didn't get the result I expected from the first test case.
I did the following:
- Create an unrestricted share link with Account A
- Log in to Account B in a private window
- Open the link as Account B
- Click the archive icon at the top right.
I expected to go to Account B's archive, but nothing happened.
8120567 to
6204ad0
Compare
6204ad0 to
ab652c2
Compare
omnignorant
left a comment
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.
huzzah! this appears to work correctly now based on the test cases provided.
Calls for folders on stela can be made with two types of authentication: - auth token - share token When making a call with the share token, if that folder is not unrestricted, the endpoint will return an empty list. When this happens, if the user is logged in, we try to make the call for the folder again, using the auth token, because maybe the user does have access to it and we can still get it. Issue: PER-10357 Fallback for share token
Calls for records on stela can be made with two types of authentication: - auth token - share token When making a call with the share token, if that record is not unrestricted, the endpoint will return an empty list. When this happens, if the user is logged in, we try to make the call for the record again, using the auth token, because maybe the user does have access to it and we can still get it. Issue: PER-10357 Fallback for share token
The method fetchFullItems uses both the record.repo and the folder.repo and the data service test suite does not create mocks for them. Because the methods api.folder.getWithChildren and api.record.get have changed, the test for the fetchFullItems fails, even with the timeout. At the moment, the best solution would be to disable this test, to avoid it from failing on future changes in the dependencies. Issue: PER-10357 Fallback for share token
The properties from stela for record(location, files) and for folder (location, thumbnailUrls, paths) did not have a check for null or undefined and if those properties are not present for some reason in the response, an error is generated that will block the whole flow in the browser. Issue: PER-10357 Fallback for share token
ab652c2 to
ada626c
Compare

Calls for folders and records on stela can be made with two types of authentication:
When making a call with the share token, if that folder/record is not unrestricted, the endpoint will return an empty list. When this happens, if the user is logged in, we try to make the call for the folder/record again, using the auth token, because maybe the user does have access to it and we can still get it.
Issue: https://permanent.atlassian.net/browse/PER-10357
Linked issues:
HOW TO TEST:
Test for folder fallback: "My Archive" button
EXPECTATION: Should be redirected to the logged in user's current archive
Test for properties check bug: "View in my archive" button
EXPECTATION: Should be redirected to the logged in user's current archive
Test for record fallback:

I did not find a place to test this, so I just faked an empty response from the code to make sure it works.