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

[Editor]: Fix cleanup attachments function #1023

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Conversation

cmoinier
Copy link
Collaborator

@cmoinier cmoinier commented Oct 22, 2024

Description

This PR fixes a wrong behavior in the editor's form, where the cleanup attachment function deletes the newly added attachments (eg : if an image is added, then the record saved, and then reloaded, the new image would be deleted).

This was because of a mapping that was not working : the names of the saved attachments were supposed to match the names of the new attachments, and the mapping was not taking into account that the name object had language keys in it, thus returning "undefined" for all attachment's names.

Quality Assurance Checklist

  • Commit history is devoid of any merge commits and readable to facilitate reviews
  • If new logic ⚙️ is introduced: unit tests were added
  • If new user stories 🤏 are introduced: E2E tests were added
  • If new UI components 🕹️ are introduced: corresponding stories in Storybook were created
  • If breaking changes 🪚 are introduced: add the breaking change label
  • If bugs 🐞 are fixed: add the backport <release branch> label
  • The documentation website 📚 has received the love it deserves

Copy link
Contributor

github-actions bot commented Oct 22, 2024

Affected libs: api-repository, feature-catalog, feature-record, feature-router, feature-search, feature-map, feature-dataviz, feature-editor, feature-auth,
Affected apps: metadata-editor, datahub, demo, webcomponents, map-viewer, search, datafeeder,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

Copy link
Contributor

github-actions bot commented Oct 22, 2024

📷 Screenshots are here!

@coveralls
Copy link

coveralls commented Oct 22, 2024

Coverage Status

coverage: 84.386% (+0.5%) from 83.868%
when pulling 506684a on fix-attachments-cleanup
into 8665bf5 on main.

Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

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

Thank you! I wonder if the original mapping wasn't done against another version of GN? It's possible that the API response differs (e.g. with localized names) between 4.2.5 and 4.4.0 for instance.

Maybe having a test of this in an e2e test would make sure this works against all version; essentially we just need to test that once an image has been uploaded and the record saved the image still shows up correctly (i.e. it has not been cleaned up).

@cmoinier
Copy link
Collaborator Author

cmoinier commented Oct 23, 2024

Thank you! I wonder if the original mapping wasn't done against another version of GN? It's possible that the API response differs (e.g. with localized names) between 4.2.5 and 4.4.0 for instance.

Maybe having a test of this in an e2e test would make sure this works against all version; essentially we just need to test that once an image has been uploaded and the record saved the image still shows up correctly (i.e. it has not been cleaned up).

@jahow I think this e2e covers it already, and it passed with all versions on the CI 🙂 [](

it('adds overviews', () => {
)

@jahow
Copy link
Collaborator

jahow commented Oct 23, 2024

Thank you! I wonder if the original mapping wasn't done against another version of GN? It's possible that the API response differs (e.g. with localized names) between 4.2.5 and 4.4.0 for instance.
Maybe having a test of this in an e2e test would make sure this works against all version; essentially we just need to test that once an image has been uploaded and the record saved the image still shows up correctly (i.e. it has not been cleaned up).

@jahow I think this e2e covers it already, and it passed with all versions on the CI 🙂 [](

it('adds overviews', () => {

)

OK so there's already an e2e test, but the test would not fail if the underlying image file ends up being deleted. Could you try and expand a bit the test to make sure that the url of the image does not end up in a 404? thanks!

@cmoinier cmoinier merged commit f53d469 into main Oct 23, 2024
13 checks passed
@cmoinier cmoinier deleted the fix-attachments-cleanup branch October 23, 2024 09:30
Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

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

Thanks!

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.

3 participants