fix server test, now server overrides defaultProxy to self

This commit is contained in:
Vitaly Turovsky 2023-11-05 06:53:26 +03:00
commit edc5fe106d
2 changed files with 18 additions and 7 deletions

View file

@ -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()
})

View file

@ -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')