From edc5fe106dc2b5c0fcb926f094e3d35d6e58ee54 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 5 Nov 2023 06:53:26 +0300 Subject: [PATCH] fix server test, now server overrides defaultProxy to self --- cypress/integration/index.spec.ts | 5 ++--- server.js | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/cypress/integration/index.spec.ts b/cypress/integration/index.spec.ts index 4e9ac1a0..8b168bf1 100644 --- a/cypress/integration/index.spec.ts +++ b/cypress/integration/index.spec.ts @@ -52,15 +52,14 @@ it('Loads & renders singleplayer', () => { testWorldLoad() }) -it('Joins to server', { - retries: 3 -}, () => { +it.only('Joins to server', () => { // visit('/?version=1.16.1') window.localStorage.version = '' visit() // todo replace with data-test cy.get('[data-test-id="connect-screen-button"]', { includeShadowDom: true }).click() cy.get('input#serverip', { includeShadowDom: true }).clear().focus().type('localhost') + cy.get('input#botversion', { includeShadowDom: true }).clear().focus().type('1.16.1') // todo needs to fix autoversion cy.get('[data-test-id="connect-to-server"]', { includeShadowDom: true }).click() testWorldLoad() }) diff --git a/server.js b/server.js index a542dd6e..0f3b1ca2 100644 --- a/server.js +++ b/server.js @@ -14,14 +14,26 @@ const app = express() const isProd = process.argv.includes('--prod') app.use(compression()) app.use(netApi({ allowOrigin: '*' })) -let lastVersion = '' -app.post('/lastVersion', (req, res) => { - res.send(lastVersion.toString()) -}) if (!isProd) { app.use('/blocksStates', express.static(path.join(__dirname, './prismarine-viewer/public/blocksStates'))) app.use('/textures', express.static(path.join(__dirname, './prismarine-viewer/public/textures'))) } +// patch config +app.get('/config.json', (req, res, next) => { + // read original file config + let config = {} + try { + config = require('./config.json') + } catch { + try { + config = require('./dist/config.json') + } catch { } + } + res.json({ + ...config, + 'defaultProxy': '', // use current url (this server) + }) +}) app.use(express.static(path.join(__dirname, './dist'))) const portArg = process.argv.indexOf('--port')