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

Expand transaction data file download feature #120

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Cruikshanks
Copy link
Member

https://eaflood.atlassian.net/browse/CMEA-299

In this change, we make use of the new test endpoint /jobs/data to expand the existing transaction file data export feature to include checking you can download the file and that its contents are as expected once the job has run.

Isse and others added 14 commits June 9, 2022 09:05
These will be needed to access the data export files in the s3 bucket.
The selector for the alert is not the same as the one used for the alert that appears at the top of the page after certain actions.

So, we add a new control to the `ExportDataPage` and use that instead.

Note - We also reduce the amount of text we're checking against. The text often has newlines embedded that are not immediately visible from the UI which can catch you unawares when testing.

As we just want to check the state of the page i.e. that it's reflecting no file has been generated we can simplify the matching by checking for something that still confirms this is the case.
Because we have to authenticate to run the job it unfortunately plays with the current session. This is because it authenticates anew on the assumption we have not authenticated.
Completely forgot we have an additional argument we can use to tell the job command not to authenticate when it runs. We added this specifically for this situation; where we are already logged in and need to run the job.

However, this does leave us on the job results page which is why we need to return to the home page before we can then select the regime from the menu.
We are now at the point that we can download the data export file, which confirms the TCM generated the file when the data export job was run.
Have got it to the point that we download the file and save it locally. But it doesn't work. The file we are downloading is a gzip file and what the S3download command is doing is streaming the data as a string.

If we save that to a file any attempts to open it raises a 'unsupported format' error.

Because the cypress tests are run in the browser it has limited access to the file system. You must use it's `writeFile()` method which expects a string.

So, I'm starting to lean towards using the https://www.npmjs.com/package/cypress-downloadfile to get hold of it instead.
This adds support for a `cy.downloadFile()` to the project. It also means we can download the data export in the same way as if we had clicked the download button.

This means we mimic better what a user would do and we avoid the whole issue of managing the data stream from AWS S3 into a format that corecctly copies the file in gzip format.
With this new task we can now unzip the transaction data file.
We update our step to not only download the file but unzip it as well.
We now have a step that confirms the transaction data file contains the data we expect. It's a cursory check; the number of lines are as expected and each is for a reference that links to the current regime.

But for the purposes of this feature and to confirm the transaction data file export is working this should suffice.
@Cruikshanks Cruikshanks added the enhancement New feature or request label Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants