-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show BCD mapping progress on front page
This is a temporary feature. The plan is to manually update the score in the storage bucket and have the frontend query that. App deployers will have to update the score manually. This should only last through December.
- Loading branch information
1 parent
d0bb86f
commit 288a534
Showing
30 changed files
with
474 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"bcd_map_progress": 62.5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+4.36 KB
(110%)
e2e/tests/overview-page.spec.ts-snapshots/internal-error-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.24 KB
(110%)
e2e/tests/overview-page.spec.ts-snapshots/internal-error-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.83 KB
(110%)
e2e/tests/overview-page.spec.ts-snapshots/internal-error-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.56 KB
(110%)
e2e/tests/overview-page.spec.ts-snapshots/invalid-query-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.18 KB
(110%)
e2e/tests/overview-page.spec.ts-snapshots/invalid-query-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.78 KB
(110%)
e2e/tests/overview-page.spec.ts-snapshots/invalid-query-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.25 KB
(100%)
...sts/overview-page.spec.ts-snapshots/matches-the-screenshot-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+16.8 KB
(110%)
...ests/overview-page.spec.ts-snapshots/matches-the-screenshot-1-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.31 KB
(100%)
...tests/overview-page.spec.ts-snapshots/matches-the-screenshot-1-webkit-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
frontend/src/static/js/components/test/webstatus-overview-content.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {provide} from '@lit/context'; | ||
import {LitElement, TemplateResult, html} from 'lit'; | ||
import {customElement, property} from 'lit/decorators.js'; | ||
import { | ||
appSettingsContext, | ||
AppSettings, | ||
} from '../../contexts/settings-context.js'; | ||
import {WebstatusOverviewContent} from '../webstatus-overview-content.js'; | ||
import '../webstatus-overview-content.js'; | ||
import {assert, expect} from '@open-wc/testing'; | ||
import {Toast} from '../../utils/toast.js'; | ||
import sinon from 'sinon'; | ||
|
||
@customElement('fake-parent-element') | ||
class FakeParentElement extends LitElement { | ||
@provide({context: appSettingsContext}) | ||
@property({type: Object}) | ||
settings!: AppSettings; | ||
|
||
render(): TemplateResult { | ||
return html`<slot></slot>`; | ||
} | ||
} | ||
|
||
describe('webstatus-overview-content', () => { | ||
describe('renderMappingPercentage', () => { | ||
let parent: FakeParentElement; | ||
let element: WebstatusOverviewContent; | ||
let container: HTMLElement; | ||
let testContainer: HTMLElement; | ||
beforeEach(async () => { | ||
container = document.createElement('div'); | ||
container.innerHTML = ` | ||
<fake-parent-element> | ||
<webstatus-overview-content> | ||
</webstatus-overview-content> | ||
</fake-parent-element> | ||
`; | ||
parent = container.querySelector( | ||
'fake-parent-element' | ||
) as FakeParentElement; | ||
|
||
element = container.querySelector( | ||
'webstatus-overview-content' | ||
) as WebstatusOverviewContent; | ||
document.body.appendChild(container); | ||
await parent.updateComplete; | ||
await element.updateComplete; | ||
testContainer = element?.shadowRoot?.querySelector( | ||
'#mapping-percentage' | ||
) as HTMLElement; | ||
assert.exists(testContainer); | ||
}); | ||
afterEach(() => { | ||
document.body.removeChild(container); | ||
}); | ||
it('should return an empty TemplateResult when webFeaturesProgress is undefined', () => { | ||
expect(testContainer.textContent?.trim()).to.equal(''); | ||
}); | ||
it('should return an empty TemplateResult when webFeaturesProgress is disabled', async () => { | ||
element.webFeaturesProgress = {isDisabled: true}; | ||
await element.updateComplete; | ||
expect(testContainer.textContent?.trim()).to.equal(''); | ||
}); | ||
|
||
it('should call toast with the error message when webFeaturesProgress has an error', async () => { | ||
const toastStub = sinon.stub(Toast.prototype, 'toast'); | ||
element.webFeaturesProgress = {error: 'Test error'}; | ||
|
||
await element.updateComplete; | ||
expect(toastStub.calledOnce).to.be.true; | ||
expect( | ||
toastStub.calledWith('Test error', 'danger', 'exclamation-triangle') | ||
).to.be.true; | ||
|
||
expect(testContainer.textContent?.trim()).to.equal(''); | ||
}); | ||
|
||
it('should render the mapping percentage when available', async () => { | ||
element.webFeaturesProgress = {bcdMapProgress: 75}; | ||
await element.updateComplete; | ||
expect(testContainer.textContent?.trim()).to.match( | ||
/Percentage of Features Mapped:\s*75%/ | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
frontend/src/static/js/contexts/webfeature-progress-context.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import {createContext} from '@lit/context'; | ||
|
||
export interface WebFeatureProgress { | ||
bcdMapProgress?: number; | ||
isDisabled?: boolean; | ||
error?: string; | ||
} | ||
|
||
export const webFeatureProgressContext = createContext< | ||
WebFeatureProgress | undefined | ||
>('webfeature-progress'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.