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

html-reporter: urlParams checkboxes broken (hidepassed, noglobals, notrycatch) #1657

Closed
bastimeyer opened this issue Sep 15, 2021 · 1 comment · Fixed by #1661
Closed

html-reporter: urlParams checkboxes broken (hidepassed, noglobals, notrycatch) #1657

bastimeyer opened this issue Sep 15, 2021 · 1 comment · Fixed by #1661

Comments

@bastimeyer
Copy link

Tell us about your runtime:

  • QUnit version:
    2.17.1
  • Which environment are you using? (e.g., browser, Node):
    NW.js - both: Chromium 93 + Node 16
  • How are you running QUnit? (e.g., QUnit CLI, Grunt, Karma, manually in browser):
    manually in NW.js (dev) / custom QUnit reporter/bridge via Chrome Debugging Protocol (CLI / headless)
    with autostart=false and delayed/injected QUnit.start() call

Issue

The hidepassed, noglobals and notrycatch checkboxes are completely broken. Neither the checked state is set correctly, nor does the toggle work properly.

This is especially frustrating when default config values are set.

import QUnit from "qunit";

const { config } = QUnit;
config.autostart = false;
config.hidepassed = true;
config.noglobals = true;
config.notrycatch = false;

do_something_async( () => QUnit.start() );

Observation

QUnit seems to build the urlParams object right at the start when loading the module.
https://github.com/qunitjs/qunit/blob/2.17.1/src/html-reporter/urlparams.js#L12-L14

However, when building the checkboxes in getUrlConfigHtml, the config values are not set yet from the urlParams, so it's always setting the checkboxes' checked state from the default config values:
https://github.com/qunitjs/qunit/blob/2.17.1/src/html-reporter/html.js#L156-L162

That's because the begin callback where the config values are set from the urlParams is run afterwards and too late:
https://github.com/qunitjs/qunit/blob/2.17.1/src/html-reporter/urlparams.js#L56-L72

Also, when deselecting a checkbox and there's no entry in the window.location.search query string, default config values are always applied instead of explicit false values representing the state of the unchecked checkboxes. For hidepassed, this is no problem because it doesn't refresh the page, but for the other urlParams entries it is.

Expected behavior

QUnit should allow setting default config values and should correctly handle the checked state of the urlParams checkboxes, in addition to false values of urlParams entries for being able to toggle the state despite of the default values.

Thanks!

@Krinkle Krinkle assigned Krinkle and unassigned Krinkle Sep 15, 2021
Krinkle added a commit to Krinkle/qunit that referenced this issue Sep 19, 2021
Follows-up cec22c1, which changed the HTML Reporter to consume
data from the "runStart" event. This event is fired immediately
before "begin" callback, where an earlier listener from urlparams.js
is responsible for applying the URL parameters to the QUnit.config
object.

Fixes qunitjs#1657.
Krinkle added a commit to Krinkle/qunit that referenced this issue Sep 19, 2021
It already confirmed that it worked end-to-end from URL parameter to
visible behaviour. But, we did not confirm the intermediary effect
(exposed as parsed config property), and the side-effect of the interface
reflecting the correct state.

This is a regression test for bug qunitjs#1657.
Krinkle added a commit to Krinkle/qunit that referenced this issue Sep 19, 2021
Similar to 87c1f9f, but for the `filter` config.

* Move general behaviour test to a CLI fixture.

* Expand coverage of the HTML file by starting from a real URL
  parameter instead of setting the config option at run-time.

* Expand coverage by verifying that the option is parsed into the
  config object.

* Expand coverage by verifying that the HTML Reporter displays
  the value in the input field.

Follows-up qunitjs#1657.
@Krinkle
Copy link
Member

Krinkle commented Sep 19, 2021

Thanks @bastimeyer. It was embarrassing to see this slip through our tests. We have lots of tests in place that verify that config options set at run-time (such as testId and filter) work as expected, as well as numerous end-to-end test that verify other config options registered by plugins correctly go from URL parameter to actual behaviour.

What we lacked was an end-to-end test for the three most important config options (those in the UI), and to simply check that the UI displays their current values correctly.

Expected behaviour:
QUnit should allow setting default config values

I understand the use case and I'd like to explore this in a separate issue. My concern here is backward-compatibility as this is not something we have supported in the past and is potentially incompatible with some of the callback features for plugins and configuration. My understanding is that most use of config at runtime is specifically to override the defaults so we may have to come up with a different way to support this. For example, something like QUnit.config.setDefaults().

Krinkle added a commit to Krinkle/qunit that referenced this issue Sep 19, 2021
It already confirmed that it worked end-to-end from URL parameter to
visible behaviour. But, we did not confirm the intermediary effect
(exposed as parsed config property), and the side-effect of the interface
reflecting the correct state.

This is a regression test for bug qunitjs#1657.
Krinkle added a commit to Krinkle/qunit that referenced this issue Sep 19, 2021
Similar to 87c1f9f, but for the `filter` config.

* Move general behaviour test to a CLI fixture.

* Expand coverage of the HTML file by starting from a real URL
  parameter instead of setting the config option at run-time.

* Expand coverage by verifying that the option is parsed into the
  config object.

* Expand coverage by verifying that the HTML Reporter displays
  the value in the input field.

Follows-up qunitjs#1657.
Krinkle added a commit that referenced this issue Sep 19, 2021
Follows-up cec22c1, which changed the HTML Reporter to consume
data from the "runStart" event. This event is fired immediately
before "begin" callback, where an earlier listener from urlparams.js
is responsible for applying the URL parameters to the QUnit.config
object.

Fixes #1657.
Krinkle added a commit that referenced this issue Sep 19, 2021
It already confirmed that it worked end-to-end from URL parameter to
visible behaviour. But, we did not confirm the intermediary effect
(exposed as parsed config property), and the side-effect of the interface
reflecting the correct state.

This is a regression test for bug #1657.
Krinkle added a commit that referenced this issue Sep 19, 2021
Similar to 87c1f9f, but for the `filter` config.

* Move general behaviour test to a CLI fixture.

* Expand coverage of the HTML file by starting from a real URL
  parameter instead of setting the config option at run-time.

* Expand coverage by verifying that the option is parsed into the
  config object.

* Expand coverage by verifying that the HTML Reporter displays
  the value in the input field.

Follows-up #1657.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants