GithubHelp home page GithubHelp logo

alphagov / smart-answers Goto Github PK

View Code? Open in Web Editor NEW
175.0 106.0 120.0 65.38 MB

Serves smart answers on GOV.UK

Home Page: https://docs.publishing.service.gov.uk/apps/smart-answers.html

License: MIT License

Ruby 34.70% JavaScript 0.08% HTML 65.13% Shell 0.01% SCSS 0.07% Dockerfile 0.01%
govuk-publishing-frontend govuk container

smart-answers's Introduction

Smart Answers

A tool for content designers to present complex information as a flow of questions, leading to an outcome. While the app is mostly self-contained, some Smart Answers use Whitehall to get data on countries and worldwide organisations.

Live examples

Nomenclature

  • Smart Answer: The flow, questions and outcomes.

  • Flow: Defines the questions, outcomes and the rules for navigating between them.

  • Landing page: Contains a description of the Smart Answer and the "Start now" button that leads to the first question.

  • Question page: Contains an individual question that's asked in order to help arrive at an outcome.

  • Outcome page: Contains the result of the Smart Answer based on responses to individual questions.

Technical documentation

This is a Ruby on Rails app, and should follow our Rails app conventions.

You can use the GOV.UK Docker environment or run ./startup.sh --live script to run the app. Read the guidance on local frontend development to find out more about each approach, before you get started.

If working on a smart answer that makes use of an API, locally run ./startup.sh --live script to run the app instead of docker.

If you are using GOV.UK Docker, remember to combine it with the commands that follow. See the GOV.UK Docker usage instructions for examples.

Running the test suite

bundle exec rake

Troubleshooting

  • When running integration tests, if you get SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version <some version number> error, then:
    • run brew install chromedriver or if you already have the cask, brew upgrade chromedriver
    • if that doesn't work, install the correct Chrome driver into usr/local/bin
  • When running bundle exec rake, if you get rake aborted! LoadError: linked to incompatible <some libruby or gem link>, run gem pristine --all

Smart Answer design

Smart Answer tasks

Further guidance is available in docs/tasks.

Further documentation

Licence

MIT License

smart-answers's People

Contributors

alext avatar andysellick avatar barrucadu avatar brenetic avatar camillebaldock avatar chrisroos avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar edwardkerry avatar erkde avatar floehopper avatar gclssvglx avatar hannahwhittaker avatar ikennaokpala avatar jackfranklin avatar jackscotti avatar jordanhatch avatar kevindew avatar kludgekml avatar kushalp avatar leenagupte avatar pmanrubia avatar richardskipper avatar rosa-fox avatar shotclog avatar steventux avatar tadast avatar theseanything avatar thomasleese avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smart-answers's Issues

NoMethodError: undefined method `rate' for nil:NilClass

From Errbit:

ERROR MESSAGE:
NoMethodError: undefined method `rate' for nil:NilClass

WHERE:
smart_answers#show

lib/smart_answer/flow.rb:22
lib/smart_answer/calculation.rb:10
lib/smart_answer/calculation.rb:10
lib/smart_answer/question/base.rb:62
lib/smart_answer/question/base.rb:61
lib/smart_answer/question/base.rb:61
lib/smart_answer/flow.rb:115
lib/smart_answer/flow.rb:112
lib/smart_answer/flow.rb:112
lib/smart_answer/flow.rb:112
app/presenters/smart_answer_presenter.rb:77
app/presenters/smart_answer_presenter.rb:128
app/presenters/smart_answer_presenter.rb:73
app/views/smart_answers/_content.html.erb:17
app/views/smart_answers/show.html.erb:8
app/controllers/smart_answers_controller.rb:13
app/controllers/smart_answers_controller.rb:12

URL:
https://www.gov.uk/calculate-your-redundancy-pay/y/1998-01-10/52/17/238.03

Styleguide repo?

Hi!

I just saw @sarahrichards speak at #ConfabMN and fell in love with your style guides. Are they posted here and I missed them? If not, could you post them? I have some forking to do!

Thank you!

Upgrade the Airbrake Gem

We're using version 3.1.7 of the Airbrake Gem. This version doesn't report on ActionController::BadRequest exceptions correctly. They're reported in Errbit as Notifications, which isn't very helpful.

Pull request 271 in the Airbrake project appears to have fixed this problem.

The pull request was updated on Aug 26 2014 with a comment saying that the fix would be released the following week. Airbrake version 4.1.0 was released on Sep 4 2014 so I suspect we'll want at least this version.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependencies.

As a result, Dependabot couldn't update any of your dependencies.

This could have been caused by a git reference having been deleted at the source, by an out-of-sync lockfile, or by a bug in Dependabot.

To help diagnose the issue, please try running bundle update --patch locally. If no errors occur, get in touch and we'll help dig into it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Phrase "translations" rendered multiple times

There are two things worth investigating.

Translations invoked prematurely

Looks like some phrases that should only be used in outcome nodes are being "translated" in the questions that lead to that outcome eg if you add a Rails.logger.warn("[Translating] #{@i18n_prefix}.phrases.#{phrase_key}") somewhere here and visit http://smartanswers.dev.gov.uk/maternity-paternity-calculator/y/maternity/2015-08-11/yes, you will see that this phrase is rendered there.
I believe this should not be required

Translations invoked multiple times

If you visit any outcome you will see that a lot of phrases are being "translated" multiple times. I'm curious if this can be avoided.

Implicit defaults for rendering formats in node .erb templates

A review comment in PR #4502 discussed that different default rendering behaviours for the render_content_for method with node templates may results in confusion as to what format content should be written in.

It was suggested that we could add multiple methods e.g:

  • govspeak_content_for
  • text_content_for
  • html_content_for

to be explicit in the type of content required.

Float parsing

Based on errbit, a lot of people are providing xxx. instead of xxx.xx as a float/money value. Parsing such a value fails with an error, thus resulting in bad UX, because the feedback a user gets is "Something went technically wrong". We could either parse such values or improve the validation logic.

ERROR MESSAGE:
ArgumentError: invalid value for Float(): "269."

WHERE:
smart_answers#show

lib/smartdown_adapter/presenter.rb:27
app/controllers/smart_answers_controller.rb:81
app/controllers/smart_answers_controller.rb:81

URL:
https://www.gov.uk/pay-leave-for-parents/y/yes/2015-12-28/employee/employee.json?utf8=%E2%9C%93&response_1=yes&response_2=yes&response_3%5Bamount%5D=269.&response_3%5Bperiod%5D=week&response_4=yes&next=1

Avoid tests relying on network connectivity

Build 2341 failed on Jenkins this morning. It appeared to be caused by a network connectivity issue.

@floehopper suggested disabling my network and running the tests to see how many might rely on the network being available.

It looks like we currently have 18 tests that rely on having an Internet connection. See this Gist for the current test failures caused by lack of Internet connection.

Checkbox question sets none option label in flow

The label for the none option on in checkbox questions is set in the flow rather than the question template. This seems to be opposing to the preference to move all view logic to templates.

E.g.:

checkbox_question :sectors? do
  option :retail
  option :offices
  set_none_option(label: "None of the above")
...
end

The instructions for getting started don't work anymore?

I can use the other examples of the repo, but when I start creating one from the instructions
https://github.com/alphagov/smart-answers/blob/master/doc/creating-a-new-smart-answer.md
but as soon as I get to the

"Assuming you're still running rails server, visit http://localhost:3000/example-smart-answer and you should see the empty landing page of our new Smart Answer."

I just get errors

NoMethodError at /example-smart-answer
undefined method `dig' for nil:NilClass

image

image

has something changed?

TypeError: can't convert nil into Integer

See the Errbit report for more information.

This exception is raised when the response to a value_question :name, parse: Integer is nil. I can't see that this is possible through the web interface but we should protect against it nonetheless.

@floehopper mentioned that this might become a problem in commit 28785dd.

You can see the error by visiting http://smartanswers.dev.gov.uk/calculate-your-child-maintenance/y/pay/1_child/no/400.0?next=1. The key is the lack of 'response=' in that URL.

All of the exceptions we've seen in Errbit came from a single IP address and the requests don't contain a user-agent which suggests to me that they might be from a bot.

Intermittent `Capybara::ElementNotFound` test failure in ReportAProblemTest

This test is passing locally, so I can only assume it's another race condition in a JS-enabled integration test.

See this build for an example of the failure: https://ci.dev.publishing.service.gov.uk/job/govuk_smartanswers_branches/3338/console

ReportAProblemTest#test_: with javascript smart-answer question should show report-a-problem. :
Capybara::ElementNotFound: Unable to find field "Name:"
    test/integration/engine/report_a_problem_test.rb:34:in `block (4 levels) in <class:ReportAProblemTest>'

Improve organisation and naming of controllers and methods

As discussed in #5212, we'd like to improve the organisation and naming of the controllers and their methods. After that ADR has been implemented we will have the following controller structure:

SmartAnswerController

  • index (Index page)
  • show (Start page)
  • visualise (Visualisation page)

FlowController

  • start (Redirect to the first flow question)
  • show (Question and outcome pages)
  • update (Redirect to next question or outcome)
  • destroy (Clear responses and redirect to start page)

@kevindew raised that it is confusing having "SmartAnswersController" and "FlowController", as it unclear what each is responsible for. This may be further exacerbated by the concepts "Smart Answer" and "Flow" not having been strictly defined or existing conflicting usage.

The other change proposed was moving the visualise method from SmartAnswerController to the FlowController, due to it being publicly available in production environment. Start page and index pages are not rendered or accessible from Smart Answers in production. However, it's not clear whether visualise is a feature we support for public use, outside its primary use as a tool to help flow development.

[BUG] Handling 29th of Feb in calculate-your-holiday-entitlement

path to reproduce: /calculate-your-holiday-entitlement/y/days-worked-per-week/leaving/2015-05-01/2016-02-29/1

It fails with an unhelpful error message undefined local variable or methodholiday_entitlement_days'`. This is because the block calculating the value raises an error, but it disappears (we should look at that separately).

The real issue is handling 29th Feb, which only exists in leap years. This method fails
as it's not taking into consideration leap year dates (funnily enough that's the main reason it was written).

I'm leaving it here for now as it's an edge case and I have other time-sensitive things at the moment.

Order dependent test failure in CountryAndDateQuestionsTest

I'm occasionally seeing the following test failure on my development machine:

  1) Failure:
CountryAndDateQuestionsTest#test_: with javascript should handle country and date questions.  [/Users/jamesmead/Code/alphagov/smart-answers/test/integration/engine/country_and_date_questions_test.rb:39]:
--- expected
+++ actual
@@ -1 +1 @@
-["angola", "aruba", "bangladesh", "belarus", "brazil", "brunei", "cambodia", "chad", "croatia", "denmark", "eritrea", "france", "ghana", "iceland", "japan", "laos", "luxembourg", "malta", "micronesia", "mozambique", "nicaragua", "panama", "portugal", "sao-tome-and-principe", "singapore", "south-korea", "sri-lanka", "venezuela", "vietnam"]
+["angola", "australia", "bahamas", "belarus", "brazil", "brunei", "cambodia", "chad", "croatia", "denmark", "eritrea", "france", "ghana", "iceland", "japan", "laos", "luxembourg", "malta", "micronesia", "mozambique", "nicaragua", "panama", "portugal", "sao-tome-and-principe", "singapore", "south-korea", "sri-lanka", "venezuela", "vietnam"]

Using a seed of 61548 seems to reproduce the problem when running all the tests. I'm going to try to narrow down the set of tests which cause the problem.

AgeRelatedAllowanceChooser could be generalised

(Note: pulled out of README)

The AgeRelatedAllowanceChooser has been created to return the
age-related personal allowance to assist with the calculation of
married couple's allowance. However, the reduction of allowances that
takes place in MarriedCoupleAllowanceCalculator applies to other tax
calculations, as your personal allowance depends on both your age and
income. So the AgeRelatedAllowanceChooser could be changed to a
PersonalAllowanceCalculator and extended such that it takes all those
factors into account and can be used across the system to calculate
someone's personal allowance depending on their age, income, and if
required, other factors:

[http://www.hmrc.gov.uk/incometax/personal-allow.htm]

Documentation on Intended usage?

Hi there,

I've been asked to look at using this project for a rails application. I'm just wondering if this will be offered as a gem?

If intended for use, it'd be good to add to the readme what steps you need to do to add a new questionnaire. I've guessed the following steps, but not sure:
o New yml file
o New rb file (for custom workflow)
o New routes definition
o New templates
o Registration in the OpenStruct with panopticon.rake

Anything that I'm missing?

Investigate organisations API usage

Investigate if it would be beneficial to use the API more extensively for things like:

  • this, finding out if the country has an embassy/high comission/consulate and where in the country it is
  • finding out if countries have no consular facilities

The risk would be content changing as the API is being updated. Which should not be a problem as long as the code is robust and makes sure it handles expected changes correctly.

Ability to dynamically define options for questions

Currently, question options (e.g. checkbox and radio) must be defined before runtime and are static i.e. do not change between requests.

We have several flows where we'd like to change the options available to a user depending on a previous response they'd given. To do this, we currently have to define multiple questions where each one represents a possible set of options, however the logically they are all the same question. A good example of this is the additional commodities flow.

This has several drawbacks. Re-defining the same question means creating multiple content files that have largely redundant content. This requires more effort to create and maintain questions and can cause issues if the content diverges between the files.

Having multiple versions of the same question can make the flow definition less readable and more complex. Defining multiple question nodes increases the length of the flow definition, where each node definition contains redundant information. As there are multiple questions nodes, preceding question may need to include complex logic in the next_node block to route users to the correct "version" of the question. These issues make the flow definition itself more difficult to understand and maintain.

I'd like to propose adding the ability to dynamically define the question options at request time. My initial thoughts are to provide a options block that needs to return an array of symbols, each representing an option key. That block will be run during request time and have access to request state (i.e. responses and any calculators etc...).

radio :node do
  options do
    calculator.node_question_options
   end

   on_response do |response|
     ...
   end

   next_node do
     ...
   end
end

The associated content erb file would just contain the copy for every possibility. This does introduce the potential for an error where copy might not exist for a particular dynamically generated option key.

This allows to address our original need for conditionally showing question options, without the overheard of defining multiple versions of the same question.

Duplication of value presentation logic

(Note: moved this out of the README)

The way that values are presented is badly factored. Values need to be
formatted for presentation in two places:

  1. when displaying a collapsed question;
  2. when interpolating values into question text.

Values can come from two places:

  1. directly from a response (save_input_as);
  2. via a calculation.

To correctly present a multiple-choice response value, you need to
know the question where it was posed. Other question types may also
determine formatting/presentation rules on a per-question basis so it
makes sense that it's determined at that point.

However, at present we don't remember which question gave rise to a
saved input, so this formatting is impossible.

There are two (duplicated) implementations of formatting response
labels:

  1. the node presenters, e.g. DateQuestionPresenter#response_label
  2. NodePresenter#value_for_interpolation

This is duplication and should be refactored out.

For now I don't think we ever need to interpolate in the responses of
multiple choice questions, so I think we could solve this issue (ie implement a single value presentation function) by:

  1. determining formatting from the type of the value
  2. adding a money type

Investigate intermittent test failure - possibly related to recent content_id changes

I've seen this test failure at least once on our Jenkins govuk_smartanswers_branches build e.g. see the bottom of the console log for this build, and several times when running the tests via rake on my local machine.

1) Error:
SmartAnswer::FlowContentItemTest#test_#payload_returns_a_valid_content-item:
GovukContentSchemaTestHelpers::ImproperlyConfiguredError: Dependency govuk-content-schemas cannot be found at: /Users/jamesmead/Code/alphagov/govuk-content-schemas. Clone it to that directory, or set GOVUK_CONTENT_SCHEMAS_PATH (see README.md for details).
  test/unit/flow_content_item_test.rb:13:in `block in <class:FlowContentItemTest>'

Note that @chrisroos, @tadast & I are running the smart-answers app outside the gov.uk VM, because it's a relatively simple app with not many dependencies in case that's significant.

Test failure on Jenkins - Capybara::Poltergeist::JavascriptError

I saw this error in Jenkins build 2378. It appears to be intermittent as the following build succeeded.

The tests were run with seed 53125.

ReportAProblemTest
  test_: with javascript smart-answer start page should have current url in report-a-problem. ERROR (0.11s)
Capybara::Poltergeist::JavascriptError:         Capybara::Poltergeist::JavascriptError: One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).

        TypeError: 'null' is not an object (evaluating 'data['title']')
        TypeError: 'null' is not an object (evaluating 'data['title']')
            at http://127.0.0.1:50084/smartanswers/smart-answers.js:97 in addToHistory
            at http://127.0.0.1:50084/smartanswers/smart-answers.js:89
            at https://assets.digital.cabinet-office.gov.uk/static/libs/jquery/jquery-1.7.2.js:16
            at https://assets.digital.cabinet-office.gov.uk/static/libs/jquery/jquery-1.7.2.js:16
            at https://assets.digital.cabinet-office.gov.uk/static/libs/jquery/jquery-1.7.2.js:18 in S
            at https://assets.digital.cabinet-office.gov.uk/static/libs/jquery/jquery-1.7.2.js:18
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/poltergeist-1.6.0/lib/capybara/poltergeist/browser.rb:323:in `command'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/poltergeist-1.6.0/lib/capybara/poltergeist/browser.rb:31:in `visit'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/poltergeist-1.6.0/lib/capybara/poltergeist/driver.rb:95:in `visit'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/capybara-2.1.0/lib/capybara/session.rb:193:in `visit'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/capybara-2.1.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
            /home/jenkins/workspace/govuk_smart_answers/test/integration/engine/report_a_problem_test.rb:8:in `block (3 levels) in <class:ReportAProblemTest>'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:436:in `instance_exec'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:436:in `block in run_current_setup_blocks'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:434:in `each'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:434:in `run_current_setup_blocks'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:426:in `run_all_setup_blocks'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:430:in `run_parent_setup_blocks'
            /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:402:in `block in create_test_from_should_hash'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/poltergeist-1.6.0/lib/capybara/poltergeist/browser.rb:323:in `command'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/poltergeist-1.6.0/lib/capybara/poltergeist/browser.rb:31:in `visit'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/poltergeist-1.6.0/lib/capybara/poltergeist/driver.rb:95:in `visit'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/capybara-2.1.0/lib/capybara/session.rb:193:in `visit'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/capybara-2.1.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
        /home/jenkins/workspace/govuk_smart_answers/test/integration/engine/report_a_problem_test.rb:8:in `block (3 levels) in <class:ReportAProblemTest>'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:436:in `instance_exec'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:436:in `block in run_current_setup_blocks'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:434:in `each'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:434:in `run_current_setup_blocks'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:426:in `run_all_setup_blocks'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:430:in `run_parent_setup_blocks'
        /home/jenkins/bundles/govuk_smart_answers/ruby/2.1.0/gems/shoulda-context-1.2.1/lib/shoulda/context/context.rb:402:in `block in create_test_from_should_hash'

Separate shared copy that is re-used in multiple nodes

We have copy that is relevant for the entire flow and is re-used in multiple nodes. Currently we have no place to put shared copy and with existing copy tied to particular nodes or hard coded in view templates.

For example, flow title is used on the start pages and the captions above questions, however is specified in the "Start page" content file. Another example is the banner text for the "Next steps for you business", which appears on every node, however is hard coded in the view template for lack of a better place.

This leads to confusing patterns in the code, for example creating a StartNodePresenter just to access the flow title.

I'd like to propose introducing a separate file to specific shared content within the flow. This content is then accessible on any node. I'm unsure whether this should formatted like an existing ERB file, or just have a YAML files similar to locales.

We could re-purpose the top level lib/smart_answer_flows/<flow_name>.erb file (currently used for start page) for generic content and move the start page content to another file alongside the question and result content files e.g. lib/smart_answer_flows/<flow-name>/start.erb

Improve diffs for regression test output

When regression tests fail due to differences in HTML outputs, the diff printed has an extra + on the left, that makes it a bit confusing.

screenshot 2015-06-25 10 09 09

I think that stripping out the extra +s would improve readability significantly.

Fix Smart Answer withdrawal process

As a user
I want withdrawn smart answers to redirect me
So that I can find an alternative path for my need

As an Information Architect
I want withdrawn smart answers to be removed from Publishing API
So that I don't accidentally tag them to browse pages

The current documentation and process for withdrawing Smart Answers is incomplete. It leaves artefacts in Panopticon and Content Items in the Publishing API and Content Store. If a Smart Answer is withdrawn, the following should happen:

  1. Withdraw the Artefact in Panopticon, preferably using the API
  2. Publish a redirect item to the Publishing API in place of the Smart Answer
  3. The Smart Answer should no longer be pushed to the Publishing API on deploy

label and suffix_label fields seem broken

As discovered in: #4502

We provide users with an ability to set a label and it doesn't seem to have an affect on the page rendered.

As an example we define one in lib/smart_answer_flows/calculate-your-holiday-entitlement/questions/shift_worker_hours_per_shift.govspeak.erb:

However when we view the page for it there doesn't seem to be any output of it.

I can see suffix labels seem to output:

<% render_content_for :suffix_label do %>
per week
<% end %>

but I'm not sure that is entirely right based on this example note:

Screenshot 2020-05-28 at 17 27 20

Looks like this might be tied into 95f1463 where a string concatenation process was added that omitted label.

I think to resolve this issue we need to work out whether these inputs provide input. If so where do they go? if not we can delete them.

Failing tests caused by duplicate context names

We appear to have a number of failing tests that aren't currently running because their names clash with other tests in the repo. The problem is caused by multiple contexts with the same name, containing tests with the same names.

I've created a script that attempts to give all contexts unique names to reveal these failing tests - https://gist.github.com/chrisroos/e7df2b0ded95a0098f1a

I've not yet attempted to fix any of these failures.

@tadast has previously fixed some similar failing tests in 4dfff63.

Running "bundle install" is failing on Windows

I am trying to get the project running on a Windows machine.

I have installed Ruby 2.6.1 (as per .ruby-version) and run gem install bundler, but then when I run bundle install I get an error when resolving dependencies.

C:\Work\smart-answers (master)
$ ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]

C:\Work\spl\smart-answers (master)
$ gem install bundler
Fetching bundler-2.0.1.gem
Successfully installed bundler-2.0.1
Parsing documentation for bundler-2.0.1
Installing ri documentation for bundler-2.0.1
Done installing documentation for bundler after 17 seconds
1 gem installed

C:\Work\spl\smart-answers (master)
$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
Bundler could not find compatible versions for gem "ruby ":
  In Gemfile:
    ruby  (~> 2.6.1.0)

    slimmer (~> 13.0.0) was resolved to 13.0.0, which depends on
      rest-client was resolved to 2.0.2, which depends on
        http-cookie (>= 1.0.2, < 2.0) was resolved to 1.0.3, which depends on
          domain_name (~> 0.5) was resolved to 0.5.20180417, which depends on
            unf (>= 0.0.5, < 1.0.0) was resolved to 0.1.4, which depends on
              unf_ext was resolved to 0.0.7.5, which depends on
                ruby  (< 2.6) x64-mingw32

Could not find gem 'ruby  (< 2.6)', which is required by gem 'nokogiri', in any
of the relevant sources:
  the local ruby installation

The error suggests that the problem is that the Ruby version needs to be less than 2.6, however I have also tried the install using version 2.5.3 and even after downgrading the .ruby-version file, the install fails again, though with different gems in the error message.

Any help with this would be most appreciated, as it is currently preventing me from running the code.

Javascript error being reported on Smart Answer pages

TypeError: null is not an object (evaluating 'elt.parentNode')
These errors occur only on iOS Safari (version 600.1.4)

Top offending pages:

/state-pension-age
/pay-leave-for-parents
/calculate-your-child-maintenance
/calculate-your-holiday-entitlement

We're seeing about 28,000 errors reported in GA each day.

Use "en" locale

This app is configured to use the en-GB locale. This was done so that numbers would be formatted correctly: f5c343a.

This is inconsistent with the rest of GOV.UK, which uses the en locale. This inconsistency has caused a situation where this app couldn't access the shared locales (something fixed in alphagov/static#907).

To avoid further confusion, the locale should be changed to en, while keeping the formatting.

Refactor FLOW_REGISTRY_OPTIONS

This constant is used to keep default configuration options for the smart answer registries. The registry instances are cached in class variables and complain if a different instance is requested. We end up modifying the constant in tests to work around this issue.

This can cause random test failures depending on the test scenario order if not reset to old values in teardown stage correctly.

I suggest encapsulating the constant in a class method eg FlowRegistry.config that gets initiated here. This would allow stubbing out the test configuration on a per-case basis without worrying of changing the state globally.

We could also encapsulate the stubbing itself in a test helper that would take care of other related things that get cached in class variables (e.g. plugin load paths), which would help with issues like this too.

Other suggestions welcome :)

Potential Marriage abroad improvements

Reviewing #1882 I've noticed some potential improvements that could be done to the marriage-abroad smartanswer. In no particular order:

  • Portugal same sex marriage title says "Same-sex in Protugal"
  • Remove the TODO comment, it is ok! e6a965a
  • consider moving Italy (also Japan, Germany?) out of the consular CNi outcome b095fbd
  • Japan-local does not use standard appointments booking link partial, standardise 93a86f8
  • consider moving Zimbabwe out of the commonwealth outcome

The last few might not be very good improvements, it needs more investigation/spiking.

Pending work on PR to retire a Smart Answer

#2994 has been merged because of an urgent deployment. The code is currently working and the tests passing.

We need to continue working on the PR code, so I have created this issue to track this work.

  • Write documentation about what are the steps to retire a smart-answer
  • Remove direct call to GDS::Router once Content Store is able to pass the segment configuration to router-api
  • Remove references to content-store and update them with publishing-api
  • Decompose long method into smaller chunks so it is easier to understand what the method is doing
  • Some comments already left in #2994
  • As per today's deployment the rake task to create the redirect is failing to set the segment in staging and production. It was needed to connect to the Rails console in production of router-api and set the segment path manually.
  • Add task to remove the URL from Search using Rummager
  • Add consolidated rake task for retiring a smart answer

This application has both RSpec and Minitest testing frameworks, we only want one of them

Smart Answers is one of GOV.UK's oldest applications (born 2011), it pre-dates the GOV.UK convention of using RSpec for Ruby testing and instead uses Minitest for testing. It has a large test suite (approx 7,000 tests and 20,000 assertions) which can be quite difficult to work with.

One of the gaps in the Minitest suite is that the embedded Ruby template files that are part of a flow (example) are not rendered in the test suite. This leaves a coverage risk that any syntactic errors in these files are not caught by the test suite. In November 2020 a new approach was taken that added RSpec to the test suite and integration tested the flows with Capybara. This new approach was precipitated on a migration of the test suite from RSpec to Minitest and not intended to be supplementary.

In March 2021 we (GOV.UK Covid Products and GOV.UK Start a Business) reconsidered the approach to migrate the whole test suite to RSpec. We concluded that we should not proceed with a migration to RSpec because we felt that the anticipated effort would outweigh the value generated, we also had concerns about the performance of a fully migrated RSpec test suite (the existing Minitest one benefits from Rails parallel testing). Instead we would replace any RSpec tests with Minitest ones so that Smart Answers only uses the one testing framework.

The tasks we identified that needed to be done for this are:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.