Merge pull request #243 from tidalcycles/shared-tests
snapshot tests on shared snippets
This commit is contained in:
commit
c3d6de2412
8 changed files with 7002 additions and 1 deletions
|
|
@ -113,6 +113,10 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const base = sampleMap.split('/').slice(0, -1).join('/');
|
const base = sampleMap.split('/').slice(0, -1).join('/');
|
||||||
|
if (typeof fetch === 'undefined') {
|
||||||
|
// skip fetch when in node / testing
|
||||||
|
return;
|
||||||
|
}
|
||||||
return fetch(sampleMap)
|
return fetch(sampleMap)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((json) => samples(json, baseUrl || json._base || base))
|
.then((json) => samples(json, baseUrl || json._base || base))
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
"name": "@strudel.cycles/repl",
|
"name": "@strudel.cycles/repl",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --host",
|
"dev": "vite --host",
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
|
|
@ -12,7 +13,8 @@
|
||||||
"add-license": "cat etc/agpl-header.txt ../docs/static/js/*LICENSE.txt > /tmp/strudel-license.txt && cp /tmp/strudel-license.txt ../docs/static/js/*LICENSE.txt",
|
"add-license": "cat etc/agpl-header.txt ../docs/static/js/*LICENSE.txt > /tmp/strudel-license.txt && cp /tmp/strudel-license.txt ../docs/static/js/*LICENSE.txt",
|
||||||
"predeploy": "npm run build",
|
"predeploy": "npm run build",
|
||||||
"deploy": "gh-pages -d ../docs",
|
"deploy": "gh-pages -d ../docs",
|
||||||
"static": "npx serve ../docs"
|
"static": "npx serve ../docs",
|
||||||
|
"dbdump": "node src/test/dbdump.js > src/test/dbdump.json"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@supabase/supabase-js": "^1.35.3",
|
"@supabase/supabase-js": "^1.35.3",
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ const toneHelpersMocked = {
|
||||||
Chorus: MockedNode,
|
Chorus: MockedNode,
|
||||||
Freeverb: MockedNode,
|
Freeverb: MockedNode,
|
||||||
Gain: MockedNode,
|
Gain: MockedNode,
|
||||||
|
Reverb: MockedNode,
|
||||||
vol: mockNode,
|
vol: mockNode,
|
||||||
out: id,
|
out: id,
|
||||||
osc: id,
|
osc: id,
|
||||||
|
|
@ -116,17 +117,40 @@ strudel.Pattern.prototype.adsr = function () {
|
||||||
strudel.Pattern.prototype.out = function () {
|
strudel.Pattern.prototype.out = function () {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
strudel.Pattern.prototype.soundfont = function () {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
// tune mock
|
// tune mock
|
||||||
strudel.Pattern.prototype.tune = function () {
|
strudel.Pattern.prototype.tune = function () {
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
strudel.Pattern.prototype.midi = function () {
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
const uiHelpersMocked = {
|
const uiHelpersMocked = {
|
||||||
backgroundImage: id,
|
backgroundImage: id,
|
||||||
};
|
};
|
||||||
|
|
||||||
prebake({ isMock: true });
|
prebake({ isMock: true });
|
||||||
|
|
||||||
|
const canvasCtx = {
|
||||||
|
clearRect: () => {},
|
||||||
|
fillText: () => {},
|
||||||
|
fillRect: () => {},
|
||||||
|
canvas: {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const audioCtx = {
|
||||||
|
currentTime: 1,
|
||||||
|
};
|
||||||
|
const getDrawContext = () => canvasCtx;
|
||||||
|
const getAudioContext = () => audioCtx;
|
||||||
|
const loadSoundfont = () => {};
|
||||||
|
|
||||||
// TODO: refactor to evalScope
|
// TODO: refactor to evalScope
|
||||||
evalScope(
|
evalScope(
|
||||||
// Tone,
|
// Tone,
|
||||||
|
|
@ -146,6 +170,10 @@ evalScope(
|
||||||
// gist,
|
// gist,
|
||||||
// euclid,
|
// euclid,
|
||||||
mini,
|
mini,
|
||||||
|
getDrawContext,
|
||||||
|
getAudioContext,
|
||||||
|
loadSoundfont,
|
||||||
|
Clock: {}, // whatever
|
||||||
// Tone,
|
// Tone,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -197,3 +225,6 @@ export const testCycles = {
|
||||||
hyperpop: 10,
|
hyperpop: 10,
|
||||||
festivalOfFingers3: 16,
|
festivalOfFingers3: 16,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// fixed: https://strudel.tidalcycles.org/?DBp75NUfSxIn (missing .note())
|
||||||
|
// bug: https://strudel.tidalcycles.org/?xHaKTd1kTpCn + https://strudel.tidalcycles.org/?o5LLePbx8kiQ
|
||||||
|
|
|
||||||
6928
repl/src/test/__snapshots__/shared.test.mjs.snap
Normal file
6928
repl/src/test/__snapshots__/shared.test.mjs.snap
Normal file
File diff suppressed because it is too large
Load diff
10
repl/src/test/dbdump.js
Normal file
10
repl/src/test/dbdump.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { createClient } from '@supabase/supabase-js';
|
||||||
|
|
||||||
|
const supabase = createClient(
|
||||||
|
'https://pidxdsxphlhzjnzmifth.supabase.co',
|
||||||
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBpZHhkc3hwaGxoempuem1pZnRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTYyMzA1NTYsImV4cCI6MTk3MTgwNjU1Nn0.bqlw7802fsWRnqU5BLYtmXk_k-D1VFmbkHMywWc15NM',
|
||||||
|
);
|
||||||
|
|
||||||
|
const { data } = await supabase.from('code');
|
||||||
|
|
||||||
|
console.log(JSON.stringify(data));
|
||||||
1
repl/src/test/dbdump.json
Normal file
1
repl/src/test/dbdump.json
Normal file
File diff suppressed because one or more lines are too long
17
repl/src/test/shared.test.mjs
Normal file
17
repl/src/test/shared.test.mjs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { queryCode } from '../runtime.mjs';
|
||||||
|
import { describe, it } from 'vitest';
|
||||||
|
import data from './dbdump.json';
|
||||||
|
|
||||||
|
describe('renders shared tunes', async () => {
|
||||||
|
data.forEach(({ id, code, hash }) => {
|
||||||
|
const url = `https://strudel.tidalcycles.org/?${hash}`;
|
||||||
|
it(`shared tune ${id} ${url}`, async ({ expect }) => {
|
||||||
|
if (code.includes('import(')) {
|
||||||
|
console.log('skip', url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const haps = await queryCode(code, 1);
|
||||||
|
expect(haps).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -11,5 +11,13 @@ export default defineConfig({
|
||||||
reporters: 'verbose',
|
reporters: 'verbose',
|
||||||
isolate: false,
|
isolate: false,
|
||||||
silent: true,
|
silent: true,
|
||||||
|
exclude: [
|
||||||
|
'**/node_modules/**',
|
||||||
|
'**/dist/**',
|
||||||
|
'**/cypress/**',
|
||||||
|
'**/.{idea,git,cache,output,temp}/**',
|
||||||
|
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*',
|
||||||
|
'**/shared.test.mjs',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue