Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,56 @@ describe('webstatus-feature-page', () => {
});
});

describe('renderOneWPTCard', () => {
let element: FeaturePage;
let hostElement: HTMLDivElement;

beforeEach(async () => {
element = await fixture(
html`<webstatus-feature-page
.location=${location}
></webstatus-feature-page>`,
);
hostElement = document.createElement('div');
});

it('marks unavailable browser implementation cards as disabled', async () => {
element.feature = {
feature_id: 'id',
name: 'name',
browser_implementations: {
chrome: {status: 'unavailable'},
},
};

const actual = element.renderOneWPTCard('chrome', 'chrome_24x24.png');
render(actual, hostElement);
const host = await fixture(hostElement);
const card = host.querySelector('sl-card');

expect(card).to.exist;
expect(card!.classList.contains('browser-impl-unavailable')).to.be.true;
});

it('marks available browser implementation cards as available', async () => {
element.feature = {
feature_id: 'id',
name: 'name',
browser_implementations: {
chrome: {status: 'available', version: '123'},
},
};

const actual = element.renderOneWPTCard('chrome', 'chrome_24x24.png');
render(actual, hostElement);
const host = await fixture(hostElement);
const card = host.querySelector('sl-card');

expect(card).to.exist;
expect(card!.classList.contains('browser-impl-available')).to.be.true;
});
});

describe('renderDeveloperSignal', () => {
let element: FeaturePage;
let hostElement: HTMLDivElement;
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/static/js/components/webstatus-feature-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ export class FeaturePage extends BaseChartsPage {
.wptScore .icon {
float: right;
}
.wptScore.browser-impl-unavailable .icon {
filter: grayscale(1);
opacity: 50%;
}
.wptScore .score {
font-size: 150%;
white-space: nowrap;
Expand Down Expand Up @@ -711,17 +715,20 @@ export class FeaturePage extends BaseChartsPage {
browser: components['parameters']['browserPathParam'],
icon: string,
): TemplateResult {
const browserImpl = this.feature?.browser_implementations?.[browser];
const browserImplStatus = browserImpl?.status || 'unavailable';
const scorePart = this.feature
? renderBrowserQuality(
this.feature,
{search: ''},
{browser: browser, fallbackText: 'N/A'},
)
: html`<sl-skeleton effect="sheen"></sl-skeleton>`;
const browserImpl = this.feature?.browser_implementations?.[browser];

return html`
<sl-card class="halign-stretch wptScore">
<sl-card
class="halign-stretch wptScore browser-impl-${browserImplStatus}"
>
<img height="32" src="/public/img/${icon}" class="icon" />
<div>${BROWSER_ID_TO_LABEL[browser]}</div>
<div class="score">${scorePart}</div>
Expand Down
Loading