Skip to content

Migrate the frontend to use the new yank API #9765

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
merged 3 commits into from
Oct 31, 2024

Conversation

0xPoe
Copy link
Member

@0xPoe 0xPoe commented Oct 27, 2024

Moved to the new API before adding frontend support for the yank message.

Tested locally:

Screen.Recording.2024-10-27.at.16.40.16.mov

@0xPoe 0xPoe force-pushed the rustin-patch-yank-patch branch from 915c4bf to 6b51275 Compare October 27, 2024 09:19
Copy link
Member Author

@0xPoe 0xPoe left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

@0xPoe 0xPoe requested a review from a team October 27, 2024 09:20
return notFound();
}

return {};
Copy link
Member

Choose a reason for hiding this comment

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

we should update the yank status and add the yank_message field here and then return the serialized version. note that there is also a test suite for the mirage route handlers to ensure that it roughly matches the real API that we are mocking here. if we implement the frontend code against an API that does not match the real API we're in for trouble 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

I followed the previous mock API 😅

  server.delete('/api/v1/crates/:name/:version/yank', (schema, request) => {
    const { name, version: versionNum } = request.params;
    const crate = schema.crates.findBy({ name });
    if (!crate) {
      return notFound();
    }

    const version = schema.versions.findBy({ crateId: crate.id, num: versionNum });
    if (!version) {
      return notFound();
    }

    return {};
  });

  server.put('/api/v1/crates/:name/:version/unyank', (schema, request) => {
    const { name, version: versionNum } = request.params;
    const crate = schema.crates.findBy({ name });
    if (!crate) {
      return notFound();
    }

    const version = schema.versions.findBy({ crateId: crate.id, num: versionNum });
    if (!version) {
      return notFound();
    }

    return {};
  });

Do we need to update the old one as well? Or just delete it?

Copy link
Member

Choose a reason for hiding this comment

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

ouch, wow, yeah, those are definitely wrong 🙈

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, I’ll update it as well. Initially, I thought we were focusing only on UI testing(we only checked the button name), so I didn’t consider the actual version status. I’ll make sure to update the version status correctly.

Copy link
Member

Choose a reason for hiding this comment

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

I thought we were focusing only on UI testing(we only checked the button name), so I didn’t consider the actual version status

we have the "crates can be yanked by owner" test, but that apparently only asserts local state, which meant that the bug in the mirage implementation was hidden. and apparently we currently don't have any tests for the yank/unyank endpoints in mirage 😢

@Turbo87 Turbo87 added C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works A-frontend 🐹 labels Oct 27, 2024
@0xPoe 0xPoe force-pushed the rustin-patch-yank-patch branch from 2a1466e to 31abbd2 Compare October 28, 2024 15:51
Copy link
Member Author

@0xPoe 0xPoe left a comment

Choose a reason for hiding this comment

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

🔢 Self-check (PR reviewed by myself and ready for feedback.)

@0xPoe 0xPoe requested a review from Turbo87 October 28, 2024 16:07
Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.80%. Comparing base (6f264d0) to head (d552553).
Report is 29 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9765      +/-   ##
==========================================
- Coverage   88.80%   88.80%   -0.01%     
==========================================
  Files         289      289              
  Lines       29817    29808       -9     
==========================================
- Hits        26480    26470      -10     
- Misses       3337     3338       +1     

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

@Turbo87 Turbo87 force-pushed the rustin-patch-yank-patch branch from 2927b7b to 381d05c Compare October 31, 2024 10:19
@Turbo87 Turbo87 merged commit 23b2531 into rust-lang:main Oct 31, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend 🐹 C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants