forked from PrismarineJS/prismarine-web-client
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
protocol & errors improvements & cleanup (#22)
- Loading branch information
Showing
25 changed files
with
557 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+211 KB
(1600%)
cypress/integration/__image_snapshots__/superflat-world #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,78 @@ | ||
/// <reference types="cypress" /> | ||
import type { AppOptions } from '../../src/optionsStorage' | ||
|
||
const setLocalStorageSettings = () => { | ||
const cleanVisit = () => { | ||
window.localStorage.clear() | ||
visit() | ||
} | ||
|
||
const visit = (url = '/') => { | ||
window.localStorage.cypress = 'true' | ||
window.localStorage.server = 'localhost' | ||
cy.visit(url) | ||
} | ||
|
||
// todo use ssl | ||
|
||
const compareRenderedFlatWorld = () => { | ||
// wait for render | ||
// cy.wait(6000) | ||
// cy.get('body').toMatchImageSnapshot({ | ||
// name: 'superflat-world', | ||
// }) | ||
} | ||
|
||
const testWorldLoad = () => { | ||
cy.document().then({ timeout: 20_000, }, doc => { | ||
return new Cypress.Promise(resolve => { | ||
doc.addEventListener('cypress-world-ready', resolve) | ||
}) | ||
}).then(() => { | ||
compareRenderedFlatWorld() | ||
}) | ||
} | ||
|
||
const setOptions = (options: Partial<AppOptions>) => { | ||
cy.window().then(win => { | ||
Object.assign(win['options'], options) | ||
}) | ||
} | ||
|
||
it('Loads & renders singleplayer', () => { | ||
cy.visit('/') | ||
window.localStorage.clear() | ||
window.localStorage.setItem('options', JSON.stringify({ | ||
cleanVisit() | ||
setOptions({ | ||
localServerOptions: { | ||
generation: { | ||
name: 'superflat', | ||
options: { seed: 250869072 } | ||
} | ||
}, | ||
}, | ||
renderDistance: 2 | ||
})) | ||
setLocalStorageSettings() | ||
}) | ||
cy.get('#title-screen').find('[data-test-id="singleplayer-button"]', { includeShadowDom: true, }).click() | ||
// todo implement load event | ||
cy.wait(12000) | ||
testWorldLoad() | ||
}) | ||
|
||
// even on local testing indeed it doesn't work sometimes, but sometimes it does | ||
it.skip('Joins to server', () => { | ||
cy.visit('/') | ||
setLocalStorageSettings() | ||
window.localStorage.version = '' | ||
it('Joins to server', () => { | ||
// visit('/?version=1.16.1') | ||
window.localStorage.version = '1.16.1' | ||
visit() | ||
// todo replace with data-test | ||
cy.get('#title-screen').find('[data-test-id="connect-screen-button"]', { includeShadowDom: true, }).click() | ||
cy.get('input#serverip', { includeShadowDom: true, }).clear().focus().type('localhost') | ||
cy.get('[data-test-id="connect-to-server"]', { includeShadowDom: true, }).click() | ||
// todo implement load event | ||
cy.wait(16000) | ||
testWorldLoad() | ||
}) | ||
|
||
it('Loads & renders zip world', () => { | ||
cy.visit('/') | ||
setLocalStorageSettings() | ||
cleanVisit() | ||
cy.get('#title-screen').find('[data-test-id="select-file-folder"]', { includeShadowDom: true, }).click({ shiftKey: true }) | ||
cy.get('input[type="file"]').selectFile('cypress/superflat.zip', { force: true }) | ||
// todo implement load event | ||
cy.wait(10000) | ||
testWorldLoad() | ||
}) | ||
|
||
it.skip('Performance test', () => { | ||
cy.visit('/') | ||
window.localStorage.cypress = 'true' | ||
window.localStorage.setItem('renderDistance', '6') | ||
cy.get('#title-screen').find('.menu > div:nth-child(2) > pmui-button:nth-child(1)', { includeShadowDom: true, }).selectFile('worlds') | ||
// -2 85 24 | ||
// select that world | ||
// from -2 85 24 | ||
// await bot.loadPlugin(pathfinder.pathfinder) | ||
// bot.pathfinder.goto(new pathfinder.goals.GoalXZ(28, -28)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.