diff --git a/package-lock.json b/package-lock.json index 26cb9a0b0d118..e4846ed665f50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,7 +53,7 @@ "semver": "~7.6.0", "simple-icons": "11.4.0", "smol-toml": "1.1.4", - "webextension-store-meta": "^1.0.5", + "webextension-store-meta": "^1.1.0", "xpath": "~0.0.34" }, "devDependencies": { @@ -27177,11 +27177,11 @@ } }, "node_modules/webextension-store-meta": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/webextension-store-meta/-/webextension-store-meta-1.0.5.tgz", - "integrity": "sha512-gOXAHe0pA8eS14doSYyBiKzs6pXN+oOTocb4iwxXCRNyp+5JVVsWbLq1MCvkgpOKoHdQkeXcY5orTPZewuMTyQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/webextension-store-meta/-/webextension-store-meta-1.1.0.tgz", + "integrity": "sha512-sEOe3Iir4PB6f/hj9fAAaesUpYLU4XIwySMdOap7JfIhL9O4fmaoTWWuj/TCzOa7UcH/6X8Mq2+HmlAAE7D0zg==", "dependencies": { - "domutils": "^2.7.0", + "domhandler": "^4.0.0", "htmlparser2": "^6.1.0", "node-fetch": "^2.6.1" }, diff --git a/package.json b/package.json index 403714df4f79b..5f0f5e0f0910f 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "semver": "~7.6.0", "simple-icons": "11.4.0", "smol-toml": "1.1.4", - "webextension-store-meta": "^1.0.5", + "webextension-store-meta": "^1.1.0", "xpath": "~0.0.34" }, "scripts": { diff --git a/services/chrome-web-store/chrome-web-store-price.service.js b/services/chrome-web-store/chrome-web-store-price.service.js index dfc77db672d7c..090d44c08ec25 100644 --- a/services/chrome-web-store/chrome-web-store-price.service.js +++ b/services/chrome-web-store/chrome-web-store-price.service.js @@ -1,39 +1,10 @@ -import { currencyFromCode } from '../text-formatters.js' -import { NotFound, pathParams } from '../index.js' -import BaseChromeWebStoreService from './chrome-web-store-base.js' +import { deprecatedService } from '../index.js' -export default class ChromeWebStorePrice extends BaseChromeWebStoreService { - static category = 'funding' - static route = { base: 'chrome-web-store/price', pattern: ':storeId' } +const ChromeWebStorePrice = deprecatedService({ + category: 'funding', + route: { base: 'chrome-web-store/price', pattern: ':storeId' }, + label: 'price', + dateAdded: new Date('2024-02-18'), +}) - static openApi = { - '/chrome-web-store/price/{storeId}': { - get: { - summary: 'Chrome Web Store Price', - parameters: pathParams({ - name: 'storeId', - example: 'ogffaloegjglncjfehdfplabnoondfjo', - }), - }, - }, - } - - static defaultBadgeData = { label: 'price' } - - static render({ priceCurrency, price }) { - return { - message: `${currencyFromCode(priceCurrency) + price}`, - color: 'brightgreen', - } - } - - async handle({ storeId }) { - const chromeWebStore = await this.fetch({ storeId }) - const priceCurrency = chromeWebStore.priceCurrency() - const price = chromeWebStore.price() - if (priceCurrency == null || price == null) { - throw new NotFound({ prettyMessage: 'not found' }) - } - return this.constructor.render({ priceCurrency, price }) - } -} +export default ChromeWebStorePrice diff --git a/services/chrome-web-store/chrome-web-store-price.tester.js b/services/chrome-web-store/chrome-web-store-price.tester.js index 8c017faf5774c..0186df0121902 100644 --- a/services/chrome-web-store/chrome-web-store-price.tester.js +++ b/services/chrome-web-store/chrome-web-store-price.tester.js @@ -1,20 +1,12 @@ -import Joi from 'joi' -import { createServiceTester } from '../tester.js' -export const t = await createServiceTester() +import { ServiceTester } from '../tester.js' -t.create('Price') - .get('/alhjnofcnnpeaphgeakdhkebafjcpeae.json') - .expectBadge({ - label: 'price', - message: Joi.string().regex(/^\$\d+(.\d{1,2})?$/), - }) +export const t = new ServiceTester({ + id: 'ChromeWebStorePrice', + title: 'ChromeWebStorePrice', + pathPrefix: '/chrome-web-store/price', +}) -t.create('Price (not found)') - .get('/invalid-name-of-addon.json') - .expectBadge({ label: 'price', message: 'not found' }) - -// Keep this "inaccessible" test, since this service does not use BaseService#_request. -t.create('Price (inaccessible)') - .get('/alhjnofcnnpeaphgeakdhkebafjcpeae.json') - .networkOff() - .expectBadge({ label: 'price', message: 'inaccessible' }) +t.create('Price').get('/alhjnofcnnpeaphgeakdhkebafjcpeae.json').expectBadge({ + label: 'price', + message: 'no longer available', +}) diff --git a/services/chrome-web-store/chrome-web-store-users.service.js b/services/chrome-web-store/chrome-web-store-users.service.js index 78175213f38cc..bddc4f9925d71 100644 --- a/services/chrome-web-store/chrome-web-store-users.service.js +++ b/services/chrome-web-store/chrome-web-store-users.service.js @@ -26,7 +26,9 @@ class ChromeWebStoreUsers extends BaseChromeWebStoreService { if (downloads == null) { throw new NotFound({ prettyMessage: 'not found' }) } - return renderDownloadsBadge({ downloads }) + return renderDownloadsBadge({ + downloads: String(downloads.replace(',', '')), + }) } }