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

Fixes #933, manifest display debugString. Add test coverage. #950

Closed
wants to merge 1 commit into from
Closed

Fixes #933, manifest display debugString. Add test coverage. #950

wants to merge 1 commit into from

Conversation

olingern
Copy link
Contributor

@olingern olingern commented Nov 16, 2016

fixes #933

@ebidel ebidel changed the title fix manifest display debugString issue #933. Add test coverage. Fixes #933, manifest display debugString. Add test coverage. Nov 16, 2016
};

const display = artifacts.Manifest.value.display;
display.raw = display.value = '';
Copy link
Contributor

Choose a reason for hiding this comment

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

separate lines please

@@ -53,9 +53,14 @@ class ManifestDisplay extends Audit {
return ManifestDisplay.generateAuditResult({
rawValue: hasRecommendedValue,
displayValue,
debugString: 'Manifest display property should be set.'
debugString: this.createDebugString(hasRecommendedValue)
Copy link
Contributor

Choose a reason for hiding this comment

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

If there's no value, it might be better not to add the debugString property in the first place. It's presence, even if blank, indicates some kind of error.

Copy link
Contributor Author

@olingern olingern Nov 16, 2016

Choose a reason for hiding this comment

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

@ebidel @brendankenny I was following the pattern I found here, and saw that it was a fairly consistent pattern throughout the audits. ( I could be mistaken, though!)

So, undefined is > empty string ?

A couple of ex:
aria-allowed-attr
color-contrast

Copy link
Member

Choose a reason for hiding this comment

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

So, undefined is > empty string ?

I'd say yes. At some point we should change all audits to standardize on this

Copy link
Contributor

Choose a reason for hiding this comment

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

What @brendankenny said :) It's our bad that things are inconsistent atm.

Copy link
Contributor

@ebidel ebidel Nov 16, 2016

Choose a reason for hiding this comment

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

I have somewhat mixed feelings about debugString: undefined but can live with what you have.

I was thinking we'd remove createDebugString and just roll with:

const auditResult = ManifestDisplay.generateAuditResult({
  rawValue: hasRecommendedValue,
  displayValue
});
if (!hasRecommendedValue) {
  auditResult.debugString = 'Manifest display property should be set.';
}
return auditResult;

That way, the debugString property only gets added when there's an error.

debugString: hasRecValue ? undefined : debugString; works but it stills add the property to the artifacts object. Oher parts of the codebase may make a check like 'debugString' in auditResult, which would return true even though there was no error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I was a little confused between what @brendankenny mentioned below.

I think it would be better to just inline a test for debugString to exist or not in the above tests instead of adding new tests just for debugString

Now, the property is absent from the object if valid, i.e. what you pasted above.

@@ -66,4 +66,28 @@ describe('Mobile-friendly: display audit', () => {
it('succeeds when a complete manifest contains a display property', () => {
return assert.equal(Audit.audit({Manifest: exampleManifest}).rawValue, true);
});

it('has no debugString when successful', () => {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to just inline a test for debugString to exist or not in the above tests instead of adding new tests just for debugString


static createDebugString(hasRecValue) {
const debugString = 'Manifest display property should be set.';
return hasRecValue ? '' : debugString;
Copy link
Member

Choose a reason for hiding this comment

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

definitely agree that debugString should be undefined if no error. Doing return hasRecValue ? undefined : debugString; here would be sufficient

@olingern
Copy link
Contributor Author

@ebidel @brendankenny
[x] New tests worked into existing tests
[x] createDebugString returns undefined instead of empty string
...
I think that's it : )

return auditResult;
}

static createDebugString(hasRecValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you remove this now :)

@brendankenny
Copy link
Member

@olingern I grabbed your commit and put it in another PR so we can land and I can do a lighthouse release with it this afternoon :)

closing this in favor of #954

@olingern olingern deleted the manifest-display-bug branch November 16, 2016 23:55
@olingern
Copy link
Contributor Author

@brendankenny Oh, bummer. Looks like I should have gotten to it sooner.

@brendankenny
Copy link
Member

no problem, sorry about that, just really needed the change :)

@brendankenny
Copy link
Member

arg, I tried to make sure your commit was preserved to give you credit for the contribution but somewhere between cherry picking and squashing it was lost. Sorry about that :( You still have credit in our hearts

@brendankenny
Copy link
Member

brendankenny commented Nov 17, 2016

Not urgent immediacy, but I was confident that github would handle the merge correctly and it would be a safe maneuver, and it was a nice change to have in the new release. However, I wouldn't have pushed forward on merging if I had known the commit author would be changed.

It's extremely important to us to recognize everyone who contributes to the project, so for whatever it's worth, really sorry that happened :(

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.

Manifest display audit shows "should set display property" debugString even if one is set
3 participants