From 4a6444ffe446fed56fae4a7ae909719946ff1090 Mon Sep 17 00:00:00 2001 From: plocket <52798256+plocket@users.noreply.github.com> Date: Mon, 17 Jul 2023 09:56:49 -0400 Subject: [PATCH 1/3] BREAKING: Remove EXTRA_LANGUAGES, now using cucumber `Examples` --- .github/workflows/test_tests.yml | 8 -------- CHANGELOG.md | 1 + action.yml | 20 +------------------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test_tests.yml b/.github/workflows/test_tests.yml index 08e5352b..2b5d7d38 100644 --- a/.github/workflows/test_tests.yml +++ b/.github/workflows/test_tests.yml @@ -4,10 +4,6 @@ on: push: workflow_dispatch: inputs: - extra_languages: - required: False - description: 'Optional. A list of comma separated language names visible on buttons or links that change the language of the interview. Overrides the EXTRA_LANGUAGES repo secret.' - default: '' tags: required: False description: 'Optional. Use a "tag expression" specify which tagged tests to run (https://cucumber.io/docs/cucumber/api/#tag-expressions)' @@ -28,7 +24,6 @@ jobs: PLAYGROUND_PASSWORD: ${{ secrets.PLAYGROUND_PASSWORD }} PLAYGROUND_ID: ${{ secrets.PLAYGROUND_ID }} DOCASSEMBLE_DEVELOPER_API_KEY: ${{ secrets.DOCASSEMBLE_DEVELOPER_API_KEY }} - EXTRA_LANGUAGES: ${{ secrets.EXTRA_LANGUAGES }} USER1_EMAIL: ${{ secrets.USER1_EMAIL }} USER1_PASSWORD: ${{ secrets.USER1_PASSWORD }} SECRET_VAR1: secret-var1-value @@ -47,9 +42,6 @@ jobs: run: | echo "ARTIFACT_NAME=alkiln-$(date +'%Y-%m-%d at %Hh%Mm%Ss' -u)UTC" >> $GITHUB_ENV echo "UNIT_TESTS_ARTIFACT_NAME=_alkiln-misc-$(date +'%Y-%m-%d at %Hh%Mm%Ss' -u)UTC" >> $GITHUB_ENV - - name: Set languages - run: echo "EXTRA_LANGUAGES=${{ github.event.inputs.extra_languages }}" >> $GITHUB_ENV - if: ${{ github.event.inputs.extra_languages != '' }} # For the testing repo, the `REPO_URL` is that of a different repo and is created in `env:` - run: echo "Repo address is $REPO_URL" - name: Checkout diff --git a/CHANGELOG.md b/CHANGELOG.md index 884f740e..5391b796 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ Format: ### Changed - BREAKING: the github action no longer runs `npm run XYZ`; it directly calls scripts, e.g. `alkiln-setup`, `alkiln-run`, `alkiln-takedown` +- BREAKING: Remove EXTRA_LANGUAGES env var as languages are being handled through cucumber `Examples` now. - upgraded cucumber v8.6.0 - using cucumber's JS API to run tests. For more details on how it works, see [the cucumber-js docs](https://github.com/cucumber/cucumber-js/blob/main/docs/javascript_api.md). diff --git a/action.yml b/action.yml index 6df6fb36..82ce4e6e 100644 --- a/action.yml +++ b/action.yml @@ -17,10 +17,6 @@ inputs: DOCASSEMBLE_DEVELOPER_API_KEY: description: 'API key of the testing account with developer permissions on your docassemble server.' required: true - EXTRA_LANGUAGES: - description: 'Other languages you want to test. This should be in your GitHub SECRETS or the SECRETS of your org.' - required: false - default: '' # This is necessary to test pre-releases at the very least. It does seem # strange considering we're controlling everything through the action, but # that actually doesn't touch the npm version that's pulled in. @@ -38,20 +34,10 @@ runs: steps: # Set environment variables - name: "ALKiln: Set environment variables" - # If extra languages were set manually, override the repository - # EXTRA_LANGUAGES secret with the manually set values # Human-readable date/time: # https://www.shell-tips.com/linux/how-to-format-date-and-time-in-linux-macos-and-bash/#how-to-format-a-date-in-bash run: | echo "ARTIFACT_NAME=alkiln-$(date +'%Y-%m-%d at %Hh%Mm%Ss' -u)UTC" >> $GITHUB_ENV - if ${{ github.event.inputs.extra_languages != '' }} - then - echo "Manually set languages: ${{ github.event.inputs.extra_languages }}" - echo "EXTRA_LANGUAGES=${{ github.event.inputs.extra_languages }}" >> $GITHUB_ENV - else - echo "Use EXTRA_LANGUAGES secret: ${{ inputs.EXTRA_LANGUAGES }}" - echo "EXTRA_LANGUAGES=${{ inputs.EXTRA_LANGUAGES }}" >> $GITHUB_ENV - fi echo "REPO_URL=${{ github.server_url }}/${{ github.repository }}" >> $GITHUB_ENV echo "BRANCH_PATH=${{ github.ref }}" >> $GITHUB_ENV echo "BASE_URL=${{ inputs.SERVER_URL }}" >> $GITHUB_ENV @@ -65,8 +51,7 @@ runs: shell: bash - name: "ALKiln: confirm info" run: | - echo -e "\nRepo is $REPO_URL\nBranch ref is $BRANCH_PATH\nManually added languages are $EXTRA_LANGUAGES\nAll other data is secret\n" - echo -e "\nALKiln version is $ALKILN_VERSION\nRepo is $REPO_URL\nBranch ref is $BRANCH_PATH\nMAX_SECONDS_FOR_SETUP is $MAX_SECONDS_FOR_SETUP\nManually added languages are $EXTRA_LANGUAGES\n" + echo -e "\nALKiln version is $ALKILN_VERSION\nRepo is $REPO_URL\nBranch ref is $BRANCH_PATH\nMAX_SECONDS_FOR_SETUP is $MAX_SECONDS_FOR_SETUP\n" shell: bash # Install node @@ -113,9 +98,6 @@ runs: # push: # workflow_dispatch: # inputs: -# extra_languages: -# description: 'Optional. A list of comma separated language names visible on buttons or links in the interview that change the language of the interview. Overrides the EXTRA_LANGUAGES GitHub secret.' -# default: '' # tags: # description: 'Optional. Use a "tag expression" specify which tagged tests to run. See https://cucumber.io/docs/cucumber/api/#tag-expressions for syntax.' # default: '' From fe47aa10217ac366a08c33de247832c023ad51eb Mon Sep 17 00:00:00 2001 From: plocket <52798256+plocket@users.noreply.github.com> Date: Mon, 17 Jul 2023 16:01:00 -0400 Subject: [PATCH 2/3] Remove lang leftovers, not just the way devs access langs --- .gitignore | 1 - .npmignore | 1 - CONTRIBUTING.md | 2 +- lib/scope.js | 27 +--------- lib/utils/langs.js | 51 ------------------- npm-shrinkwrap.json | 5 +- package.json | 6 +-- .../getSafeScenarioBaseFilename.test.js | 14 ----- .../getSafeScenarioFilename.test.js | 2 +- 9 files changed, 7 insertions(+), 102 deletions(-) delete mode 100755 lib/utils/langs.js diff --git a/.gitignore b/.gitignore index 5519e595..c1d3006e 100644 --- a/.gitignore +++ b/.gitignore @@ -131,7 +131,6 @@ npm-debug.log error*.jpg screenshot_*.jpg downloads_* -*_lang_*.feature *_report_* _al_test_project_name* # So that our tests will behave more like our users' tests diff --git a/.npmignore b/.npmignore index f289c127..a58f63e1 100644 --- a/.npmignore +++ b/.npmignore @@ -135,7 +135,6 @@ npm-debug.log error*.jpg screenshot_*.jpg downloads_* -*_lang_*.feature *_report_* _al_test_project_name* # So that our tests will behave more like our users' tests diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0a2bc305..cef67019 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -204,7 +204,7 @@ If you want to know the commands, you can go to the [instructions for running te ### Files that you don't need to look at -`index.js` and `world.js` are short files that cucumber needs. `./lib/utils/langs.js` used to work, but we're not sure it does anymore. No one has used it yet, so we're waiting to experiment until someone expresses a need or we have some extra time. +`index.js` and `world.js` are short files that cucumber needs. ## Footnotes diff --git a/lib/scope.js b/lib/scope.js index eb63cfb8..49818072 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -230,17 +230,9 @@ module.exports = { getSafeScenarioBaseFilename: async function( scope, { scenario }) { /** Return a string that's safe to be a filename. Include the Scenario - * description, tags, and language. + * description and tags. */ - let name_parts = []; - - // Try to order filenames by language if possible/needed - if ( scope.language ) { - name_parts.push( scope.language ); - } - name_parts.push( scenario.pickle.name ); - - let filename = name_parts.join(`-`); + let filename = scenario.pickle.name; let safe_name = safe_filename( filename, { replacement: `_` }); // Allow room for extensions, date, etc. let short_name = `${ safe_name }`.substring(0, 70); @@ -854,21 +846,6 @@ module.exports = { return result; }, // Ends scope.getLoadData() - setLanguage: async function ( scope, { language }) { - // Tap the language button if given - let lang_url = null; - if ( language ) { - - let [lang_link] = await scope.page.$x(`//a[text()="${ language }"]`); - - let msg = `Could not find the link with the text "${ language }"`; - if ( !lang_link ) { await scope.addToReport(scope, { type: `error`, value: msg }); } - expect( lang_link, msg ).to.exist; // Cause test failure - - await scope.tapElement( scope, lang_link ); - } - }, // Ends scope.setLanguage() - normalizeTable: async function ( scope, { var_data=null, raw_var_data=null }) { /* Return data derived from cucumber variable-setting data, from either an object format * (var_data) or an array format (raw_var_data). `var_data` only is used when calling diff --git a/lib/utils/langs.js b/lib/utils/langs.js deleted file mode 100755 index 6b986f1d..00000000 --- a/lib/utils/langs.js +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env node - -let _path = require('path'); -let fs = require('fs'); -const fg = require('fast-glob'); - -let session_vars = require('./session_vars'); - -// Get the glob filepaths to find all the test files -let dir_root = process.env.INIT_CWD; // Path to root of project -let test_glob = process.argv[2]; // String of glob (regex for filepaths) -let filepaths = fg.sync( _path.resolve( dir_root, test_glob ) ); -let flag = '_lang_'; - -let langs = session_vars.get_languages(); - -// Generate new language files -for ( let full_path of filepaths ) { // Handle old language files before creating new ones. - - // Don't apply this to the example test that this package always provides - if ( full_path.includes( 'example_test.feature' )) { continue; } - - // Delete already existing non-default language files and skip the rest of this. For example, - // if 3 languages were tested previously and now only two are being tested. - if ( full_path.includes( flag )) { - fs.unlinkSync( full_path ); - continue; - } - - for ( let lang of langs ) { // Create new language files - // Get and change the text from the file to add the language to it - let data = fs.readFileSync( full_path, 'utf8' ); - let result = data.replace(/(Given I start the interview.*$)/gm, `$1 in lang "${ lang }"`); - - // Unicode category for NOT language characters \P{L} - const lang_escaped = lang.replace(/(\P{L})+/gu, '_'); - - // append generated language tags to existing Feature tags if they exist - const tags_regex = /(?:(?@.*)\n)?(?=Feature:)/; - result = result.replace(tags_regex, (_, tags) => `${tags ? tags + ' ' : ''}@generated @lang @${ lang_escaped }\n`); - - // Save the file to the same folder with a new name indicating the language - let test_dir = _path.dirname( full_path ); - // Put it alphabetically next to its matching tests by starting with the same name (discuss) - let orig_filename = _path.basename( full_path ).replace('.feature', ''); - let filename = `${ orig_filename }${ flag }${ lang_escaped }.feature`; - let fullPath = _path.resolve( test_dir, filename ); - // Always overwrite previous versions of the file if they exist - fs.writeFileSync(fullPath, result, { encoding:'utf8', flag:'w' }); - } -} diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 9a7c0db8..03aa6fbd 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,12 +1,12 @@ { "name": "@suffolklitlab/alkiln", - "version": "5.0.0", + "version": "5.0.0-pre-11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@suffolklitlab/alkiln", - "version": "5.0.0", + "version": "5.0.0-pre-11", "license": "MIT", "dependencies": { "@axe-core/puppeteer": "4.7.3", @@ -26,7 +26,6 @@ "uuid": "8.3.2" }, "bin": { - "alkiln-langs": "lib/utils/langs.js", "alkiln-run": "lib/run_cucumber.js", "alkiln-setup": "lib/docassemble/setup.js", "alkiln-takedown": "lib/docassemble/takedown.js" diff --git a/package.json b/package.json index e3d71b83..cc43eb72 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,8 @@ "description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.", "main": "lib/index.js", "scripts": { - "test": "npm run unit && npm run langs_setup && npm run cucumber", + "test": "npm run unit && npm run cucumber", "cucumber": "./lib/run_cucumber.js", - "langs": "npm run langs_setup && npm run cucumber", - "langs_setup": "./lib/utils/langs.js 'docassemble/*/data/sources/*.feature'", - "langs_local": "npm run langs_setup && npm run local", "local": "npm run setup && npm run cucumber; npm run takedown", "setup": "./lib/docassemble/setup.js", "takedown": "./lib/docassemble/takedown.js", @@ -52,7 +49,6 @@ "bin": { "alkiln-setup": "./lib/docassemble/setup.js", "alkiln-takedown": "./lib/docassemble/takedown.js", - "alkiln-langs": "./lib/utils/langs.js", "alkiln-run": "./lib/run_cucumber.js" } } diff --git a/tests/unit_tests/getSafeScenarioBaseFilename.test.js b/tests/unit_tests/getSafeScenarioBaseFilename.test.js index a315c4bb..c44ea49b 100644 --- a/tests/unit_tests/getSafeScenarioBaseFilename.test.js +++ b/tests/unit_tests/getSafeScenarioBaseFilename.test.js @@ -16,11 +16,6 @@ let mock_scenario = function ( description ) { describe(`When I use scope.getSafeScenarioBaseFilename()`, function() { - beforeEach(function() { - scope.language = undefined; - }); - - // No language it(`preserves spaces`, async function() { let scenario = mock_scenario( names.with_spaces ); let result = await getSafeScenarioBaseFilename( scope, { scenario }); @@ -45,13 +40,4 @@ describe(`When I use scope.getSafeScenarioBaseFilename()`, function() { expect( result ).to.equal( names.long_output ); }); - // language - it(`adds a language correctly to a description`, async function() { - scope.language = names.non_english_chars; - let scenario = mock_scenario( names.with_spaces ); - let result = await getSafeScenarioBaseFilename( scope, { scenario }); - let expected = `${ names.non_english_chars }-${ names.with_spaces }`; - expect( result ).to.equal( expected ); - }); - }); diff --git a/tests/unit_tests/getSafeScenarioFilename.test.js b/tests/unit_tests/getSafeScenarioFilename.test.js index c689c0ce..77a8f247 100644 --- a/tests/unit_tests/getSafeScenarioFilename.test.js +++ b/tests/unit_tests/getSafeScenarioFilename.test.js @@ -7,7 +7,7 @@ const getSafeScenarioFilename = scope.getSafeScenarioFilename; let test_filename = function ( expected_prefix, result ) { - /* Test a name to see if it's valid output with a language defined. */ + /* Test a name to see if it's valid output with a prefix defined, like `aXe`. */ let expected_name_regex_str = `^${ expected_prefix }-${ names.description }-\.{13}$`; if ( expected_prefix == `` ) { expected_name_regex_str = `^${ names.description }-\.{13}$`; From f2fd3ef5c661a2f2e8273b9ad52640eba9b16bfb Mon Sep 17 00:00:00 2001 From: plocket <52798256+plocket@users.noreply.github.com> Date: Mon, 17 Jul 2023 18:22:52 -0400 Subject: [PATCH 3/3] Restore ignores --- .gitignore | 1 + .npmignore | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c1d3006e..5519e595 100644 --- a/.gitignore +++ b/.gitignore @@ -131,6 +131,7 @@ npm-debug.log error*.jpg screenshot_*.jpg downloads_* +*_lang_*.feature *_report_* _al_test_project_name* # So that our tests will behave more like our users' tests diff --git a/.npmignore b/.npmignore index a58f63e1..f289c127 100644 --- a/.npmignore +++ b/.npmignore @@ -135,6 +135,7 @@ npm-debug.log error*.jpg screenshot_*.jpg downloads_* +*_lang_*.feature *_report_* _al_test_project_name* # So that our tests will behave more like our users' tests