Skip to content
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

Fix issue of user not being able to submit assignment when logged in root account #2989

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

suhaibabsi-inst
Copy link
Contributor

@suhaibabsi-inst suhaibabsi-inst commented Nov 27, 2024

refs: MBL-18064
affects: Student,Teacher
release note: Fixes issue of user not being able to submit assignment when logged in root account

What's changed

The main point of change of this PR resides in files:
AppEnvironmentOverride
CourseTabUrlInteractor
Router

This is to provide a clean way to pass a modified AppEnvironment with the correct baseURL that fits the current tab user is sitting at, which in this case is Course > Assignments

The rest are a consequence of those changes, which is basically to make sure views and classes are respecting what ever AppEnvironment instance is passed to them.

Test Plan

See ticket description.

Also, made testing for ordinary accounts for following use cases:

  1. View Assignment details
  2. View Submission details
  3. New text and file assignment submission.
  4. New text and file submission comment.
  5. View submission comments, especially those with comments.

Also, testing for the following scenarios:

  1. Tapping on external link.
  2. Tapping on an internal link for an assignment, making sure submission work as well for both of cases.

Screen Record

demo_consortia.mov

Checklist

  • Follow-up e2e test ticket created
  • A11y checked
  • Tested on phone
  • Tested on tablet
  • Tested in dark mode
  • Tested in light mode
  • Approve from product

…root account

refs: MBL-18064
affects: Student
release note: Fixes issue of user not being able to submit assignment when logged in root account
@inst-danger
Copy link
Contributor

inst-danger commented Nov 27, 2024

Warnings
⚠️ One or more files are below the minimum test coverage 50%
⚠️ The total test coverage is below the minimum 90%

Release Note:

Fixes issue of user not being able to submit assignment when logged in root account

Affected Apps: Student, Teacher

MBL-18064

Coverage New % Master % Delta
Canvas iOS 89.98% 90.05% -0.07%
Core/Core/AppEnvironment/AppEnvironmentOverride.swift 32.76% -- --
Core/Core/Planner/CalendarMain/ViewModel/PlannerViewModel.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/Model/CalendarWeek.swift 0% 0% 0%
Core/Core/Extensions/CGSizeExtensions.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/View/Calendar/CalendarCardInteractionState.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/Model/PlannablesInteractor.swift 0% 0% 0%
Core/Core/Search/Model/SearchSupportButtonModel.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/View/Calendar/ViewPreferences.swift 0% 0% 0%
Core/Core/Planner/CalendarMain/Model/CalendarDay.swift 0% 0% 0%
Core/Core/Courses/SmartSearch/View/CourseSmartSearchViewsProvider.swift 13.64% 13.64% 0%

Generated by 🚫 dangerJS against ec8b11e

@inst-danger
Copy link
Contributor

inst-danger commented Nov 27, 2024

Student Build QR Code:

@suhaibabsi-inst suhaibabsi-inst marked this pull request as ready for review November 27, 2024 14:55
@suhaibabsi-inst suhaibabsi-inst marked this pull request as draft November 27, 2024 15:24
refs: MBL-18064
affects: Student,Teacher
release note: Fixes issue of user not being able to submit assignment when logged in root account
@inst-danger
Copy link
Contributor

inst-danger commented Nov 27, 2024

Teacher Build QR Code:

@suhaibabsi-inst suhaibabsi-inst marked this pull request as ready for review November 27, 2024 21:24
@balintbartok balintbartok marked this pull request as draft November 29, 2024 13:08
@suhaibabsi-inst suhaibabsi-inst marked this pull request as ready for review December 1, 2024 11:57
@suhaibabsi-inst suhaibabsi-inst marked this pull request as draft December 1, 2024 11:57
@suhaibabsi-inst suhaibabsi-inst marked this pull request as ready for review December 2, 2024 08:48
@suhaibabsi-inst suhaibabsi-inst marked this pull request as draft December 2, 2024 11:04
@suhaibabsi-inst suhaibabsi-inst marked this pull request as ready for review December 2, 2024 15:01
@suhaibabsi-inst
Copy link
Contributor Author

suhaibabsi-inst commented Dec 3, 2024

@vargaat

I updated the code to use the Router's CourseTabUrlInteractor object to tweak all URLs pointing to internal course pages, regardless of their source.

For the point of API tweaking, when attempted I had to face the issue of this property access on LoginSession:

AppEnvironment.shared.currentSession?.baseURL.host

Which is very common place in code, and it is sometimes used to authenticate API requests, which would make the tweak of the baseURL on the API level a very missy and uncontrollable step.

If we were to go this route, we must guarantee that the value of this property on LoginSession is the same as the value on API whenever they accessed in the same context, and that would be impossible without fixing the dependency injection of AppEnvironment through whole the app. That's because changing this value would require passing information about the called endpoint, which is a dependency as well.

That's why using AppEnvironmentOverride, to me, can provide the framework to do so gradually.

Places where you can find such access:

if let authorizationHeader = task.originalRequest?.value(forHTTPHeaderField: HttpHeader.authorization), request.url?.host == AppEnvironment.shared.currentSession?.baseURL.host {

private var host: String? { AppEnvironment.shared.currentSession?.baseURL.host }

private let env = AppEnvironment.shared

public init(assignment: Assignment, courseColor: UIColor?) {
public init(env: AppEnvironment, assignment: Assignment, courseColor: UIColor?) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we usually pass in the primary data/model first which is the main subject of the whole type.
Then the secondary ones.
And in the end we pass in the dependecies, like interactors, env, router, etc.
Maybe this is only me, but it would make sense to me to keep this ordering.
May look like nit, but I would rather call this out now, at the beginning of this approach.

The same stands for all the other places where we inject env in this PR. cc @vargaat for thoughts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree, that bloated environment object is definitely not a primary dependency. I didn't notice this during my review but let's keep the priority order in the future.

Copy link
Contributor

@vargaat vargaat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA+1, I was able to submit to both consortia and my regular account various ways. What I noticed and I'm not sure if this can cause any issues or not is that when submitting via the share extension the file upload request still goes to the root account while the submission goes to the child domain. This is because the file upload logic for the share extension fetches the base url for its own but only for the last API request. On the image the non-selected rows are from the share extension and bottom ones from the app.
Screenshot 2024-12-04 at 16 04 54
I also managed to make the app crash two times during submitting files from the app. I couldn't reproduce it with Xcode and for some reason the crash symbolication didn't succeed so let's keep an eye out for this while testing the RC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants