-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core(pwa): revamp and move short_name_length audit #4860
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the checklist perspective, I appreciated a helpful reminder to provide an alternative to long names. I'd propose turning it informative and marking not applicable when no manifest rather than killing it off entirely.
If others never found it useful I can live with it gone though :)
I did have this at first, fwiw. @brendankenny thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I like keeping it personally.
How did its requirement in wepapp-install-banner make it through the last round of culling?
137629c
to
35b821f
Compare
Welcome back!
screenshot where there's no manifest at allscreenshot where there's a failing manifestIf you hypothetically have a manifest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wfm 👍
aside: is it just me or could multicheckaudit and byteefficiencyaudit use a bit of a refresh cleanup post I/O :)
got some lint failures though |
yUPPPPPPPPP |
} | ||
const shortNameCheckIds = ['hasShortName', 'shortNameLength']; | ||
manifestValues.allChecks.filter(item => shortNameCheckIds.includes(item.id)).forEach(item => { | ||
if (!item.passing) failures.push(item.failureText); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this have the other problem where if you don't have a short name you'll get both 'Manifest does not have `short_name`'
and 'Manifest `short_name` will be truncated when displayed on the homescreen'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes good call. thx.
001c900
to
f422128
Compare
As for the limit of 12, does this consider that Android word-wraps the text and shows on two lines? So, two words, both 12 long, would be fine. |
It doesn't, but I don't see this on my phone. Android 8.1.0 on a Pixel 2. I've never seen the text below an icon get word-wrapping. :/ |
validate: manifest => !!manifest.value.short_name.value && | ||
failureText: `Manifest's \`short_name\` is too long (>${SUGGESTED_SHORTNAME_LENGTH} ` + | ||
`characters) to be displayed on a homescreen without truncation`, | ||
// Pass if there's no short_name. Don't want to report a non-existent string is too long |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this should fail if there is no short_name
and the name
is longer than SUGGESTED_SHORTNAME_LENGTH. Or another audit like hasSomeShortName
should fail. I wouldn't know that short_name
exists without this audit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
should update the PR description (looks like you ended up doing the opposite) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shrtnm
const failures = []; | ||
/** @type {Array<string>} */ | ||
const warnings = []; | ||
|
||
return artifacts.requestManifestValues(artifacts.Manifest).then(manifestValues => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await!
return { | ||
rawValue: !!isShortEnough && isShortEnough.passing, | ||
}; | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's no warnings and only one possible failure, so why not drop mulitcheckAudit and do like
const manifestValues = await artifacts.requestManifestValues(artifacts.Manifest);
// If there's no valid manifest, this audit is not applicable
if (manifestValues.isParseFailure) {
return {
rawValue: true,
notApplicable: true,
};
}
const shortNameCheck = manifestValues.allChecks.find(i => i.id === 'hasShortName');
const shortNameLengthCheck = manifestValues.allChecks.find(i => i.id === 'shortNameLength');
// If there's no short_name present, this audit is not applicable
if (shortNameCheck && !shortNameCheck.passing) {
return {
rawValue: true,
notApplicable: true,
};
}
if (shortNameLengthCheck && !shortNameLengthCheck.passing) {
return {
rawValue: false,
explanation: `Failure: ${shortNameLengthCheck.failureText}.`,
};
}
return {
rawValue: true,
};
@@ -30,29 +30,30 @@ describe('Manifest: short_name_length audit', () => { | |||
artifacts.Manifest = null; | |||
|
|||
return ManifestShortNameLengthAudit.audit(artifacts).then(result => { | |||
assert.strictEqual(result.rawValue, false); | |||
assert.strictEqual(result.explanation, undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update test description (doesn't fail)
}); | ||
}); | ||
|
||
it('fails when an empty manifest is present', () => { | ||
const artifacts = generateMockArtifacts(); | ||
artifacts.Manifest = manifestParser('{}', EXAMPLE_MANIFEST_URL, EXAMPLE_DOC_URL); | ||
return ManifestShortNameLengthAudit.audit(artifacts).then(result => { | ||
assert.equal(result.rawValue, false); | ||
assert.equal(result.explanation, 'No short_name found in manifest.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sames
}); | ||
}); | ||
|
||
it('fails when a manifest contains no short_name and too long name', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sames
@@ -66,6 +67,8 @@ describe('Manifest: short_name_length audit', () => { | |||
artifacts.Manifest = manifestParser(manifestSrc, EXAMPLE_MANIFEST_URL, EXAMPLE_DOC_URL); | |||
return ManifestShortNameLengthAudit.audit(artifacts).then(result => { | |||
assert.equal(result.rawValue, false); | |||
assert.ok(result.explanation.includes('without truncation'), result.explanation); | |||
assert.ok(!result.explanation.includes('Manifest does not have `short_name`')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this line as it's not a possibility any longer? Want to assert not not applicable, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for fixing this @paulirish 😊 I know it's been over a year, just a quick question related to this change. From the description of the PR, the original goal was to remove the
If I understand the discussion correctly, it was then agreed to make it informative instead:
But in the end, the check still is mandatory: // Technically shortname isn't required (if name is defined):
// https://cs.chromium.org/chromium/src/chrome/browser/installable/installable_manager.cc?type=cs&q=IsManifestValidForWebApp+f:cc+-f:test&sq=package:chromium&l=473
// Despite this, we think it's better to require it anyway.
// short_name is preferred for the homescreen icon, but a longer name can be used in
// the splash screen and app title. Given the different usecases, we'd like to make it clearer
// that the developer has two possible strings to work with.
'hasShortName', Is there a particular reason for keeping it required in the (Problem background: Most PWA directories use the result of lighthouse |
Two separate, but related changes in here:
short_name
any more. It's never technically been required, so we shouldn't assert it.str.length <= 12
is kinda annoying.notApplicable: true
if no manifest is present. But honestly I don't think it's worth keeping it around. Open to arguments tho.Fixes #2698. See also #23 (comment)
Fixes #686 (comment)
Fixes #4860
Doesn't fix #348 because it makes a different conclusion.