Repository: ROpdebee/mb-userscripts
Pull request #498 (2022-06-16 08:56:23)

test(ecau): test for missing providers in docs
While adding new providers yesterday, I kept on forgetting to add them to the `supported_providers.md` file. This adds a test to verify that the new provider has an entry in that file.

codecov[bot]: # [Codecov](https://codecov.io/gh/ROpdebee/mb-userscripts/pull/498?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ruben+Opdebeeck) Report
> Merging [#498](https://codecov.io/gh/ROpdebee/mb-userscripts/pull/498?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ruben+Opdebeeck) (fa0a4a3) into [main](https://codecov.io/gh/ROpdebee/mb-userscripts/commit/25c603c0134216965028db74919f094a5cc13c5d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ruben+Opdebeeck) (25c603c) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@            Coverage Diff            @@
##              main      #498   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           53        53           
  Lines         1222      1222           
  Branches       194       194           
=========================================
  Hits          1222      1222           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/ROpdebee/mb-userscripts/pull/498?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ruben+Opdebeeck).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ruben+Opdebeeck)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/ROpdebee/mb-userscripts/pull/498?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ruben+Opdebeeck). Last update [25c603c...fa0a4a3](https://codecov.io/gh/ROpdebee/mb-userscripts/pull/498?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ruben+Opdebeeck). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ruben+Opdebeeck).


Patch:
diff --git a/src/mb_caa_dimensions/DisplayedImage.tsx b/src/mb_caa_dimensions/DisplayedImage.tsx
index cb80dc90..3c3b47d8 100644
--- a/src/mb_caa_dimensions/DisplayedImage.tsx
+++ b/src/mb_caa_dimensions/DisplayedImage.tsx
@@ -15,7 +15,7 @@ export interface DisplayedImage {
 
 export function createDimensionsString(imageInfo: ImageInfo): string {
     return (typeof imageInfo.dimensions !== 'undefined'
-        ? `${imageInfo.dimensions.height}x${imageInfo.dimensions.width}`
+        ? `${imageInfo.dimensions.width}x${imageInfo.dimensions.height}`
         : 'failed :(');
 }
 
diff --git a/src/mb_enhanced_cover_art_uploads/docs/supported_providers.md b/src/mb_enhanced_cover_art_uploads/docs/supported_providers.md
index a7159c32..79a1233a 100644
--- a/src/mb_enhanced_cover_art_uploads/docs/supported_providers.md
+++ b/src/mb_enhanced_cover_art_uploads/docs/supported_providers.md
@@ -18,12 +18,12 @@ The following table describes the types of links supported by MB: Upload to CAA
 | Discogs | Partial | ❌ | Images are limited to 600x600, see [qsniyg/maxurl#689](https://github.com/qsniyg/maxurl/issues/689) |
 | Jamendo | ✔️ | ✔️ |
 | Melon | ✔️ | ✔️ |
-| MusicBrainz/CAA | ✔️ | ✔️ | To copy images from one release to another. |
+| MusicBrainz/Cover Art Archive | ✔️ | ✔️ | To copy images from one release to another. |
 | Musik-Sammler | ✔️ | ❌ |
 | Qobuz | ✔️ | ✔️ | Goodies are grabbed whenever possible. Back covers might not be supported at this time, if you have a release with a back cover, please let me know. Maximised to original source image. |
 | QUB Musique | ✔️ | ✔️ | Dispatched to Qobuz provider. |
 | RateYourMusic | ✔️ | ✔️ | Requires being logged in to RYM. |
-| Rockipedia.no | ✔️ | ❌ |
+| Rockipedia | ✔️ | ❌ |
 | Soundcloud | ✔️ | ✔️ | Grabs custom track images. |
 | Spotify | ✔️ | ✔️ |
 | Tidal | ✔️ | ✔️ | listen.tidal.com/store.tidal.com are converted to tidal.com prior to fetching |


Test patch:
diff --git a/tests/unit/mb_enhanced_cover_art_uploads/providers/docs.test.ts b/tests/unit/mb_enhanced_cover_art_uploads/providers/docs.test.ts
new file mode 100644
index 00000000..969943a0
--- /dev/null
+++ b/tests/unit/mb_enhanced_cover_art_uploads/providers/docs.test.ts
@@ -0,0 +1,41 @@
+import '@src/mb_enhanced_cover_art_uploads/providers';
+
+import fs from 'node:fs/promises';
+
+import type { CoverArtProvider } from '@src/mb_enhanced_cover_art_uploads/providers/base';
+import { DispatchMap } from '@lib/util/domain_dispatch';
+
+jest.mock('@lib/util/domain_dispatch');
+
+// eslint-disable-next-line jest/unbound-method
+const spyDispatchMapSet = DispatchMap.prototype.set as jest.MockedFunction<DispatchMap<CoverArtProvider>['set']>;
+
+function getAllProviderNamesInSource(): Set<string> {
+    const providerNames = new Set<string>();
+
+    for (const [, provider] of spyDispatchMapSet.mock.calls) {
+        providerNames.add(provider.name);
+    }
+
+    return providerNames;
+}
+
+describe('cover art provider documentation', () => {
+    const providerNamesInDocs = new Set<string>();
+
+    beforeAll(async () => {
+        const docsContent = await fs.readFile('./src/mb_enhanced_cover_art_uploads/docs/supported_providers.md', {
+            encoding: 'utf8',
+        });
+
+        for (const providerNameMatch of docsContent.matchAll(/^\|([^|]+)\|/gm)) {
+            for (const providerName of providerNameMatch[1].split('/')) {
+                providerNamesInDocs.add(providerName.trim());
+            }
+        }
+    });
+
+    it.each([...getAllProviderNamesInSource()])('has an entry for %s', (providerName) => {
+        expect(providerNamesInDocs.has(providerName)).toBeTrue();
+    });
+});