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

feat: add environment details to results #1353

Merged
merged 8 commits into from
Feb 11, 2019
Merged

feat: add environment details to results #1353

merged 8 commits into from
Feb 11, 2019

Conversation

straker
Copy link
Contributor

@straker straker commented Feb 6, 2019

Adds tool options, axe-core version, branding name, and environment details to the result object.

Closes issue: #947

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Has documentation updated, a DU ticket, or requires no documentation change
  • Includes new tests, or was unnecessary
  • Code is reviewed for security by: @WilcoFiers

@straker straker requested a review from a team as a code owner February 6, 2019 18:58
Copy link
Member

@stephenmathieson stephenmathieson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add these new properties to the TypeScript definition file.

Copy link
Member

@stephenmathieson stephenmathieson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments and questions left inline.

axe.d.ts Show resolved Hide resolved
@@ -9,7 +9,25 @@ axe.addReporter('na', function(results, options, callback) {
}

var out = helpers.processAggregate(results, options);
var orientation =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use the standards-compliant object first:

var orientation = screen.orientation || screen.msOrientation || screen.mozOrientation || {}

Just incase someone defined a non-standard property of the same name.

Not a big deal either way tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, I just copied the MDN code to grab it https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♀️ OK, that's fine I suppose

@@ -9,8 +9,25 @@ axe.addReporter('no-passes', function(results, options, callback) {
options.resultTypes = ['violations'];

var out = helpers.processAggregate(results, options);
var orientation =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth moving this into a getScreenOrientation function since it's duplicated across files?

Again, not a big deal IMO, just a thought.

lib/core/reporters/v2.js Show resolved Hide resolved
@@ -245,4 +245,25 @@ describe('reporters - na', function() {
done();
});
});
it('should add version information', function(done) {
axe.run(naOption, function(err, results) {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This try/catch seems very awkward. Can't we just do:

axe.run(naOption, function (err, results) {
  if (err) {
    return done(err)
  }

  // Assertions go here
  done()
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The try/catch is for the assertions. A failed assertion throws an error but done is not called with it, so the unit test just hangs until timeout, then stops the test there without reporting what the error was.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, wow, OK. That's something we should change. I wonder if updating mocha would solve the problem for us.

Obviously don't worry about this now.

@@ -209,4 +209,25 @@ describe('reporters - no-passes', function() {
done();
});
});
it('should add version information', function(done) {
axe.run(noPassOpt, function(err, results) {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about the try/catch.

@@ -283,4 +283,25 @@ describe('reporters - v1', function() {
done();
});
});
it('should add version information', function(done) {
axe.run(optionsV1, function(err, results) {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about the try/catch.

try {
assert.isNull(err);
assert.isObject(results.testEngine, 'tesetEngine');
assert.equal(results.testEngine.name, 'axe-core');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we testing the same thing 3 different times? Is there a case where 1 of these tests could fail but the others wouldn't? If not, I think we only need to do this once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are different reporters. Just answered my own question. Disregard my question.

@@ -227,4 +227,25 @@ describe('reporters - v2', function() {
done();
});
});
it('should add version information', function(done) {
axe.run(optionsV2, function(err, results) {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same duplicate test and try/catch concern.

@stephenmathieson stephenmathieson dismissed their stale review February 7, 2019 18:14

Made more sense of this after speaking with Steven

@@ -9,7 +9,25 @@ axe.addReporter('na', function(results, options, callback) {
}

var out = helpers.processAggregate(results, options);
var orientation =
screen.msOrientation || (screen.orientation || screen.mozOrientation || {});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can assume screen exists as a global (or at all). I kinda doubt this is available on IE9. Please check that it exists before accessing its properties.

windowHeight: window.innerHeight,
orientationAngle: orientation.angle,
orientationType: orientation.type
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of duplicating this code a bunch of times, it'd be better to create a helper for this in lib/core/reporters/helpers, so you could just do:

callback({
  ...getEnvironmentData(),
  toolOptions: options,
  violations: out.violations,
  passes: out.passes,
  incomplete: out.incomplete,
  inapplicable: out.inapplicable
})

You could probably have the URL & timestamp returned from it too. That's probably a better place for those two than the processAggregate helper.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WilcoFiers please see #1353 (comment)

We've discussed this already, but neither @straker nor I know where to put things like this.

@straker straker dismissed WilcoFiers’s stale review February 8, 2019 17:59

created helper function

@WilcoFiers WilcoFiers merged commit e795f7d into develop Feb 11, 2019
@WilcoFiers WilcoFiers deleted the versionInfo branch February 11, 2019 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants