GSA-TTS / FAC

GSA's Federal Audit Clearinghouse
Other
20 stars 5 forks source link

Rework API portion of E2E #4398

Open jadudm opened 3 weeks ago

jadudm commented 3 weeks ago

Background

The E2E tests:

  1. Do a complete submission
  2. Use the API to validate that Tribal audits are correctly suppressed

This works because the API points at the dissemination tables directly (in fac-db).

With the move of the API to fac-snapshot-db, we can no longer use the API to check that a submission is complete. The API now points at a database that is refreshed nightly. Therefore, we need to rework the Cypress tests.

Possible design

  1. We could check that a PDF is correctly suppressed/available via a simple GET. This would be a good first check, which can easily be worked back into the existing E2E framework.
  2. To test via the API, we would need to
    1. Sling/copy the data from fac-db to fac-snapshot-db
    2. Use an API key (in the env) to talk to the API.
    3. Confirm whether or not the most recent submission was properly suppressed.

The test would have to now pull the general record(s), look at is_public, and then check to make sure that the tables that should be suppressed are suppressed. In the E2E framwork, we knew the report ID (because it was all one test). Once it is broken up, we won't know the most recent submission. (We will be able to ask for the general submissions that came in today, which should exist if everything worked.)

Tasks

- [x] Remove API tests from existing E2E framwork.
- [x] Add PDF suppression check to existing E2E framework.
rnovak338 commented 1 week ago

Below is my implementation to handle this piece with the E2E testing.

When we expect it to succeed:

cy.request({
  method: 'GET',
  url: '/dissemination/report/pdf/' + reportId
}).should((response) => {
  expect(response.isOkStatusCode).to.equal(true);
});

When we expect it to fail (Tribal and NOT public):

cy.request({
  method: 'GET',
  url: '/dissemination/report/pdf/' + reportId,
  failOnStatusCode: false,
}).should((response) => {
  expect(response.isOkStatusCode).to.equal(false);
});

This has been applied to the new dissemination-table-via-pdf.js file.