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(seo): UI disabled tab buttons in seo toolbar don't show properly #26490

Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ describe('DotSetMetaTagsService', () => {
'seo.rules.og-description.description.not.found':
'og:description meta tag, and Meta Description not found!',
'seo.rules.twitter-card-description.description.not.found':
'twitter:description meta tag not found! Showing Description instead.'
'twitter:description meta tag, and Meta Description not found!',
'seo.rules.twitter-card-title.title.not.found':
'twitter:title meta tag not found, and HTML Title not found!'
})
},
DotUploadService
Expand Down Expand Up @@ -616,4 +618,86 @@ describe('DotSetMetaTagsService', () => {
done();
});
});

it('should found twitter:description meta tag not found! Showing Description instead.', (done) => {
const doc: Document = document.implementation.createDocument(
'http://www.w3.org/1999/xhtml',
'html',
null
);
manuelrojas marked this conversation as resolved.
Show resolved Hide resolved

const head = doc.createElement('head');
doc.documentElement.appendChild(head);

const metaDesc = document.createElement('meta');
metaDesc.name = 'description';
metaDesc.content =
'Get down to Costa Rica this winter for some of the best surfing int he world. Large winter swell is pushing across the Pacific.';
head.appendChild(metaDesc);

service.getMetaTagsResults(doc).subscribe((value) => {
expect(value[8].items[0].message).toEqual(
'<code>twitter:description</code> meta tag not found! Showing Description instead.'
);
done();
});
});

it('should found twitter:description meta tag', (done) => {
const doc: Document = document.implementation.createDocument(
'http://www.w3.org/1999/xhtml',
'html',
null
);

const head = doc.createElement('head');
doc.documentElement.appendChild(head);

service.getMetaTagsResults(doc).subscribe((value) => {
expect(value[8].items[0].message).toEqual(
'<code>twitter:description</code> meta tag, and Meta Description not found!'
);
done();
});
});

it('should found twitter:title meta tag not found and HTML Title not found!', (done) => {
const doc: Document = document.implementation.createDocument(
'http://www.w3.org/1999/xhtml',
'html',
null
);

const head = doc.createElement('head');
doc.documentElement.appendChild(head);

service.getMetaTagsResults(doc).subscribe((value) => {
expect(value[7].items[0].message).toEqual(
'<code>twitter:title</code> meta tag not found, and HTML Title not found!'
);
done();
});
});

it('should found twitter:title meta tag, Showing HTML Title instead.', (done) => {
const doc: Document = document.implementation.createDocument(
'http://www.w3.org/1999/xhtml',
'html',
null
);

const head = doc.createElement('head');
doc.documentElement.appendChild(head);

const title = document.createElement('title');
title.innerText = 'Costa Rica Special Offer';
head.appendChild(title);

service.getMetaTagsResults(doc).subscribe((value) => {
expect(value[7].items[0].message).toEqual(
'<code>twitter:title</code> meta tag not found! Showing HTML Title instead.'
);
done();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,13 @@ export class DotSeoMetaTagsService {
const result: SeoRulesResult[] = [];
const titleCardElements = metaTagsObject['twitterTitleElements'];
const titleCard = metaTagsObject['twitter:title'];
const title = metaTagsObject['og:title'];
const titleElements = metaTagsObject['titleOgElements'];
const titleOg = metaTagsObject['og:title'];
const titleOgElements = metaTagsObject['titleOgElements'];
const title = metaTagsObject['title'];
const titleElements = metaTagsObject['titleElements'];

if (
title &&
(title || titleOg) &&
this.dotSeoMetaTagsUtilService.areAllFalsyOrEmpty([titleCard, titleCardElements])
) {
result.push(
Expand All @@ -567,7 +569,9 @@ export class DotSeoMetaTagsService {
title,
titleCard,
titleElements,
titleCardElements
titleCardElements,
titleOgElements,
titleOg
])
) {
result.push(
Expand Down Expand Up @@ -631,11 +635,13 @@ export class DotSeoMetaTagsService {
const result: SeoRulesResult[] = [];
const twitterDescriptionElements = metaTagsObject['twitterDescriptionElements'];
const twitterDescription = metaTagsObject['twitter:description'];
const ogDescriptionElements = metaTagsObject['ogDescriptionElements'];
const ogDescriptionElements = metaTagsObject['descriptionOgElements'];
const ogDescription = metaTagsObject['og:description'];
const descriptionElements = metaTagsObject['descriptionElements'];
const description = metaTagsObject['description'];

if (
ogDescription &&
(description || ogDescription) &&
this.dotSeoMetaTagsUtilService.areAllFalsyOrEmpty([
twitterDescription,
twitterDescriptionElements
Expand All @@ -653,7 +659,9 @@ export class DotSeoMetaTagsService {
twitterDescription,
twitterDescriptionElements,
ogDescriptionElements,
ogDescriptionElements
descriptionElements,
ogDescription,
description
])
) {
result.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class DotResultsSeoToolComponent implements OnInit, OnChanges {

const twitterTitle = twitterTitleProperties
.map((property) =>
this.seoOGTags[property]?.slice(0, SEO_LIMITS.MAX_TWITTER_DESCRIPTION_LENGTH)
this.seoOGTags[property]?.slice(0, SEO_LIMITS.MAX_TWITTER_TITLE_LENGTH)
)
.find((value) => value !== undefined);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<button
class="dot-tab__dropdown"
*ngIf="item.value.showDropdownButton"
[disabled]="item.disabled"
manuelrojas marked this conversation as resolved.
Show resolved Hide resolved
[ngClass]="{ 'dot-tab-dropdown--active': activeId === item.value.id }"
(click)="onClickDropdown($event, item.value.id)"
data-testId="dot-tab-button-dropdown">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ $dot-tab-height: 2.5rem;
&:hover {
background: $color-palette-primary-100;
}

&:disabled {
cursor: not-allowed;
background-color: $color-palette-gray-100;
color: $color-palette-gray-500;
}
}

.dot-tab__button--right {
Expand All @@ -58,6 +64,12 @@ $dot-tab-height: 2.5rem;
&:hover {
background: $color-palette-primary-200;
}

&:disabled {
cursor: not-allowed;
background-color: $color-palette-gray-100;
color: $color-palette-gray-500;
}
}

.dot-tab-indicator {
Expand Down
Loading