qa:preventing_regressions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
qa:preventing_regressions [2025/07/08 23:15] – [C logic] sandbergja | qa:preventing_regressions [2025/07/30 09:35] (current) – [IDL problems] sandbergja | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Preventing regressions ====== | ====== Preventing regressions ====== | ||
- | You've fixed a bug in Evergreen! | + | You've fixed a bug in Evergreen! |
+ | |||
+ | However, there' | ||
+ | |||
+ | |||
+ | How can we help make sure that your bug never rears its ugly head again? | ||
===== Angular component templates ===== | ===== Angular component templates ===== | ||
- | If the bug was something specific to this component, for example, it displayed its data incorrectly or a user interaction was broken: an angular unit test can be useful. | + | If the bug was something specific to this component, for example, it displayed its data incorrectly, had some incorrect display logic, |
- | If the bug was a general bad practice that could happen in any component (for example, important @Inputs | + | If the bug was a general bad practice that could happen in any component (for example, important |
+ | If the bug was a general accessibility bug (e.g. form inputs not associated with their labels), another nice option is a nightwatch end-to-end (e2e) test. Nightwatch can load your page in a browser then [[https:// | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
===== Angular typescript ===== | ===== Angular typescript ===== | ||
+ | Angular unit tests are useful for guarding against regressions in the typescript code, whether it is in a component, service, or elsewhere. | ||
+ | Note that Angular unit tests are relatively easy to write for components, services, etc. that have a single responsibility. | ||
+ | |||
+ | As with templates, if your bug was caused by a general bad practice that could happen elsewhere in the Angular typescript code, you can write an ESLint rule. | ||
+ | |||
+ | Another option can be to use the type system to prevent future regressions. | ||
+ | |||
+ | * [[https:// | ||
===== Database functions ===== | ===== Database functions ===== | ||
Line 19: | Line 37: | ||
===== Perl logic ===== | ===== Perl logic ===== | ||
+ | If you fix a bug in the Perl logic, you will want to write a Perl test to accompany it. If you can test the logic in isolation easily, put your test into Open-ILS/ | ||
+ | |||
+ | * [[https:// | ||
+ | * [[https:// | ||
===== C logic ===== | ===== C logic ===== | ||
Line 24: | Line 46: | ||
* [[https:// | * [[https:// | ||
- | ===== IDL problems ===== | + | ===== IDL and other XML problems ===== |
+ | To ensure that the IDL (or other XML file) is in a consistent format, you can adjust the XML schema (*.xsd) files. | ||
+ | |||
+ | To guard against more complex regressions in the IDL, you could write a perl unit test that parses the fm_IDL.xml file and makes assertions against it. I don't know of any examples of this type of test (yet!) at the time of writing. | ||
===== TT2 problems ===== | ===== TT2 problems ===== | ||
+ | TT2 files can be tested using a Perl unit test. | ||
+ | Here's an example of a basic test (intended as a starting point, it has a few issues as noted below): | ||
+ | |||
+ | < | ||
+ | use strict; use warnings; | ||
+ | use Test::More tests => 1; | ||
+ | use Template; | ||
+ | use FindBin qw($Bin); | ||
+ | use Carp; | ||
+ | |||
+ | my $filename = ' | ||
+ | |||
+ | my $tt = Template-> | ||
+ | INCLUDE_PATH => [" | ||
+ | PLUGINS => { | ||
+ | CGI_utf8 => ' | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | my $output; | ||
+ | $tt-> | ||
+ | $filename, | ||
+ | {}, # This is where you would set any variables that are needed for the template | ||
+ | \$output | ||
+ | ) or croak $tt-> | ||
+ | like $output, qr/<p/, 'it is structured as a <p> tag'; | ||
+ | </ | ||
+ | |||
+ | Be careful of testing very specific details of the templates. | ||
+ | * The filename of the tt2 file changes | ||
+ | * The tt2 file switches to some other markup that is just as good as a ''< | ||
+ | |||
+ | The above example test could also be tricked! | ||
+ | |||
+ | Note that you can iterate through multiple tt2 templates (or even all of them!) in the same test, so it can be a good option if there are certain bad practices that you want to catch regardless throughout the tt2 code base. | ||
+ | |||
+ | * [[https:// | ||
===== OPAC Javascript problems ===== | ===== OPAC Javascript problems ===== | ||
+ | Some javascript files in the OPAC are EcmaScript modules (i.e. they use '' | ||
+ | |||
+ | If the javascript file in question is not yet an EcmaScript module, you may consider refactoring it to be one -- not only does this help with testability, | ||
+ | * [[https:// | ||
===== General ===== | ===== General ===== | ||
* Adding a comment about why you use a particular approach is always welcome. | * Adding a comment about why you use a particular approach is always welcome. | ||
* A clear, descriptive commit message without unnecessary jargon. | * A clear, descriptive commit message without unnecessary jargon. | ||
+ | * If your test required some extra data beyond what is available in the Concerto Data Set or Enhanced Concerto Data Set, consider adding that data to make things easier for human testers. |
qa/preventing_regressions.1752030931.txt.gz · Last modified: 2025/07/08 23:15 by sandbergja