Skip to content

Commit

Permalink
sync main
Browse files Browse the repository at this point in the history
prev-commit: 716ebcd
  • Loading branch information
zardoy committed Sep 25, 2023
1 parent 09a9550 commit 78e7fdb
Show file tree
Hide file tree
Showing 20 changed files with 628 additions and 335 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Install pnpm
run: npm i -g pnpm
- run: pnpm install
- run: pnpm build
- run: pnpm check-build
- run: nohup pnpm prod-start &
- run: nohup node cypress/minecraft-server.mjs &
- uses: cypress-io/github-action@v5
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,26 @@ jobs:
(
contains(github.event.comment.body, '/deploy')
)
permissions:
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Install Global Dependencies
run: npm install --global vercel pnpm
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
uses: mathiasvr/command-output@v2.0.0
with:
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
id: deploy
- uses: mshick/add-pr-comment@v2
with:
message: |
Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }}
Binary file modified 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.
81 changes: 47 additions & 34 deletions cypress/integration/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,65 +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('renderDistance', '2')
window.localStorage.setItem('options', JSON.stringify({
cleanVisit()
setOptions({
localServerOptions: {
generation: {
name: 'superflat',
options: { seed: 250869072 }
}
}
}))
setLocalStorageSettings()
cy.get('#title-screen').find('[data-test-id="singleplayer-button"]', { includeShadowDom: true, }).click()
// todo implement load event
cy.wait(12000)
cy.get('body').toMatchImageSnapshot({
name: 'superflat-world',
},
},
renderDistance: 2
})
cy.get('#title-screen').find('[data-test-id="singleplayer-button"]', { includeShadowDom: true, }).click()
testWorldLoad()
})

it('Joins to server', () => {
cy.visit('/')
setLocalStorageSettings()
// 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(12000)
cy.get('body').toMatchImageSnapshot({
name: 'superflat-world',
})
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(12000)
cy.get('body').toMatchImageSnapshot({
name: 'superflat-world',
})
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))
})
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"start": "node scripts/build.js copyFilesDev && node scripts/prepareData.mjs && node esbuild.mjs --watch",
"start-watch-script": "nodemon -w esbuild.mjs esbuild.mjs",
"build": "node scripts/build.js copyFiles && node scripts/prepareData.mjs && node esbuild.mjs --minify --prod",
"build": "node scripts/build.js copyFiles && node scripts/prepareData.mjs -f && node esbuild.mjs --minify --prod",
"check-build": "tsc && pnpm build",
"watch": "node scripts/build.js copyFilesDev && webpack serve --config webpack.dev.js --progress",
"test:cypress": "cypress run",
"test:e2e": "start-test http-get://localhost:8080 test:cypress",
Expand All @@ -31,9 +32,10 @@
"browserfs": "github:zardoy/browserfs#build",
"compression": "^1.7.4",
"cypress-plugin-snapshots": "^1.4.4",
"debug": "^4.3.4",
"diamond-square": "^1.2.0",
"eruda": "^3.0.1",
"esbuild": "^0.19.2",
"esbuild": "^0.19.3",
"esbuild-loader": "^4.0.0",
"esbuild-plugin-polyfill-node": "^0.3.0",
"express": "^4.18.2",
Expand Down Expand Up @@ -92,6 +94,7 @@
"style-loader": "^3.3.3",
"three": "0.128.0",
"timers-browserify": "^2.0.12",
"typescript": "^5.2.2",
"url-loader": "^4.1.1",
"use-typed-event-listener": "^4.0.2",
"vite": "^4.4.9",
Expand Down
Loading

0 comments on commit 78e7fdb

Please sign in to comment.