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

fix: short_name shouldn't be required if the name is short #5449

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lighthouse-core/gather/computed/manifest-values.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ class ManifestValues extends ComputedArtifact {
{
id: 'hasShortName',
failureText: 'Manifest does not have `short_name`',
validate: manifestValue => !!manifestValue.short_name.value,
validate: manifestValue => !!manifestValue.short_name.value || !!manifestValue.name.value &&
manifestValue.name.value.length <= SUGGESTED_SHORTNAME_LENGTH,
},
{
id: 'shortNameLength',
failureText: 'Manifest `short_name` will be truncated when displayed on the homescreen',
validate: manifestValue => !!manifestValue.short_name.value &&
validate: manifestValue => !manifestValue.short_name.value ||
manifestValue.short_name.value.length <= SUGGESTED_SHORTNAME_LENGTH,
},
{
Expand Down
11 changes: 11 additions & 0 deletions lighthouse-core/test/audits/manifest-short-name-length-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ describe('Manifest: short_name_length audit', () => {
});
});

it('succeeds when a manifest contains a name that is already short', () => {
const artifacts = generateMockArtifacts();
const manifestSrc = JSON.stringify({
name: 'Lighthouse',
});
artifacts.Manifest = manifestParser(manifestSrc, EXAMPLE_MANIFEST_URL, EXAMPLE_DOC_URL);
return ManifestShortNameLengthAudit.audit(artifacts).then(result => {
assert.equal(result.rawValue, true);
});
});

// Need to disable camelcase check for dealing with short_name.
/* eslint-disable camelcase */
it('fails when a manifest contains a too long short_name', () => {
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/fixtures/manifest-bom.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "ExApp",
"name": "Example App",
"name": "Example Application",
"start_url": "./",
"icons": [
{
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/test/fixtures/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "ExApp",
"name": "Example App",
"name": "Example Application",
"start_url": "./",
"icons": [
{
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/test/gather/gatherers/manifest-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ describe('Manifest gatherer', () => {
promises.push(manifestGather.afterPass(getDriver(manifestWithBOM))
.then(manifest => {
assert.strictEqual(manifest.raw, Buffer.from(manifestWithBOM).slice(3).toString());
assert.strictEqual(manifest.value.name.value, 'Example App');
assert.strictEqual(manifest.value.name.value, 'Example Application');
assert.strictEqual(manifest.value.short_name.value, 'ExApp');
})
);

promises.push(manifestGather.afterPass(getDriver(manifestWithoutBOM))
.then(manifest => {
assert.strictEqual(manifest.raw, manifestWithoutBOM);
assert.strictEqual(manifest.value.name.value, 'Example App');
assert.strictEqual(manifest.value.name.value, 'Example Application');
assert.strictEqual(manifest.value.short_name.value, 'ExApp');
})
);
Expand Down