Skip to content

Commit 78e7fdb

Browse files
committed
sync main
prev-commit: 716ebcd
1 parent 09a9550 commit 78e7fdb

20 files changed

+628
-335
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Install pnpm
1212
run: npm i -g pnpm
1313
- run: pnpm install
14-
- run: pnpm build
14+
- run: pnpm check-build
1515
- run: nohup pnpm prod-start &
1616
- run: nohup node cypress/minecraft-server.mjs &
1717
- uses: cypress-io/github-action@v5

.github/workflows/preview.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,26 @@ jobs:
1414
(
1515
contains(github.event.comment.body, '/deploy')
1616
)
17+
permissions:
18+
pull-requests: write
1719
steps:
1820
- name: Checkout
1921
uses: actions/checkout@v2
2022
with:
2123
fetch-depth: 0
24+
ref: refs/pull/${{ github.event.issue.number }}/head
2225
- name: Install Global Dependencies
2326
run: npm install --global vercel pnpm
2427
- name: Pull Vercel Environment Information
2528
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
2629
- name: Build Project Artifacts
2730
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
2831
- name: Deploy Project Artifacts to Vercel
29-
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
32+
uses: mathiasvr/[email protected]
33+
with:
34+
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
35+
id: deploy
36+
- uses: mshick/add-pr-comment@v2
37+
with:
38+
message: |
39+
Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }}
Loading

cypress/integration/index.spec.ts

+47-34
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,78 @@
11
/// <reference types="cypress" />
2+
import type { AppOptions } from '../../src/optionsStorage'
23

3-
const setLocalStorageSettings = () => {
4+
const cleanVisit = () => {
5+
window.localStorage.clear()
6+
visit()
7+
}
8+
9+
const visit = (url = '/') => {
410
window.localStorage.cypress = 'true'
5-
window.localStorage.server = 'localhost'
11+
cy.visit(url)
612
}
713

814
// todo use ssl
915

16+
const compareRenderedFlatWorld = () => {
17+
// wait for render
18+
// cy.wait(6000)
19+
// cy.get('body').toMatchImageSnapshot({
20+
// name: 'superflat-world',
21+
// })
22+
}
23+
24+
const testWorldLoad = () => {
25+
cy.document().then({ timeout: 20_000, }, doc => {
26+
return new Cypress.Promise(resolve => {
27+
doc.addEventListener('cypress-world-ready', resolve)
28+
})
29+
}).then(() => {
30+
compareRenderedFlatWorld()
31+
})
32+
}
33+
34+
const setOptions = (options: Partial<AppOptions>) => {
35+
cy.window().then(win => {
36+
Object.assign(win['options'], options)
37+
})
38+
}
39+
1040
it('Loads & renders singleplayer', () => {
11-
cy.visit('/')
12-
window.localStorage.clear()
13-
window.localStorage.setItem('renderDistance', '2')
14-
window.localStorage.setItem('options', JSON.stringify({
41+
cleanVisit()
42+
setOptions({
1543
localServerOptions: {
1644
generation: {
1745
name: 'superflat',
1846
options: { seed: 250869072 }
19-
}
20-
}
21-
}))
22-
setLocalStorageSettings()
23-
cy.get('#title-screen').find('[data-test-id="singleplayer-button"]', { includeShadowDom: true, }).click()
24-
// todo implement load event
25-
cy.wait(12000)
26-
cy.get('body').toMatchImageSnapshot({
27-
name: 'superflat-world',
47+
},
48+
},
49+
renderDistance: 2
2850
})
51+
cy.get('#title-screen').find('[data-test-id="singleplayer-button"]', { includeShadowDom: true, }).click()
52+
testWorldLoad()
2953
})
3054

3155
it('Joins to server', () => {
32-
cy.visit('/')
33-
setLocalStorageSettings()
56+
// visit('/?version=1.16.1')
57+
window.localStorage.version = '1.16.1'
58+
visit()
3459
// todo replace with data-test
3560
cy.get('#title-screen').find('[data-test-id="connect-screen-button"]', { includeShadowDom: true, }).click()
3661
cy.get('input#serverip', { includeShadowDom: true, }).clear().focus().type('localhost')
3762
cy.get('[data-test-id="connect-to-server"]', { includeShadowDom: true, }).click()
38-
// todo implement load event
39-
cy.wait(12000)
40-
cy.get('body').toMatchImageSnapshot({
41-
name: 'superflat-world',
42-
})
63+
testWorldLoad()
4364
})
4465

4566
it('Loads & renders zip world', () => {
46-
cy.visit('/')
47-
setLocalStorageSettings()
67+
cleanVisit()
4868
cy.get('#title-screen').find('[data-test-id="select-file-folder"]', { includeShadowDom: true, }).click({ shiftKey: true })
4969
cy.get('input[type="file"]').selectFile('cypress/superflat.zip', { force: true })
50-
// todo implement load event
51-
cy.wait(12000)
52-
cy.get('body').toMatchImageSnapshot({
53-
name: 'superflat-world',
54-
})
70+
testWorldLoad()
5571
})
5672

5773
it.skip('Performance test', () => {
58-
cy.visit('/')
59-
window.localStorage.cypress = 'true'
60-
window.localStorage.setItem('renderDistance', '6')
61-
cy.get('#title-screen').find('.menu > div:nth-child(2) > pmui-button:nth-child(1)', { includeShadowDom: true, }).selectFile('worlds')
62-
// -2 85 24
74+
// select that world
75+
// from -2 85 24
6376
// await bot.loadPlugin(pathfinder.pathfinder)
6477
// bot.pathfinder.goto(new pathfinder.goals.GoalXZ(28, -28))
6578
})

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"scripts": {
66
"start": "node scripts/build.js copyFilesDev && node scripts/prepareData.mjs && node esbuild.mjs --watch",
77
"start-watch-script": "nodemon -w esbuild.mjs esbuild.mjs",
8-
"build": "node scripts/build.js copyFiles && node scripts/prepareData.mjs && node esbuild.mjs --minify --prod",
8+
"build": "node scripts/build.js copyFiles && node scripts/prepareData.mjs -f && node esbuild.mjs --minify --prod",
9+
"check-build": "tsc && pnpm build",
910
"watch": "node scripts/build.js copyFilesDev && webpack serve --config webpack.dev.js --progress",
1011
"test:cypress": "cypress run",
1112
"test:e2e": "start-test http-get://localhost:8080 test:cypress",
@@ -31,9 +32,10 @@
3132
"browserfs": "github:zardoy/browserfs#build",
3233
"compression": "^1.7.4",
3334
"cypress-plugin-snapshots": "^1.4.4",
35+
"debug": "^4.3.4",
3436
"diamond-square": "^1.2.0",
3537
"eruda": "^3.0.1",
36-
"esbuild": "^0.19.2",
38+
"esbuild": "^0.19.3",
3739
"esbuild-loader": "^4.0.0",
3840
"esbuild-plugin-polyfill-node": "^0.3.0",
3941
"express": "^4.18.2",
@@ -92,6 +94,7 @@
9294
"style-loader": "^3.3.3",
9395
"three": "0.128.0",
9496
"timers-browserify": "^2.0.12",
97+
"typescript": "^5.2.2",
9598
"url-loader": "^4.1.1",
9699
"use-typed-event-listener": "^4.0.2",
97100
"vite": "^4.4.9",

0 commit comments

Comments
 (0)