Skip to content

Add a support page #9529

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 7 commits into from
Oct 1, 2024
Merged

Add a support page #9529

merged 7 commits into from
Oct 1, 2024

Conversation

eth3lbert
Copy link
Contributor

@eth3lbert eth3lbert commented Sep 27, 2024

This PR adds a support page that allows user to select a support type from a list and fill in required information. It also moves "Email Support" from the footer to the support page.

The support page is inspired by npm's support page1. When a user clicks the "report violation" link, a report form will be displayed. The user must input a crate name, select reasons, and provide detailed information (required when "other" is chosen) before submitting. The name field in the report form should be automatically filled when navigating from the report button in the CrateSidebar.

Related #9496 .
Closes #9478 .

Footnotes

  1. https://www.npmjs.com/support

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.11%. Comparing base (c0d0045) to head (ba869e5).
Report is 55 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9529      +/-   ##
==========================================
- Coverage   89.16%   89.11%   -0.06%     
==========================================
  Files         286      285       -1     
  Lines       29071    28920     -151     
==========================================
- Hits        25922    25772     -150     
+ Misses       3149     3148       -1     

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

@eth3lbert
Copy link
Contributor Author

@Turbo87 I've only created the support route for now, and haven't placed it anywhere yet. I believe we want to replace "Email Support" under the "Get Help" section in the footer with this. I'm unsure whether we should simply add a "Get help" mailto link to the categorized support list or differentiate it with a horizontal separator and a subheader like "If you couldn't find a category above." followed by the "Get help" mailto link.

Copy link
Contributor Author

@eth3lbert eth3lbert left a comment

Choose a reason for hiding this comment

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

I've also introduced data-testid="some-id" in this PR instead of the data-test-some-id format. data-testid is becoming more popular recently, which also enables getByTestId in playwright and the potential benefit of removing data-testid in production (further implementation is required) if desired. This comes with a minor drawback of being slightly more verbose in qunit tests.

export default class SupportController extends Controller {
queryParams = ['inquire', 'name'];

@tracked inquire;
Copy link
Member

Choose a reason for hiding this comment

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

since this is in a controller I think the property keeps its value across page navigations. in other words: if you press the "report crate" button the property will be set, if you navigate away from the page, then you press the support link in the footer, you will not get to the overview state, but to the "report crate" state again. I'm not 100% sure about this, but we should probably add a test to ensure that navigating to /support without query params resets the state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One more thing I noticed is that, if you're on the support page with query, if the support link in footer is defined as <LinkTo @route="support" /> it will still inherit those query params. There doesn't seem to be a simple way to avoid this inheritance in the template. You need to use hash to manual overwrite all query params.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if there's a way to test this without <LinkTo @route="support"/>. We already have <LinkTo @route="support" @query={{hash inquire=null crate=null }}>Support</LinkTo> that reset the query params by setting their values to null.

Copy link
Member

Choose a reason for hiding this comment

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

not sure about playwright, but in the Ember.js test suite visit('/support') might be sufficient as it does not reload the whole app

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I just commented out resetController and expected the following to fail, but it didn't 😅 .

  test('should not retain query params when exiting and then returning', async function (assert) {
    await visit('/support?inquire=crate-violation');
    assert.strictEqual(currentURL(), '/support?inquire=crate-violation');
    assert
      .dom('[data-test-id="support-main-content"] section')
      .exists({ count: 1 })
      .hasAttribute('data-test-id', 'crate-violation-section');

    await visit('/');
    assert.strictEqual(currentURL(), '/');
    await visit('/support');
    assert.strictEqual(currentURL(), '/support');
    assert
      .dom('[data-test-id="support-main-content"] section')
      .exists({ count: 1 })
      .hasAttribute('data-test-id', 'inquire-list-section');
  });

However, if there's a <LinkTo @route="support">, I can see that the generated URL has sticky query params.

Copy link
Member

Choose a reason for hiding this comment

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

interesting, maybe I was wrong then :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured out how to test this in qunit but not playwright. I don't know how to mock the route in playwright QQ.

@Turbo87
Copy link
Member

Turbo87 commented Sep 27, 2024

the potential benefit of removing data-testid in production

that is already done for data-test-* attributes by https://github.com/mainmatter/ember-test-selectors, so using data-testid and not removing them from prod builds would be a (small) regression for now. we could potentially add data-testid support to ember-test-selectors though, if that is becoming a common pattern in other frameworks.

@eth3lbert
Copy link
Contributor Author

the potential benefit of removing data-testid in production

that is already done for data-test-* attributes by https://github.com/mainmatter/ember-test-selectors, so using data-testid and not removing them from prod builds would be a (small) regression for now. we could potentially add data-testid support to ember-test-selectors though, if that is becoming a common pattern in other frameworks.

Thanks for pointing this out. I didn't know that before.

Yes, I suppose this is a common pattern in newer testing frameworks like testing-library, cypress, and playwright, etc. Do you suggest we stick to the data-test-* convention for now and introduce data-testid later when we implement the removal process for production?

@Turbo87
Copy link
Member

Turbo87 commented Sep 27, 2024

Do you suggest we stick to the data-test-* convention for now and introduce data-testid later when we implement the removal process for production?

yeah, I think that would be best for now. I'd rather convert the whole codebase to the other pattern at once, instead of having to deal with two concepts in parallel when possible.

one thing to note, we use things like data-test-crate="serde" too, where the value of the test attribute is dynamic. I'm not sure how that would work with data-testid="crate"? I guess data-testid="crate[serde]" or something like that?

@eth3lbert
Copy link
Contributor Author

one thing to note, we use things like data-test-crate="serde" too, where the value of the test attribute is dynamic. I'm not sure how that would work with data-testid="crate"? I guess data-testid="crate[serde]" or something like that?

Hmm, I'm not sure if I fully understand your question, but I think this can be easily achieved using a template like data-testid="crate-{{crate.name}}".

@eth3lbert
Copy link
Contributor Author

the potential benefit of removing data-testid in production

that is already done for data-test-* attributes by https://github.com/mainmatter/ember-test-selectors, so using data-testid and not removing them from prod builds would be a (small) regression for now. we could potentially add data-testid support to ember-test-selectors though, if that is becoming a common pattern in other frameworks.

I think I've found a possible solution. Since the testid attribute is configurable in Playwright https://playwright.dev/docs/locators#set-a-custom-test-id-attribute, and ember-test-selectors accepts selectors with the pattern data-test-*, we can use data-test-id as the custom testid attribute to satisfy both frameworks.

The custom test id is also compatible with `ember-test-selectors`
The page is inspired by npm's support page.
@eth3lbert eth3lbert force-pushed the support-page branch 2 times, most recently from c63f3aa to 85d18ee Compare September 28, 2024 08:11
A report form will be displayed on the support page. The user must input
a crate name, select reasons, and provide detailed information
(required when the "other" reason is chosen) before submitting.
The report form's crate field should be automatically filled when
navigating from the report button in the CrateSidebar.
To display a correct support link (without query params) in the support page,
it is necessary to overwrite query params.
@Turbo87
Copy link
Member

Turbo87 commented Sep 30, 2024

@eth3lbert is this PR in draft state intentionally or is it ready for review/merging?

@eth3lbert
Copy link
Contributor Author

@eth3lbert is this PR in draft state intentionally or is it ready for review/merging?

Yes, this is almost done. We just need to implement this

I believe we want to replace "Email Support" under the "Get Help" section in the footer with this. I'm unsure whether we should simply add a "Get help" mailto link to the categorized support list or differentiate it with a horizontal separator and a subheader like "If you couldn't find a category above." followed by the "Get help" mailto link.

The simplest and most intuitive way would be to simply place a mailto link after the {{each}} block in template, rather than putting it into supports. I assume that it should always appear after other supports, and when we want to add a new support, we don't need to worry about placing the new support before it. After that, I think it will be ready for review and merging.

Or do you expect this to be done in a separate PR?

@Turbo87
Copy link
Member

Turbo87 commented Sep 30, 2024

Or do you expect this to be done in a separate PR?

I'm fine with either path :)

This makes the support link in the footer testable and eliminates the
need to manually update query params when new ones are added.
@eth3lbert
Copy link
Contributor Author

eth3lbert commented Sep 30, 2024

I just copied screenshots from Percy for preview. :)

image

image

These words need to be revised. :D

@eth3lbert eth3lbert marked this pull request as ready for review September 30, 2024 17:27
@eth3lbert eth3lbert requested a review from Turbo87 September 30, 2024 17:27
@Turbo87 Turbo87 added C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works A-frontend 🐹 labels Oct 1, 2024
Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

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

:shipit:

@Turbo87 Turbo87 merged commit 3c970a1 into rust-lang:main Oct 1, 2024
11 checks passed
@eth3lbert eth3lbert deleted the support-page branch October 1, 2024 23:24
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
Archived in project
Development

Successfully merging this pull request may close these issues.

"Report a crate" button doesn't require any information
2 participants