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

[ENG-4682] Mirage for addons #2062

Conversation

futa-ikeda
Copy link
Contributor

@futa-ikeda futa-ikeda commented Nov 20, 2023

Purpose

  • Add mirage endpoints for addons service

Summary of Changes

  • Add mirage serializers + factories for new addon service models
  • Rename some models

To-do

  • Update mirage config
  • Add views for new addon endpoints
  • Create mirage scenario that has a project with addons configured

Screenshot(s)

  • external_storage_services
    image

  • internal_resources/<guid>
    image

  • internal_users/<guid>
    image

  • internal_users/<guid>/authorized_storage_accounts
    image

  • authorized_storage_accounts/<id>
    image

  • configured_storage_addons/<id>
    image

Side Effects

QA Notes

Copy link
Contributor

@brianjgeiger brianjgeiger left a comment

Choose a reason for hiding this comment

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

Mostly a request to get the API contract modified to make the URLs match the model types. But also a question about a thing I didn't know was a thing.

mirage/factories/configured-storage-addon.ts Outdated Show resolved Hide resolved
mirage/serializers/configured-storage-addon.ts Outdated Show resolved Hide resolved
mirage/serializers/configured-storage-addon.ts Outdated Show resolved Hide resolved
mirage/serializers/internal-resource.ts Outdated Show resolved Hide resolved
mirage/serializers/internal-user.ts Outdated Show resolved Hide resolved
mirage/serializers/internal-user.ts Outdated Show resolved Hide resolved
mirage/serializers/authorized-storage-account.ts Outdated Show resolved Hide resolved
scopes: [],
defaultRootFolder: faker.system.filePath,

configuringUser: belongsTo('internal-user'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not recall doing this for my factories. Is that a thing that needs fixing? What does it do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this was a misunderstanding of what these do. The association() helper can make it so that factories will automatically create a related model (e.g. server.create('draft-registration') will automagically create an initiator user). Whereas these belongsTo and hasMany helpers are used to define relationships in your data models (which we don't need to do, since we get this for free as we use ember-data)

@brianjgeiger
Copy link
Contributor

brianjgeiger commented Nov 20, 2023

Oh, actually, one more thing. Could you add to the dashboard scenario to put the box addon in to file5 and maybe just run through a quick test that your mirage endpoints work?

@brianjgeiger brianjgeiger marked this pull request as draft November 21, 2023 15:19
@futa-ikeda futa-ikeda marked this pull request as ready for review December 1, 2023 23:02
@futa-ikeda futa-ikeda changed the title [WIP][ENG-4682] Mirage for addons [ENG-4682] Mirage for addons Dec 1, 2023
Copy link
Contributor

@brianjgeiger brianjgeiger left a comment

Choose a reason for hiding this comment

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

Overall, looks good. A few small things.

Did you have a chance to try things out to make sure your mirage endpoints all worked and gave the output you were expecting?

mirage/config.ts Outdated Show resolved Hide resolved
// Addon service
this.urlPrefix = addonServiceUrl;
this.namespace = '/v1';
this.resource('external_storage_services', { only: ['index', 'show'] });
Copy link
Contributor

Choose a reason for hiding this comment

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

Innnteresting. I didn't know this.resource was a thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, partway through writing some of these views, I realized it was a lot simpler than what I was doing 😅

mirage/fixtures/external-storage-services.ts Outdated Show resolved Hide resolved
mirage/fixtures/external-storage-services.ts Show resolved Hide resolved
mirage/fixtures/external-storage-services.ts Outdated Show resolved Hide resolved
mirage/fixtures/external-storage-services.ts Outdated Show resolved Hide resolved
mirage/fixtures/external-storage-services.ts Outdated Show resolved Hide resolved
mirage/scenarios/dashboard.ts Outdated Show resolved Hide resolved
mirage/serializers/internal-user.ts Outdated Show resolved Hide resolved
@futa-ikeda
Copy link
Contributor Author

Did you have a chance to try things out to make sure your mirage endpoints all worked and gave the output you were expecting?

I will add those requests/responses to the PR descriptions now!

Copy link
Contributor

@brianjgeiger brianjgeiger left a comment

Choose a reason for hiding this comment

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

This should be ready to go once tests pass.

@futa-ikeda futa-ikeda merged commit 739c9f7 into CenterForOpenScience:feature/addon-services Dec 5, 2023
9 checks passed
@futa-ikeda futa-ikeda deleted the mirage-for-addons branch December 5, 2023 14:46
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.

2 participants