mirror of
https://github.com/HeyPuter/puter.git
synced 2026-02-19 13:15:21 -06:00
* ci: init e2e test for browser env stash changes * test: update fsentry definition, add tests stash changes * test: pass puter-js mkdir test * test: add test for puter-js move * tidy code * tidy code * doc: add docs for playwright test * recover memoryfs * test: puter-js readdir/stat * test: puter-js write * test: puter-js read * test: puter-js move_cart * test: fix failed tests on move * tests: rename files * test: puter-js copy_cart * tests: puter-js batch/delete, read config from file * ci: add vitest * ci: update names and timeout * ci: simplify playwright-test * ci: simplify api-test * move "api-tester" from tools to tests * test: update example config * test: remove folder tests/api-tester/ci * test: unify config location * test: remove unused files * ci: fix wrong config * ci: fix wrong path * test: add docs * ci: update timeout, print artifact url
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
// testUtils.ts - Puter.js API test utilities (TypeScript)
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import * as yaml from 'yaml';
|
|
import type { Puter } from '../../src/puter-js/index.js';
|
|
|
|
// Create and configure a global puter instance from client-config.yaml
|
|
// Usage: import { puter } from './testUtils'
|
|
// Configuration is read from tests/client-config.yaml
|
|
|
|
// Load configuration from YAML file
|
|
let config: any;
|
|
try {
|
|
const configPath = path.join(__dirname, '../client-config.yaml');
|
|
config = yaml.parse(fs.readFileSync(configPath, 'utf8'));
|
|
} catch (error) {
|
|
console.error('Failed to load client-config.yaml:', error);
|
|
process.exit(1);
|
|
}
|
|
|
|
// @ts-ignore
|
|
const puter: Puter = require('../../src/puter-js/src/index.js').default || globalThis.puter;
|
|
|
|
(globalThis as any).PUTER_ORIGIN = config.frontend_url;
|
|
(globalThis as any).PUTER_API_ORIGIN = config.api_url;
|
|
|
|
(puter as any).setAPIOrigin(config.api_url);
|
|
(puter as any).defaultGUIOrigin = config.frontend_url;
|
|
|
|
if (config.auth_token) {
|
|
(puter as any).setAuthToken(config.auth_token);
|
|
}
|
|
|
|
export { puter };
|