refactor: rename ws adapter to server across codebase
'ws' conflated storage mode with transport protocol (WebSocket). Renamed for clarity: the adapter talks the self-hosted server (src/storage/server.js), which happens to use WebSocket for realtime — but the name should describe what it connects to, not how. Renames: - src/storage/ws.js -> server.js - createWsStorage() -> createServerStorage() - storage mode 'ws' -> 'server' - REACT_APP_BACKEND_WS -> REACT_APP_BACKEND_REALTIME_URL - factory param wsUrl -> realtimeUrl - server/tests/ws-*.test.js -> server-*.test.js Kept literal: 'ws' npm package, ws:// protocol URLs, /ws WebSocket endpoint. Transport is accurate there; only storage-naming changed. Updated all docs (DEVELOPMENT, TESTING, REWORK_PLAN, GLOSSARY, TODO), scripts (dev-start.sh, replay-combat.js), factory + ESM tests. 204 tests green.
This commit is contained in:
@@ -27,10 +27,10 @@ describe('getStorageMode', () => {
|
||||
expect(getStorageMode()).toBe('firebase');
|
||||
});
|
||||
|
||||
test('returns ws when REACT_APP_STORAGE=ws', () => {
|
||||
process.env.REACT_APP_STORAGE = 'ws';
|
||||
test('returns server when REACT_APP_STORAGE=server', () => {
|
||||
process.env.REACT_APP_STORAGE = 'server';
|
||||
const { getStorageMode } = require('../storage/index');
|
||||
expect(getStorageMode()).toBe('ws');
|
||||
expect(getStorageMode()).toBe('server');
|
||||
});
|
||||
|
||||
test('throws on unknown mode', () => {
|
||||
@@ -41,8 +41,8 @@ describe('getStorageMode', () => {
|
||||
});
|
||||
|
||||
describe('getStorage factory routing', () => {
|
||||
test('ws mode returns ws adapter (init may fail without backend — catch)', () => {
|
||||
process.env.REACT_APP_STORAGE = 'ws';
|
||||
test('server mode returns server adapter (init may fail without backend — catch)', () => {
|
||||
process.env.REACT_APP_STORAGE = 'server';
|
||||
const { getStorage } = require('../storage/index');
|
||||
try {
|
||||
const s = getStorage();
|
||||
@@ -56,7 +56,7 @@ describe('getStorage factory routing', () => {
|
||||
});
|
||||
|
||||
test('returns singleton on repeat call (same instance)', () => {
|
||||
process.env.REACT_APP_STORAGE = 'ws';
|
||||
process.env.REACT_APP_STORAGE = 'server';
|
||||
const { getStorage } = require('../storage/index');
|
||||
let a;
|
||||
try { a = getStorage(); } catch (e) { return; } // no backend ok
|
||||
|
||||
Reference in New Issue
Block a user