Pocket / curation-tools-frontend

DEPRECATED
Mozilla Public License 2.0
10 stars 52 forks source link

Add data and actions to New Tab page #127

Closed nina-py closed 3 years ago

nina-py commented 3 years ago

Goal

Get the New Tab page working as intended.

Implementation Decisions

Note that the frontend hides the "Remove" button for removed prospects - only the "Edit" button remains available - my thinking was that you can't remove it twice - that would only overwrite the value in the removalReason field.

Also, it is unclear where the contents of the removalReason should be displayed - perhaps in the history field of the Edit/Edit & Approve form? Added this to the list of UI tweaks under consideration.

Outstanding tasks:

nina-py commented 3 years ago

The work in this PR, particularly the tests required, exposed an interesting conundrum with the tests. Apollo Client expects the mocks for each query to match the objects fetched by those queries. The result returned by the query itself is an object of the following shape:

{
  data { 
    allProspects: Prospect[]
    totals: id[]
  }
}

It doesn't care much for the extra layer I added to the local API so that the output conforms to the spec:

  data {
    data: Prospect[]
    meta: {
      ...metaProps
    }
}

Indeed, it appears that it's impossible to test the Prospects and New Tab pages using just the local API, so I have removed all but one (tab-related) test for those two components. For the time being, the code that fetches queries from the GraphQL server and passes it to various components remains without test coverage (mutations are covered though).

One possible way to improve this would be to increase test coverage by testing the code against a copy of the private API and, at the same time, being able to request those meta fields so that they are part of the GraphQL query and can be used in the mocks. Apparently it's possible to use encrypted secrets in GitHub actions.