mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-13 22:58:34 +00:00
add shared tunes test
This commit is contained in:
parent
f829f35cfa
commit
ed44f4ed0c
@ -109,6 +109,10 @@ export const samples = async (sampleMap, baseUrl = sampleMap._base || '') => {
|
||||
sampleMap = `https://raw.githubusercontent.com/${path}/strudel.json`;
|
||||
}
|
||||
const base = sampleMap.split('/').slice(0, -1).join('/');
|
||||
if (typeof fetch === 'undefined') {
|
||||
// skip fetch when in node / testing
|
||||
return;
|
||||
}
|
||||
return fetch(sampleMap)
|
||||
.then((res) => res.json())
|
||||
.then((json) => samples(json, baseUrl || json._base || base))
|
||||
|
||||
@ -65,6 +65,7 @@ const toneHelpersMocked = {
|
||||
Chorus: MockedNode,
|
||||
Freeverb: MockedNode,
|
||||
Gain: MockedNode,
|
||||
Reverb: MockedNode,
|
||||
vol: mockNode,
|
||||
out: id,
|
||||
osc: id,
|
||||
@ -116,17 +117,40 @@ strudel.Pattern.prototype.adsr = function () {
|
||||
strudel.Pattern.prototype.out = function () {
|
||||
return this;
|
||||
};
|
||||
strudel.Pattern.prototype.soundfont = function () {
|
||||
return this;
|
||||
};
|
||||
// tune mock
|
||||
strudel.Pattern.prototype.tune = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
strudel.Pattern.prototype.midi = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
const uiHelpersMocked = {
|
||||
backgroundImage: id,
|
||||
};
|
||||
|
||||
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
|
||||
evalScope(
|
||||
// Tone,
|
||||
@ -146,6 +170,9 @@ evalScope(
|
||||
// gist,
|
||||
// euclid,
|
||||
mini,
|
||||
getDrawContext,
|
||||
getAudioContext,
|
||||
loadSoundfont,
|
||||
// Tone,
|
||||
},
|
||||
);
|
||||
@ -197,3 +224,7 @@ export const testCycles = {
|
||||
hyperpop: 10,
|
||||
festivalOfFingers3: 16,
|
||||
};
|
||||
|
||||
|
||||
// fixed: https://strudel.tidalcycles.org/?DBp75NUfSxIn (missing .note())
|
||||
// bug: https://strudel.tidalcycles.org/?xHaKTd1kTpCn + https://strudel.tidalcycles.org/?o5LLePbx8kiQ
|
||||
|
||||
6317
repl/src/test/__snapshots__/shared.test.mjs.snap
Normal file
6317
repl/src/test/__snapshots__/shared.test.mjs.snap
Normal file
File diff suppressed because it is too large
Load Diff
23
repl/src/test/shared.test.mjs
Normal file
23
repl/src/test/shared.test.mjs
Normal file
@ -0,0 +1,23 @@
|
||||
import { queryCode } from '../runtime.mjs';
|
||||
import { describe, it } from 'vitest';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
|
||||
const supabase = createClient(
|
||||
'https://pidxdsxphlhzjnzmifth.supabase.co',
|
||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBpZHhkc3hwaGxoempuem1pZnRoIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NTYyMzA1NTYsImV4cCI6MTk3MTgwNjU1Nn0.bqlw7802fsWRnqU5BLYtmXk_k-D1VFmbkHMywWc15NM',
|
||||
);
|
||||
|
||||
describe('renders shared tunes', async () => {
|
||||
const { data } = await supabase.from('code');
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user