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

Adding cypress test for new attachment API + fixes #2821

Merged
merged 6 commits into from
Dec 18, 2024

Conversation

olemartinorg
Copy link
Contributor

Description

When I tested the functionality implemented in #2754, I found two problems:

  1. Attachments that got removed by the backend were still being presented in frontend. This happened because the code in useNodeAttachments() that carries over previously-seen attachments also did that for successful uploads, but the comment indicated it was only supposed to happen for uploads in progress.
  2. When the backend removes an attachment (and doesn't care to update the list of IDs in the data model), the data model would become out of sync with the actual state in the UI + Instance data. Adding Maintain*DataModelBinding components to make sure we update those values when instance data elements disappear.

Also adding a cypress test for this functionality, with a somewhat hidden test structure and quite strange IDataWriteProcessor in the ttd/subform app.

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Ole Martin Handeland added 4 commits December 13, 2024 08:58
…nstance data, the attachments should be considered to be deleted.
…t in the node hierarchy. This makes sure we also update the IDs if an attachment is deleted on the backend (when the backend aldo doesn't update that field in the data model).
…, as attachments don't always map themselves when added to the instance data.
@olemartinorg olemartinorg added the kind/bug Something isn't working label Dec 16, 2024
@olemartinorg olemartinorg self-assigned this Dec 16, 2024
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
41.0% Coverage on New Code (required ≥ 45%)
44.83% Condition Coverage on New Code (required ≥ 45%)

See analysis details on SonarQube Cloud

Comment on lines +593 to +594
* If the attachment is deleted from the instance data outside of these functions (i.e. by a backend hook), these
* components will make sure to remove the attachment ID from the data model:
Copy link
Member

Choose a reason for hiding this comment

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

Good catch, I did not think of this case 🥇

Copy link
Member

@bjosttveit bjosttveit left a comment

Choose a reason for hiding this comment

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

Very nice!

@olemartinorg olemartinorg merged commit f0eb5ee into main Dec 18, 2024
13 of 14 checks passed
@olemartinorg olemartinorg deleted the bug/attachment-deletion branch December 18, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants