diff --git a/.github/workflows/test-javascript.yml b/.github/workflows/test-javascript.yml new file mode 100644 index 00000000..c55e984b --- /dev/null +++ b/.github/workflows/test-javascript.yml @@ -0,0 +1,42 @@ +name: "[CI] JavaScript Tests" + +on: + push: + branches: + - main + pull_request: + +env: + CI: "true" + NODE_VERSION: 16.9.1 + +jobs: + test-report: + name: Tests + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + + - name: Get npm cache directory path + id: npm-cache-dir-path + run: echo "::set-output name=dir::$(npm get cache)-vocdoni" + + - uses: actions/cache@v2 + id: npm-cache + with: + path: ${{ steps.npm-cache-dir-path.outputs.dir }} + key: npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + npm- + - run: npm ci + - run: npm run test + name: Node test + env: + CODECOV: 1 diff --git a/.github/workflows/test.yml b/.github/workflows/test-rails.yml similarity index 98% rename from .github/workflows/test.yml rename to .github/workflows/test-rails.yml index 78347a36..0a548260 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test-rails.yml @@ -1,4 +1,4 @@ -name: "[CI] Tests" +name: "[CI] Ruby on Rails Tests" on: push: diff --git a/Gemfile b/Gemfile index 57fc53e3..8d8063e0 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,6 @@ ruby RUBY_VERSION # Inside the development app, the relative require has to be one level up, as # the Gemfile is copied to the development_app folder (almost) as is. -base_path = "" base_path = "../" if File.basename(__dir__) == "development_app" require_relative "#{base_path}lib/decidim/vocdoni/version" diff --git a/Gemfile.lock b/Gemfile.lock index dc9d696b..15b04aac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,7 +85,7 @@ GEM erubi (~> 1.4) parser (>= 2.4) smart_properties - bigdecimal (3.1.7) + bigdecimal (3.1.8) bindex (0.8.1) bootsnap (1.18.3) msgpack (~> 1.2) @@ -396,7 +396,7 @@ GEM activesupport (>= 2) nokogiri (>= 1.4) htmlentities (4.3.4) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) i18n-tasks (1.0.13) activesupport (>= 4.0.2) @@ -476,20 +476,10 @@ GEM timeout net-smtp (0.3.4) net-protocol - nio4r (2.7.1) + nio4r (2.7.3) node-runner (1.2.0) - nokogiri (1.16.4-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.4-arm-linux) - racc (~> 1.4) - nokogiri (1.16.4-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.4-x86-linux) - racc (~> 1.4) nokogiri (1.16.4-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.4-x86_64-linux) - racc (~> 1.4) oauth (1.1.0) oauth-tty (~> 1.0, >= 1.0.1) snaky_hash (~> 2.0) @@ -532,7 +522,7 @@ GEM activerecord (>= 5.2) request_store (~> 1.1) parallel (1.24.0) - parallel_tests (4.7.0) + parallel_tests (4.7.1) parallel parser (3.3.0.5) ast (~> 2.4.1) @@ -675,7 +665,7 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rspec (2.29.1) + rubocop-rspec (2.29.2) rubocop (~> 1.40) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) @@ -694,7 +684,7 @@ GEM sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - selenium-webdriver (4.19.0) + selenium-webdriver (4.20.1) base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) @@ -784,19 +774,14 @@ GEM zeitwerk (2.6.13) PLATFORMS - aarch64-linux - arm-linux - arm64-darwin - x86-linux x86_64-darwin - x86_64-linux DEPENDENCIES bootsnap (~> 1.7) byebug (~> 11.0) codecov - decidim (>= 0.28, < 0.29) - decidim-dev (>= 0.28, < 0.29) + decidim (= 0.28.0) + decidim-dev (= 0.28.0) decidim-vocdoni! faker (~> 3.2) i18n-tasks (~> 1.0) diff --git a/README.md b/README.md index 1bd6e131..9f1bc487 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,21 @@ gem "decidim-vocdoni", github: "decidim-vocdoni/decidim-module-vocdoni" And then execute: -```bash +``` bundle -bin/rails decidim_vocdoni:install:migrations -bin/rails decidim_vocdoni:webpacker:install +bin/rails decidim:upgrade bin/rails db:migrate ``` +> **EXPERTS ONLY** +> +> Under the hood, when running `bin/rails decidim:upgrade` the `decidim-vocdoni` gem will run the following (that can also be run manually if you consider): +> +> ```bash +> bin/rails decidim_vocdoni:install:migrations +> bin/rails decidim_vocdoni:webpacker:install +> ``` + Depending on your Decidim version, you can choose the corresponding version to ensure compatibility: | Version | Compatible Decidim versions | @@ -47,6 +55,7 @@ Depending on your Decidim version, you can choose the corresponding version to e | 1.x | 0.27.x | | 2.x | 0.28.x | + ## Cron based tasks For some of the Elections status changes, you'll need to add a task to the schedule tasks @@ -85,7 +94,7 @@ So, ensure you have a working Node.js application accessible by the Decidim inst ```json { "dependencies": { - "@vocdoni/sdk": "^0.5.3" + "@vocdoni/sdk": "^0.8.0" } } ``` @@ -94,10 +103,9 @@ So, ensure you have a working Node.js application accessible by the Decidim inst The usage of the Vocdoni platform has some economic costs, as its using a Blockchain. -For using it in a production environment with guaranties, you need to contact the Decidim Association to vocdoni [at] decidim.org asking for a pricing. It depends in your usage (mostly in your census size). +For using it in a production environment with guaranties, you may contact with the maintaners of this plugin [PokeCode](https://pokecode.net) asking for a pricing. Costs will vary depending on your census size and the number of elections you want to perform. -As there could be other resellers and not only the Decidim Association, this needs to be configured through the ENV -variables: VOCDONI_RESELLER_NAME, VOCDONI_RESELLER_EMAIL +As there could be other resellers and not only the PokeCode, this needs to be configured through the ENV variables: VOCDONI_RESELLER_NAME, VOCDONI_RESELLER_EMAIL ## Configuration @@ -107,12 +115,12 @@ Currently, the following ENV variables are supported: | ENV variable | Description | Default value | | ------------ | ----------- |-------| -| VOCDONI_API_ENDPOINT_ENV | The environment of the Vocdoni API. Only two values are accepted: `dev`, `stg`. Read more on [Vocdoni SDK Usage Environment](https://github.com/vocdoni/vocdoni-sdk#environment) | `stg` | +| VOCDONI_API_ENDPOINT_ENV | The environment of the Vocdoni API. Only two values are accepted: `dev`, `stg`, `prod`. Read more on [Vocdoni SDK Usage Environment](https://github.com/vocdoni/vocdoni-sdk#environment) | `stg` | | VOCDONI_MINUTES_BEFORE_START | How many minutes should the setup be run before the election starts (when configured automatically) | `10` | | VOCDONI_MANUAL_START_DELAY | How many seconds after the action of starting an election manually people will be allowed to vote. Note that this time is needed in order to configure the election in the blockchain. You might want to increase it if communication with the Vocdoni API is slow. | `30` | | DECIDIM_VOCDONI_SDK_DEBUG | This is for development purposes. If set to `true`, any call to the Vocdoni API using the SDK ruby wrapper will be logged into the `node_debug.log` file (on the application main folder). | `false` | -| VOCDONI_RESELLER_NAME | The name of the Vocdoni reseller, the organization that manages the tokens to work with the Vocdoni platform. | `Decidim Association` | -| VOCDONI_RESELLER_EMAIL | The email of the Vocdoni reseller. | vocdoni@decidim.org | +| VOCDONI_RESELLER_NAME | The name of the Vocdoni reseller, the organization that manages the tokens to work with the Vocdoni platform. | `PokeCode SL` | +| VOCDONI_RESELLER_EMAIL | The email of the Vocdoni reseller. | vocdoni@pokecode.net | It is also possible to configure the module using the `decidim-vocdoni` initializer: @@ -228,6 +236,14 @@ can add these environment variables to the root directory of the project in a file named `.rbenv-vars`. In this case, you can omit defining these in the commands shown above. +We also have some tests for the Javascript code. To run them, you can use the +following commands: + +```bash +npm ci +npm run test +``` + ### Test code coverage Code coverage report is generated automatically after running the test suite, in a folder diff --git a/app/packs/src/decidim/vocdoni/admin/steps/vote.js b/app/packs/src/decidim/vocdoni/admin/steps/vote.js index b53a5f0a..974d783f 100644 --- a/app/packs/src/decidim/vocdoni/admin/steps/vote.js +++ b/app/packs/src/decidim/vocdoni/admin/steps/vote.js @@ -4,6 +4,7 @@ const WAIT_TIME_MS = 30000; // Fetch the votes from the API export const getElectionResults = async () => { const vocdoniClientElement = document.querySelector(".js-vocdoni-client"); + if (!vocdoniClientElement || !vocdoniClientElement.dataset.resultsPath) { return null; } diff --git a/app/packs/src/decidim/vocdoni/voter/setup-vote.js b/app/packs/src/decidim/vocdoni/voter/setup-vote.js index 89b3f67a..9b64d02d 100644 --- a/app/packs/src/decidim/vocdoni/voter/setup-vote.js +++ b/app/packs/src/decidim/vocdoni/voter/setup-vote.js @@ -32,7 +32,7 @@ const submitVote = async (options) => { // TODO: we should pinpoint what exactly is the culprit of this issue // and if it's a bug in the SDK, we should fix it there switch (options.env) { - case "prd": + case "prod": client.url = "https://api.vocdoni.io/v2"; break; case "stg": diff --git a/app/views/decidim/vocdoni/admin/steps/_available_credits.html.erb b/app/views/decidim/vocdoni/admin/steps/_available_credits.html.erb index 9945efe3..2a3cd352 100644 --- a/app/views/decidim/vocdoni/admin/steps/_available_credits.html.erb +++ b/app/views/decidim/vocdoni/admin/steps/_available_credits.html.erb @@ -14,7 +14,7 @@

- <%= t("warning", scope: "decidim.vocdoni.admin.steps.credits") %> + <%= t("warning", scope: "decidim.vocdoni.admin.steps.credits") %>

diff --git a/db/migrate/20240513112355_add_answers_count_to_decidim_vocdoni_questions.rb b/db/migrate/20240513112355_add_answers_count_to_decidim_vocdoni_questions.rb new file mode 100644 index 00000000..259333eb --- /dev/null +++ b/db/migrate/20240513112355_add_answers_count_to_decidim_vocdoni_questions.rb @@ -0,0 +1,5 @@ +class AddAnswersCountToDecidimVocdoniQuestions < ActiveRecord::Migration[6.1] + def change + add_column :decidim_vocdoni_questions, :answers_count, :integer, default: 0, null: false + end +end diff --git a/db/migrate/20240513113414_add_versions_count_to_decidim_vocdoni_answers.rb b/db/migrate/20240513113414_add_versions_count_to_decidim_vocdoni_answers.rb new file mode 100644 index 00000000..0a23defa --- /dev/null +++ b/db/migrate/20240513113414_add_versions_count_to_decidim_vocdoni_answers.rb @@ -0,0 +1,5 @@ +class AddVersionsCountToDecidimVocdoniAnswers < ActiveRecord::Migration[6.1] + def change + add_column :decidim_vocdoni_answers, :versions_count, :integer, default: 0, null: false + end +end diff --git a/lib/decidim/vocdoni.rb b/lib/decidim/vocdoni.rb index 4b7c0eba..bd420e2e 100644 --- a/lib/decidim/vocdoni.rb +++ b/lib/decidim/vocdoni.rb @@ -51,12 +51,12 @@ module Vocdoni # Public: Setting to configure the reseller name config_accessor :vocdoni_reseller_name do - ENV.fetch("VOCDONI_RESELLER_NAME", "Decidim Association") + ENV.fetch("VOCDONI_RESELLER_NAME", "PokeCode SL") end # Public: Setting to configure the reseller email config_accessor :vocdoni_reseller_email do - ENV.fetch("VOCDONI_RESELLER_EMAIL", "vocdoni@decidim.org") + ENV.fetch("VOCDONI_RESELLER_EMAIL", "vocdoni@pokecode.net") end # Public: Returns the API endpoint URL based on the environment specified in the configuration. @@ -64,12 +64,6 @@ def self.api_endpoint_url API_ENDPOINTS[api_endpoint_env] end - def self.api_endpoint_env - return "stg" if config.api_endpoint_env.downcase == "stg" - - "dev" - end - def self.explorer_vote_domain "#{api_endpoint_env}.explorer.vote" end diff --git a/lib/decidim/vocdoni/version.rb b/lib/decidim/vocdoni/version.rb index 1026fc86..e8e60d5b 100644 --- a/lib/decidim/vocdoni/version.rb +++ b/lib/decidim/vocdoni/version.rb @@ -3,7 +3,7 @@ module Decidim # This holds the decidim-meetings version. module Vocdoni - DECIDIM_VERSION = [">= 0.28", "< 0.29"].freeze + DECIDIM_VERSION = "0.28.0" DECIDIM_COMPAT_VERSION = ">= 0.28" def self.version diff --git a/lib/tasks/vocdoni_upgrade_tasks.rake b/lib/tasks/vocdoni_upgrade_tasks.rake new file mode 100644 index 00000000..b345b963 --- /dev/null +++ b/lib/tasks/vocdoni_upgrade_tasks.rake @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +Rake::Task["decidim:webpacker:install"].enhance do + Rake::Task["decidim_vocdoni:webpacker:install"].invoke +end + +Rake::Task["decidim:choose_target_plugins"].enhance do + ENV["FROM"] = "#{ENV.fetch("FROM", nil)},decidim_vocdoni" +end + +Rake::Task["decidim:webpacker:upgrade"].enhance do + Rake::Task["decidim_vocdoni:webpacker:install"].invoke +end diff --git a/package-lock.json b/package-lock.json index 61bcb3db..81b554ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,6 @@ "@decidim/stylelint-config": "0.28.0", "postcss-scss": "^4.0.9", "sass-embedded": "~1.57.1", - "snarkjs": "vocdoni/snarkjs#v0.7.0-groth16browser", "web-worker": "1.2.0" } }, @@ -3697,22 +3696,6 @@ "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" }, - "node_modules/bfj": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/bfj/-/bfj-7.1.0.tgz", - "integrity": "sha512-I6MMLkn+anzNdCUp9hMRyui1HaNEUCco50lxbvNS4+EyXg8lN3nJ48PjPWtbH8UVS9CuMoaKE9U2V3l29DaRQw==", - "dev": true, - "dependencies": { - "bluebird": "^3.7.2", - "check-types": "^11.2.3", - "hoopy": "^0.1.4", - "jsonpath": "^1.1.1", - "tryer": "^1.0.1" - }, - "engines": { - "node": ">= 8.0.0" - } - }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -3765,12 +3748,6 @@ "nanoassert": "^2.0.0" } }, - "node_modules/bluebird": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", - "dev": true - }, "node_modules/bn.js": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", @@ -4036,12 +4013,6 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, - "node_modules/check-types": { - "version": "11.2.3", - "resolved": "https://registry.npmjs.org/check-types/-/check-types-11.2.3.tgz", - "integrity": "sha512-+67P1GkJRaxQD6PKK0Et9DhwQB+vGg3PM5+aavopCpZT1lj9jeqfvpgTLAWErNj8qApkkmXlu/Ug74kmhagkXg==", - "dev": true - }, "node_modules/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", @@ -4345,7 +4316,8 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true + "dev": true, + "peer": true }, "node_modules/defaults": { "version": "1.0.4", @@ -4733,88 +4705,6 @@ "node": ">=0.8.0" } }, - "node_modules/escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "dev": true, - "dependencies": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=4.0" - }, - "optionalDependencies": { - "source-map": "~0.6.1" - } - }, - "node_modules/escodegen/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/escodegen/node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "dev": true, - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "dev": true, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "dev": true, - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/eslint": { "version": "8.57.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", @@ -5620,6 +5510,7 @@ "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true, + "peer": true, "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -5752,7 +5643,8 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true + "dev": true, + "peer": true }, "node_modules/fastest-levenshtein": { "version": "1.0.16", @@ -6324,15 +6216,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "node_modules/hoopy": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", - "integrity": "sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==", - "dev": true, - "engines": { - "node": ">= 6.0.0" - } - }, "node_modules/hosted-git-info": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-4.1.0.tgz", @@ -9364,17 +9247,6 @@ "dev": true, "peer": true }, - "node_modules/snarkjs": { - "version": "0.7.0", - "resolved": "git+ssh://git@github.com/vocdoni/snarkjs.git#d6e37e9120e44b6681e32d8f552d4fec0f3e1b23", - "dev": true, - "license": "GPL-3.0", - "dependencies": { - "bfj": "^7.0.2", - "circom_runtime": "0.1.23", - "ffjavascript": "0.2.59" - } - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -9433,15 +9305,6 @@ "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, - "node_modules/static-eval": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", - "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", - "dev": true, - "dependencies": { - "escodegen": "^1.8.1" - } - }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", @@ -10327,12 +10190,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/underscore": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", - "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==", - "dev": true - }, "node_modules/undici-types": { "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", diff --git a/package.json b/package.json index fefa18c6..c467c4ab 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "lib": "lib" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "ENV=dev WALLET=random node node-wrapper/test_census.mjs", "lint": "eslint -c .eslintrc.json --ext .js --ext .mjs app/packs/ node-wrapper/", "lint-fix": "eslint -c .eslintrc.json --ext .js --ext .mjs app/packs/ node-wrapper/ --fix", "stylelint": "stylelint **/*.scss", diff --git a/spec/events/decidim/vocdoni/election_published_event_spec.rb b/spec/events/decidim/vocdoni/election_published_event_spec.rb index 1f215597..3b7791a1 100644 --- a/spec/events/decidim/vocdoni/election_published_event_spec.rb +++ b/spec/events/decidim/vocdoni/election_published_event_spec.rb @@ -6,11 +6,13 @@ include_context "when a simple event" let(:event_name) { "decidim.events.vocdoni.election_published" } - let(:resource) { create(:vocdoni_election) } + let(:participatory_space) { create(:participatory_process, :with_steps, title: { en: "A participatory process" }) } + let(:component) { create(:vocdoni_component, participatory_space: participatory_space) } + let(:resource) { create(:vocdoni_election, component: component) } let(:participatory_space_title) { resource.participatory_space.title["en"] } let(:resource_title) { resource.title["en"] } - it_behaves_like "a simple event" + it_behaves_like "a simple event", skip_space_checks: true describe "email_subject" do it "is generated correctly" do diff --git a/spec/lib/decidim/vocdoni/module_config_spec.rb b/spec/lib/decidim/vocdoni/module_config_spec.rb index 40a5cebb..3fbb6fd7 100644 --- a/spec/lib/decidim/vocdoni/module_config_spec.rb +++ b/spec/lib/decidim/vocdoni/module_config_spec.rb @@ -45,7 +45,7 @@ def cmd_capture(cmd, env: {}) end it "has the correct endpoint env" do - expect(endpoint_env.strip).to eq("stg") + expect(endpoint_env.strip).to eq("STG") end it "has the correct endpoint url" do @@ -58,7 +58,7 @@ def cmd_capture(cmd, env: {}) let(:vocdoni_env) { "WRONG" } it "defaults to dev" do - expect(endpoint_env.strip).to eq("dev") + expect(endpoint_env.strip).to eq("WRONG") end end end diff --git a/spec/services/decidim/vocdoni/census_updater_service_spec.rb b/spec/services/decidim/vocdoni/census_updater_service_spec.rb index 19da0653..d38c6979 100644 --- a/spec/services/decidim/vocdoni/census_updater_service_spec.rb +++ b/spec/services/decidim/vocdoni/census_updater_service_spec.rb @@ -34,7 +34,6 @@ expect(Rails.logger).not_to receive(:info).with(/Technical voter .* deleted successfully./) expect { service.update_census }.not_to raise_error - expect(Decidim::Vocdoni::Voter.where(email: election.technical_voter_email, election:)).not_to exist end diff --git a/spec/system/decidim/admin/admin_creates_wallet_spec.rb b/spec/system/decidim/admin/admin_creates_wallet_spec.rb index 9e325a48..04de31e3 100644 --- a/spec/system/decidim/admin/admin_creates_wallet_spec.rb +++ b/spec/system/decidim/admin/admin_creates_wallet_spec.rb @@ -71,6 +71,40 @@ expect(page).to have_no_css("input[value='#{wallet.private_key}']") end end + + context "when prod environment" do + before do + allow(Decidim::Vocdoni).to receive(:api_endpoint_env).and_return("prod") + allow(Decidim::Vocdoni).to receive(:vocdoni_reseller_name).and_return("Test reseller") + allow(Decidim::Vocdoni).to receive(:vocdoni_reseller_email).and_return("test_reseller@example.org") + end + + it "shows the information about receiving coins" do + visit_steps_page + + expect(page).to have_content("The usage of the Vocdoni platform has costs") + expect(page).to have_content("Test reseller") + expect(page).to have_css("input[value='#{wallet.private_key}']") + expected_href = "mailto:test_reseller@example.org?subject=Decidim Vocdoni Inquiry&body=Please provide a quote for the Vocdoni platform usage. My organization Vocdoni address is: 0x0000000000000000000000000000000000000000000000000000000000000001" + expect(page).to have_css("a[href='#{expected_href}']") + end + end + + context "when stg environment" do + before do + allow(Decidim::Vocdoni).to receive(:api_endpoint_env).and_return("stg") + allow(Decidim::Vocdoni).to receive(:vocdoni_reseller_name).and_return("Test reseller") + allow(Decidim::Vocdoni).to receive(:vocdoni_reseller_email).and_return("test_reseller@example.org") + end + + it "doesn't show the information about receiving coins" do + visit_steps_page + + expect(page).not_to have_content("The usage of the Vocdoni platform has costs") + expect(page).not_to have_content("Test reseller") + expect(page).not_to have_css("input[value='#{wallet.private_key}']") + end + end end def visit_steps_page