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

BREAKING: Remove EXTRA_LANGUAGES, now using cucumber Examples #735

Merged
merged 3 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/workflows/test_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 1 addition & 19 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: ''
Expand Down
27 changes: 2 additions & 25 deletions lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
51 changes: 0 additions & 51 deletions lib/utils/langs.js

This file was deleted.

5 changes: 2 additions & 3 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
14 changes: 0 additions & 14 deletions tests/unit_tests/getSafeScenarioBaseFilename.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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 );
});

});
2 changes: 1 addition & 1 deletion tests/unit_tests/getSafeScenarioFilename.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}$`;
Expand Down