Skip to content

Conversation

@samuelallan72
Copy link

@samuelallan72 samuelallan72 commented Aug 4, 2025

In the student view "Your Response" section,
there were several race conditions and issues relating to file uploads:

  • Selecting the file input while multiple file uploads are in progress
    results in broken uploaded files ("undefined" description and not actually uploaded to the backend) and inconsistent UI (the upload staging area where you can enter a description gets out of sync with reality).
  • A file can be deleted after clicking Submit,
    while the submission is still processing.
  • Clicking "Upload files" again after successfully uploading files,
    but before selecting more files,
    results in an attempt to upload the same files again.

On a high speed network connection,
the race condition issues are not very noticeable,
but on a slower connection,
they are easy to trigger as there is more time
in the UI while processing is happening in the backend.

What changed?

These changes fix the above issues by ensuring that the buttons
and other input fields relating to file uploads
are disabled while actions are in progress
(uploading, deleting, submitting).

screenshots of the disabled UI while actions are processing 1754369933 1754378062 1754378107 1754378121

Note: I haven't written any new tests; please let me know what level of unit/functional tests are required here.

Developer Checklist

Testing Instructions

  • Set up a devstack with this branch of ora2, create an ora2 assessment that allows multiple file uploads in a course, and navigate to the student view as a learner.
  • Use your browser's dev tools to throttle the network speed so you have time while actions are being processed to confirm fields are disabled during processing.
  • Click the "Browse" or "Choose files" button to select a file.
  • Don't enter a description, and click the "Upload files" button.
  • Verify the file does not get uploaded. You should see an error message about a missing description.
  • Verify that the file input field, the upload files button, and the submit assessment button remain enabled (hereafter referred to as "the fields"). They may be disabled for a moment as the form is being validated - this is expected.
  • Upload a file: select a file, enter a description, click "Upload files"
  • While the file is being uploaded (after clicking "Upload files", and before the files display in the uploaded section), verify that the fields are disabled.
  • Once the upload is complete, verify the fields are enabled again.
  • Without selecting any other fields first, click the "Upload files" button again.
  • Verify there is an error message "No files selected for upload.", and that no new files appear below.
  • Upload multiple files: select multiple files, enter a description for the files, click "Upload files"
  • While the files are being uploaded, verify the fields are disabled.
  • Once the upload is complete, verify the fields are enabled again.
  • Verify the uploaded files all display the description you entered - none should show "undefined".
  • Click the "Delete" button to delete a file.
  • While the file is being deleted, verify the fields are disabled.
  • Once the file is deleted verify the fields are enabled again.
  • Click the "Submit your response..." button.
  • Verify the fields are disabled (you can just see through the dimmed background behind the confirmation dialog).
  • Click the "Cancel" button on the confirmation dialog.
  • Verify the fields are enabled again.
  • Click the "Submit your response..." button again.
  • Click the "OK" button on the confirmation dialog.
  • Verify the fields remain disabled until the submission completes.

The above steps will help confirm the logic for disabling and re-enabling the form fields are working. However, also feel free to play around with the ui relating to file uploads, trying to break it - check for edge cases I may have missed.

Reviewer Checklist

Collectively, these should be completed by reviewers of this PR:

  • I've done a visual code review
  • I've tested the new functionality

FYI: @openedx/content-aurora

Private-ref: https://tasks.opencraft.com/browse/BB-9938

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Aug 4, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Aug 4, 2025

Thanks for the pull request, @samuelallan72!

This repository is currently maintained by @openedx/2u-aurora.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@codecov
Copy link

codecov bot commented Aug 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.29%. Comparing base (3e4bf88) to head (4f03bc4).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2319      +/-   ##
==========================================
- Coverage   95.29%   95.29%   -0.01%     
==========================================
  Files         195      195              
  Lines       21664    21663       -1     
  Branches     1509     1509              
==========================================
- Hits        20644    20643       -1     
  Misses        771      771              
  Partials      249      249              
Flag Coverage Δ
unittests 95.29% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@samuelallan72 samuelallan72 changed the title WIP: fix: disable file buttons while upload in progress fix: Disable file buttons when actions in progress Aug 5, 2025
In the student view "Your Response" section,
there were several race conditions and issues relating to file uploads:

- Selecting the file input while multiple file uploads are in progress
  results in broken uploaded files and inconsistent UI.
- A file can be deleted after clicking Submit,
  while the submission is still processing.
- Clicking "Upload files" again after successfully uploading files,
  but before selecting more files,
  results in an attempt to upload the same files again.

On a high speed network connection,
the race condition issues are not very noticeable,
but on a slower connection,
they are easy to trigger as there is more time
in the UI while processing is happening in the backend.

These changes fix the above issues by ensuring that the buttons
and other input fields relating to file uploads
are disabled while actions are in progress
(uploading, deleting, submitting).

Private-ref: https://tasks.opencraft.com/browse/BB-9938
@samuelallan72 samuelallan72 marked this pull request as ready for review August 5, 2025 07:19
@itsjeyd itsjeyd requested a review from kaustavb12 August 8, 2025 08:48
@itsjeyd itsjeyd moved this from Needs Triage to Waiting on Author in Contributions Aug 8, 2025
Copy link

@kaustavb12 kaustavb12 left a comment

Choose a reason for hiding this comment

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

@samuelallan72

I think we should add a few tests here, to make sure the buttons are disabled when they should be.

Comment on lines 160 to 163
expect(view.baseView.buttonEnabled('.step--response__submit')).toBe(expectedEnabled);
expect(view.baseView.buttonEnabled('.step--response .file__upload')).toBe(expectedEnabled);
expect(view.baseView.buttonEnabled('.step--response .delete__uploaded__file')).toBe(expectedEnabled);
expect(view.baseView.buttonEnabled('.step--response .submission__answer__upload')).toBe(expectedEnabled);
Copy link
Author

Choose a reason for hiding this comment

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

@kaustavb12 this is a bit brittle because it repeats logic from the actual code. I'm not sure how to improve the test for this though.

Copy link
Author

Choose a reason for hiding this comment

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

I'm also not sure how to add more tests to cover the case where a file deletion is processing or image upload is processing. 🤔

Choose a reason for hiding this comment

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

I see some test cases already present, which deal with uploads and deletes. You can perhaps use those as reference.

Copy link
Author

Choose a reason for hiding this comment

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

Unfortunately these weren't helpful in the end - they are directly calling upload functions and such. I've spent some time today trying to figure out some tests, but haven't got far. 😞

Do you know of ways to help with writing tests? Are there ways to live-debug, or view the UI in a headed browser while the tests are running?

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I've figured some things out and making progress now. :)

Copy link
Author

Choose a reason for hiding this comment

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

I've added a WIP test. Any feedback appreciated. :) I'll plan to keep working on tests tomorrow; I should make quicker progress now that I've figured out my environment and a workflow for running and debugging the tests.

Copy link
Author

@samuelallan72 samuelallan72 Aug 15, 2025

Choose a reason for hiding this comment

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

@kaustavb12 I've added tests that should somewhat cover the changed behaviour here. Ready for review again. :)

@samuelallan72 samuelallan72 self-assigned this Sep 9, 2025
@itsjeyd
Copy link

itsjeyd commented Oct 8, 2025

@samuelallan72 Since this work is currently paused, could you mark the PR as draft please?

@samuelallan72 samuelallan72 marked this pull request as draft October 8, 2025 08:50
@samuelallan72
Copy link
Author

@itsjeyd sure, can do 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

4 participants