-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Only display Preview Language Setting (dark_lang) in LMS #38510
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
Merged
+8
−2
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a5dd482
chore: Only display Preview Language Setting (dark_lang) in LMS
salman2013 7eb9c98
fix: add test
salman2013 8c4b219
Merge remote-tracking branch 'origin/master' into salman/legacy-front…
salman2013 f8d1627
fix: skip tests for the cms
salman2013 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@salman2013 I am confused--I thought that endpoint would redirect if you call it from CMS, but would still work as before if you call it from the LMS. Does this test pass in both LMS and CMS? If it passes in LMS, then why is it redirecting back into the same path in LMS?
Uh oh!
There was an error while loading. Please reload this page.
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.
As per my understanding It redirect on both cases, LMS and CMS
In LMS this redirects to the same host and path (e.g. /update_lang/). Ref:
openedx-platform/openedx/core/djangoapps/dark_lang/views.py
Line 74 in 4a49a95
In CMS now lambda redirects to {LMS_ROOT_URL}/update_lang/
Ref:
openedx-platform/cms/urls.py
Line 89 in 7eb9c98
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, OK, but that redirect after completing the POST action, right? We still need
_post_set_preview_langand_post_clear_preview_langto work (at least on the LMS side), otherwise we are not testing that users can set and clear their preview language.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 tried to write tests but faced failure,
By using LLM i found the logical reason when the old URL used include(...), a POST from the test client to /update_lang/ was handled in-process: the Django test client's request went directly into PreviewLanguageFragmentView.post(), the view called set_user_preference(), wrote to the database, and returned a
302 → /update_lang/ (a same-server redirect). The test client's session was live the whole time.
After the change, that same POST hits the lambda, which immediately returns 302 → http://localhost:18000/update_lang/. The test client sees
a redirect response and stops. It does not follow it, because Django's test client only follows redirects within the same Django application
instance — it has no concept of making a real TCP connection to another port. localhost:18010 (CMS test server) and localhost:18000 (LMS
test server) are treated as different servers even though they share the same process during tests. The result is that the test's POST never
reaches PreviewLanguageFragmentView at all. set_user_preference() is never called, the dark-lang preference row is never written to the
database, and get_user_preference() returns None hence _post_set_preview_lang test always fails.
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 could see how that would fail in CMS.
Does it test pass in LMS? We could use
@skip_unless_lmsUh oh!
There was an error while loading. Please reload this page.
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.
yes the tests pass in LMS, let me try @skip_unless_lms
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 skipped the failing tests for cms.