Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Media reporting e2e tests, single audio support, style updates, and accessibility improvements #1276

Merged
merged 12 commits into from Apr 16, 2022

Conversation

zackkrida
Copy link
Member

@zackkrida zackkrida commented Apr 14, 2022

Description

This PR makes a number of improvements to the reporting media code:

  • Updates the styles of the reporting popup trigger button to match the mockups
  • Adds the reporting functionality to single audio results
  • Updates the report form to use an actual submit button and form handler, rather than a click event on a type="button" button.
  • Updates the reporting API service to require a media type
  • Passes the media.frontendMediaType property to the reporting service to make the form work with all media tyes
  • Adds e2e tests for each report type for each media type

I would love some heavy attention applied to the e2e tests. These tests run each type of report (dmca, mature, and other) on the first search result each media-specific search endpoint (search/images, for example). This tests the entire flow, like this:

  1. Choose the desired media type from the content switcher
  2. Search for 'cat'
  3. Click on the first result.
  4. Open the report modal.
  5. Submit the current report (there's one test per media type per report)

Currently the tests mock the various network requests made by the reporting form: the google docs form and the api reporting endpoint. There are also likely utilities in this test that could be used elsewhere, if you have any suggestions for those.

Testing Instructions

  • Report some images and audio locally
  • Run the e2e tests locally
  • View the reporting button styles in

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@zackkrida zackkrida added 🟧 priority: high Stalls work on the project or its dependents ✨ goal: improvement Improvement to an existing user-facing feature 💻 aspect: code Concerns the software code in the repository labels Apr 14, 2022
@zackkrida zackkrida requested a review from a team as a code owner April 14, 2022 20:11
@zackkrida zackkrida requested review from krysal and obulat April 14, 2022 20:11
@openverse-bot openverse-bot added this to Needs review in Openverse PRs Apr 14, 2022
@zackkrida
Copy link
Member Author

Side note: the VS Code Playwright extension is amazing! fun example, it understands and lets me run these 'dynamic' tests, it's magical:

CleanShot 2022-04-14 at 16 13 11@2x

Comment on lines +3 to +8
<header class="flex flex-row justify-between items-center mb-6">
<h4 class="text-base lg:text-3xl">
{{ $t('audio-details.information') }}
</h4>
<VContentReportPopover :media="audio" />
</header>
Copy link
Member Author

Choose a reason for hiding this comment

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

This adds the report form and button to the single audio results.

Comment on lines +4 to +9
class="report-button font-semibold text-dark-charcoal-70"
>
<span class="md:hidden">{{
<span class="text-sr md:text-base md:hidden">{{
$t('media-details.content-report.short')
}}</span>
<span class="hidden md:inline">{{
<span class="text-sr md:text-base hidden md:inline">{{
Copy link
Member Author

Choose a reason for hiding this comment

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

Style updates to the reporting button so it matches the mockups:

CleanShot 2022-04-14 at 16 16 24@2x

:disabled="isSubmitDisabled"
:focusable-when-disabled="true"
variant="secondary"
@click="handleSubmit"
:value="$t('media-details.content-report.form.submit')"
Copy link
Member Author

@zackkrida zackkrida Apr 14, 2022

Choose a reason for hiding this comment

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

Fun fact: Playwright's selectors for text (page.locate('text="Submit"'), for example) use the value attribute when applied to submit buttons, not the actual button text contents.

Copy link
Contributor

Choose a reason for hiding this comment

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

TIL! I guess we should add value attribute to all the submit buttons? I wonder if it uses value for all buttons...

@@ -166,11 +167,13 @@ export default defineComponent({
const isSubmitDisabled = computed(
() => selectedReason.value === OTHER && description.value.length < 20
)
const handleSubmit = async () => {
const handleSubmit = async (event) => {
event.preventDefault()
Copy link
Member Author

@zackkrida zackkrida Apr 14, 2022

Choose a reason for hiding this comment

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

      event.preventDefault()

Prevents redirection to the api POST request endpoint.

@sarayourfriend
Copy link
Contributor

I imagine I should also mock the search responses?

What do you mean by this? As long as there are tapes for the search requests then they are mocked.

Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

Just reviewing the code so far. E2e tests look good to me!

test/playwright/e2e/report-media.spec.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGTM!

Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>
@zackkrida
Copy link
Member Author

I imagine I should also mock the search responses?

@sarayourfriend I wrote this before I fully understood the tapes 😅 disregard!

@zackkrida zackkrida added this to the Full E2E Test Suite milestone Apr 15, 2022
Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

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

Great improvements in the way the report sets the mediaType, and overall report style and flow.
I wonder why I can't see the CI run information?

PS: I merged the main into this branch, and CI is all green!

if (selectedReason.value === DMCA) return
// Submit report
try {
await service.sendReport({
mediaType: props.media.frontendMediaType,
Copy link
Contributor

Choose a reason for hiding this comment

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

I keep forgetting that we can use the frontendMediaType property!

Openverse PRs automation moved this from Needs review to Reviewer approved Apr 16, 2022
# Conflicts:
#	src/locales/po-files/openverse.pot
@zackkrida zackkrida merged commit d3f749b into main Apr 16, 2022
Openverse PRs automation moved this from Reviewer approved to Merged! Apr 16, 2022
@zackkrida zackkrida deleted the audio-reporting branch April 16, 2022 16:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code Concerns the software code in the repository ✨ goal: improvement Improvement to an existing user-facing feature 🟧 priority: high Stalls work on the project or its dependents
Projects
No open projects
Openverse PRs
  
Merged!
Development

Successfully merging this pull request may close these issues.

None yet

3 participants