diff --git a/.dockerignore b/.dockerignore index 8dd8c6a..db82531 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,6 @@ .git node_modules Dockerfile +.forgejo +README.md +renovate.json \ No newline at end of file diff --git a/.forgejo/workflows/build-image.yml b/.forgejo/workflows/build-image.yml index 70bf0ae..c564782 100644 --- a/.forgejo/workflows/build-image.yml +++ b/.forgejo/workflows/build-image.yml @@ -39,3 +39,15 @@ jobs: password: ${{ secrets.FORGEJO_REGISTRY_TOKEN }} image: combinefm tags: latest ${{ github.sha }} + test-image: + runs-on: self-hosted + steps: + - name: Check out repository + uses: https://cremin.dev/actions/checkout@v4 + - name: Test image + env: + YOUTUBE_KEY: ${{ secrets.YOUTUBE_KEY }} + SPOTIFY_CLIENT_ID: ${{ secrets.SPOTIFY_CLIENT_ID }} + SPOTIFY_CLIENT_SECRET: ${{ secrets.SPOTIFY_CLIENT_SECRET }} + run: | + podman run --rm --env-host -it cremin.dev/jonathan/combinefm:${{ github.sha }} yarn test diff --git a/docker-compose.yml b/docker-compose.yml index 88527e4..6d4d7b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: app: build: context: ./ - dockerfile: Dockerfile.dev + dockerfile: Containerfile environment: DEBUG: "combine.fm*" VUE_ENV: server @@ -30,7 +30,7 @@ services: worker: build: context: ./ - dockerfile: Dockerfile.dev + dockerfile: Containerfile environment: DEBUG: "combine.fm*" VUE_ENV: server diff --git a/package.json b/package.json index d631f8f..cde14e8 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "NODE_OPTIONS=--openssl-legacy-provider webpack --mode=production --config webpack.config.cjs && NODE_OPTIONS=--openssl-legacy-provider webpack --config webpack.config.server.cjs", "start": "node app.js", "worker": "node worker.js", - "test": "mocha-esm test/**/*.js test/lookup.js --timeout=15000", + "test": "mocha-esm test/services/deezer.js test/services/itunes.js test/services/spotify.js test/services/youtube.js test/lookup.js --timeout=15000", "watch": "concurrently -k \"npm:watch-js\" \"npm:watch-server\"", "watch-js": "NODE_OPTIONS=--openssl-legacy-provider concurrently -k -n webpack-frontend,webpack-server \"webpack -w -d --config webpack.config.cjs\" \"webpack -w --config webpack.config.server.cjs\"", "watch-server": "nodemon -e js,vue -i node_modules -i chrome/ app.js", diff --git a/test/lookup.js b/test/lookup.js index ab4d588..aa2bc1e 100644 --- a/test/lookup.js +++ b/test/lookup.js @@ -1,9 +1,11 @@ -import 'should'; -import lookup from '../lib/lookup.js'; +import "should"; +import lookup from "../lib/lookup.js"; -describe('Search with url', function(){ - it('should find album by url', async function (){ - const result = await lookup('https://play.google.com/music/m/Bw2bwajaddrgr5vakp3vluqothq'); - result.name.should.equal('Breaking'); +describe("Search with url", function() { + it("should find album by url", async function() { + const result = await lookup( + "https://open.spotify.com/album/5TbRo1rBrhgHSTB4i2wdZS" + ); + result.name.should.equal("Atom Bomb"); }); }); diff --git a/test/services/spotify.js b/test/services/spotify.js index e135aef..539cfde 100644 --- a/test/services/spotify.js +++ b/test/services/spotify.js @@ -1,40 +1,63 @@ -import 'should'; -import * as spotify from '../../lib/services/spotify/index.js'; +import "should"; +import * as spotify from "../../lib/services/spotify/index.js"; -describe('Spotify', function(){ - describe('lookupId', function(){ - it('should find album by ID', async function (){ - const result = await spotify.lookupId('77UW17CZFyCaRLHdHeofZu', 'album'); - result.name.should.equal('Listen'); - }); - - it('should find track by ID', async function (){ - const result = await spotify.lookupId('7dS5EaCoMnN7DzlpT6aRn2', 'track'); - result.name.should.equal('Take Me To Church'); +describe("Spotify", function() { + describe("init", function() { + it("should have secrets", async function() { + process.env.SPOTIFY_CLIENT_ID.should.exist; }); }); - describe('search', function(){ - it('should find album by search', async function (){ - const result = await spotify.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'}); - result.name.should.equal('Listen (Deluxe)'); + describe("lookupId", function() { + it("should find album by ID", async function() { + const result = await spotify.lookupId("77UW17CZFyCaRLHdHeofZu", "album"); + result.name.should.equal("Listen"); }); - it('should find br album by search', async function (){ - const result = await spotify.search({type: 'album', artist: {name: 'Anavitória'}, name: 'Fica'}); - result.name.should.equal('Fica'); - }); - - it('should find album by various artists by search', async function (){ - const result = await spotify.search({type: 'album', artist: {name: 'Various Artists'}, name: 'The Get Down Part II: Original Soundtrack From The Netflix Original Series'}); - result.name.should.equal('The Get Down Part II: Original Soundtrack From The Netflix Original Series'); + it("should find track by ID", async function() { + const result = await spotify.lookupId("7dS5EaCoMnN7DzlpT6aRn2", "track"); + result.name.should.equal("Take Me To Church"); }); }); - describe('parseUrl', function(){ - it('should parse url into ID', async function (){ - const result = await spotify.parseUrl('https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu'); - result.id.should.equal('77UW17CZFyCaRLHdHeofZu'); + describe("search", function() { + it("should find album by search", async function() { + const result = await spotify.search({ + type: "album", + artist: { name: "David Guetta" }, + name: "Listen (Deluxe)" + }); + result.name.should.equal("Listen (Deluxe)"); + }); + + it("should find br album by search", async function() { + const result = await spotify.search({ + type: "album", + artist: { name: "Anavitória" }, + name: "Fica" + }); + result.name.should.equal("Fica"); + }); + + it("should find album by various artists by search", async function() { + const result = await spotify.search({ + type: "album", + artist: { name: "Various Artists" }, + name: + "The Get Down Part II: Original Soundtrack From The Netflix Original Series" + }); + result.name.should.equal( + "The Get Down Part II: Original Soundtrack From The Netflix Original Series" + ); + }); + }); + + describe("parseUrl", function() { + it("should parse url into ID", async function() { + const result = await spotify.parseUrl( + "https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu" + ); + result.id.should.equal("77UW17CZFyCaRLHdHeofZu"); }); }); }); diff --git a/test/services/spotify.sync-conflict-20250612-195820-SCF3HLT.js b/test/services/spotify.sync-conflict-20250612-195820-SCF3HLT.js new file mode 100644 index 0000000..93c788e --- /dev/null +++ b/test/services/spotify.sync-conflict-20250612-195820-SCF3HLT.js @@ -0,0 +1,46 @@ +import 'should'; +import * as spotify from '../../lib/services/spotify/index.js'; + +describe('Spotify', function(){ + describe('init', function(){ + it('should have secrets', async function (){ + process.env.SPOTIFY_CLIENT_ID.should.exist(); + }); + }); + + describe('lookupId', function(){ + it('should find album by ID', async function (){ + const result = await spotify.lookupId('77UW17CZFyCaRLHdHeofZu', 'album'); + result.name.should.equal('Listen'); + }); + + it('should find track by ID', async function (){ + const result = await spotify.lookupId('7dS5EaCoMnN7DzlpT6aRn2', 'track'); + result.name.should.equal('Take Me To Church'); + }); + }); + + describe('search', function(){ + it('should find album by search', async function (){ + const result = await spotify.search({type: 'album', artist: {name: 'David Guetta'}, name: 'Listen (Deluxe)'}); + result.name.should.equal('Listen (Deluxe)'); + }); + + it('should find br album by search', async function (){ + const result = await spotify.search({type: 'album', artist: {name: 'Anavitória'}, name: 'Fica'}); + result.name.should.equal('Fica'); + }); + + it('should find album by various artists by search', async function (){ + const result = await spotify.search({type: 'album', artist: {name: 'Various Artists'}, name: 'The Get Down Part II: Original Soundtrack From The Netflix Original Series'}); + result.name.should.equal('The Get Down Part II: Original Soundtrack From The Netflix Original Series'); + }); + }); + + describe('parseUrl', function(){ + it('should parse url into ID', async function (){ + const result = await spotify.parseUrl('https://play.spotify.com/album/77UW17CZFyCaRLHdHeofZu'); + result.id.should.equal('77UW17CZFyCaRLHdHeofZu'); + }); + }); +}); diff --git a/test/services/youtube.js b/test/services/youtube.js index 42b42fa..4ca191e 100644 --- a/test/services/youtube.js +++ b/test/services/youtube.js @@ -1,18 +1,23 @@ -import 'should'; -import * as youtube from '../../lib/services/youtube/index.js'; +import "should"; +import * as youtube from "../../lib/services/youtube/index.js"; -describe('Youtube', function(){ - describe('lookup', function(){ - it('should find album by lookup', async function (){ - const result = await youtube.lookupId('6JnGBs88sL0'); - result.name.should.equal('Say It Right'); +describe("Youtube", function() { + describe("lookup", function() { + it("should find album by lookup", async function() { + const result = await youtube.lookupId("6JnGBs88sL0"); + result.name.should.equal("Say It Right"); }); }); - describe('search', function(){ - it('should find album by search', async function (){ - const result = await youtube.search({type: 'track', artist: {name: 'Aesop Rock'}, album: {name: 'Skeconsthon'}, name: 'Zero Dark Thirty'}); - result.name.should.equal('Aesop Rock - Zero Dark Thirty (Official Video)'); + describe("search", function() { + it("should find album by search", async function() { + const result = await youtube.search({ + type: "track", + artist: { name: "Aesop Rock" }, + album: { name: "Skeconsthon" }, + name: "Zero Dark Thirty" + }); + result.name.should.startWith("Aesop Rock - Zero Dark Thirty"); }); }); });