Page MenuHomePhabricator

[Cashtab]Auto add @generated to top of updated snapshot files
ClosedPublic

Authored by kieran709 on Oct 28 2021, 20:22.

Details

Summary

Bash script which checks snapshot files for str @generated on first line, if not found it is added. Runs prior to npm run test. Related to task T1918.

Test Plan

Remove @generated from top snapshot files
npm run test || npm run pretest
ensure that 7 files now have @generated appended to first line
npm run test || npm run pretest
ensure that 7 files do not now have a second @generated appended to first line

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Nice -- this is a great start. Some improvements in the in-line comments.

web/cashtab/scripts/addGenerated.sh
8 ↗(On Diff #30688)

Could drop the else from these functions; only do the sed if you get a false from the if condition.

68 ↗(On Diff #30688)

Writing each function individually and then calling them all will work. However, it would be better to write some kind of loop.

Here is some pseudocode

  1. Get list of all files in /web/cashtab that end in .test.js.snap
  2. for each file fileName.test.js.snap, if it does not have @generated in the first line,insert it
This revision now requires changes to proceed.Oct 28 2021, 21:40

responding to review feedback

bytesofman added inline comments.
web/cashtab/src/components/Common/__tests__/__snapshots__/StyledCollapse.test.js.snap
1 ↗(On Diff #30712)

Diff looks good. Please remove @generated from all these files, and the space preceding it, and then run npm pretest

This diff shouldn't be adding an extra space before @generated on all these files, will end up keeping it forever or slowly losing it one at a time as snapshots are updated.

This revision now requires changes to proceed.Oct 29 2021, 19:10
This revision is now accepted and ready to land.Nov 1 2021, 22:22