wip testing cypress
This commit is contained in:
parent
7793247287
commit
df2e1a76cf
8 changed files with 24 additions and 16 deletions
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
|
|
@ -12,5 +12,12 @@ jobs:
|
|||
run: npm i -g pnpm
|
||||
- run: pnpm install
|
||||
- run: pnpm build
|
||||
# todo use nohup and official action?
|
||||
# - run: pnpm prod-start & pnpm test:cypress
|
||||
- uses: cypress-io/github-action@v5
|
||||
with:
|
||||
start: pnpm prod-start
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: failure()
|
||||
with:
|
||||
name: cypress-images
|
||||
path: cypress/integration/__image_snapshots__/
|
||||
if-no-files-found: ignore
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 229 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 215 KiB |
|
|
@ -1,11 +1,10 @@
|
|||
/// <reference types="cypress" />
|
||||
|
||||
it('Renders menu (options button)', () => {
|
||||
it('Loads & renders singleplayer', () => {
|
||||
// todo use <button match text selectors
|
||||
cy.visit('/')
|
||||
window.localStorage.cypress = 'true'
|
||||
cy.window().then((win) => {
|
||||
win['cypress'] = true
|
||||
win['hideStats']()
|
||||
})
|
||||
window.localStorage.server = 'localhost'
|
||||
window.localStorage.setItem('renderDistance', '2')
|
||||
|
|
@ -15,7 +14,8 @@ it('Renders menu (options button)', () => {
|
|||
options: { seed: 250869072 }
|
||||
}
|
||||
}))
|
||||
cy.get('#title-screen').find('.menu > pmui-button:nth-child(2)', { includeShadowDom: true, }).click()
|
||||
// todo replace with data-test
|
||||
cy.get('#title-screen').find('.menu > div:nth-child(2) > pmui-button:nth-child(1)', { includeShadowDom: true, }).click()
|
||||
// todo implement load event
|
||||
cy.wait(6000)
|
||||
//@ts-ignore
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@
|
|||
"test:cypress": "cypress run",
|
||||
"test:e2e": "start-test http-get://localhost:8080 test:cypress",
|
||||
"prod-start": "node server.js",
|
||||
"prepublishOnly": "npm run build",
|
||||
"test": "npm run lint && mocha"
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"keywords": [
|
||||
"prismarine",
|
||||
|
|
@ -71,7 +70,6 @@
|
|||
"memfs": "^3.5.3",
|
||||
"mineflayer": "^4.11.0",
|
||||
"mineflayer-pathfinder": "^2.4.4",
|
||||
"mocha": "^10.2.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"os-browserify": "^0.3.0",
|
||||
"path-browserify": "^1.0.1",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const { isMobile } = require('./menus/components/common')
|
|||
const { activeModalStack, hideCurrentModal, showModal } = require('./globalState')
|
||||
import { repeat } from 'lit/directives/repeat.js'
|
||||
import { classMap } from 'lit/directives/class-map.js'
|
||||
import { isCypress } from './utils'
|
||||
|
||||
const styles = {
|
||||
black: 'color:#000000',
|
||||
|
|
@ -400,13 +401,12 @@ class ChatBox extends LitElement {
|
|||
}
|
||||
|
||||
render () {
|
||||
// todo just to hide player joined at random timings
|
||||
if (window.cypress) return html``
|
||||
|
||||
return html`
|
||||
<div id="chat-wrapper" class="chat-wrapper chat-messages-wrapper">
|
||||
<div class="chat ${this.inChat ? 'opened' : ''}" id="chat-messages">
|
||||
${repeat(this.messages, (m) => m.id, (m) => this.renderMessage(m))}
|
||||
<!-- its to hide player joined at random timings, todo add chat tests as well -->
|
||||
${repeat(isCypress() ? [] : this.messages, (m) => m.id, (m) => this.renderMessage(m))}
|
||||
</div>
|
||||
</div>
|
||||
<div id="chat-wrapper2" class="chat-wrapper chat-input-wrapper">
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ const Cursor = require('./cursor')
|
|||
global.THREE = require('three')
|
||||
const { initVR } = require('./vr')
|
||||
const { activeModalStack, showModal, hideModal, hideCurrentModal, activeModalStacks, replaceActiveModalStack, isGameActive, miscUiState, gameAdditionalState } = require('./globalState')
|
||||
const { pointerLock, goFullscreen, toNumber } = require('./utils')
|
||||
const { pointerLock, goFullscreen, toNumber, isCypress } = require('./utils')
|
||||
const { notification } = require('./menus/notification')
|
||||
const { removePanorama, addPanoramaCubeMap, initPanoramaOptions } = require('./panorama')
|
||||
const { startLocalServer } = require('./createLocalServer')
|
||||
|
|
@ -65,7 +65,7 @@ const { default: updateTime } = require('./updateTime')
|
|||
const { options } = require('./optionsStorage')
|
||||
const { subscribeKey } = require('valtio/utils')
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
if ('serviceWorker' in navigator && !isCypress()) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('./service-worker.js').then(registration => {
|
||||
console.log('SW registered: ', registration)
|
||||
|
|
@ -87,11 +87,10 @@ document.body.appendChild(stats.dom)
|
|||
stats2.dom.style.left = '80px'
|
||||
document.body.appendChild(stats2.dom)
|
||||
|
||||
window.hideStats = () => {
|
||||
if (localStorage.hideStats || isCypress()) {
|
||||
stats.dom.style.display = 'none'
|
||||
stats2.dom.style.display = 'none'
|
||||
}
|
||||
if (localStorage.hideStats) window.hideStats()
|
||||
|
||||
// const debugPitch = document.createElement('span')
|
||||
// debugPitch.style.cssText = `
|
||||
|
|
|
|||
|
|
@ -112,3 +112,7 @@ export const getGamemodeNumber = (bot) => {
|
|||
default: return -1
|
||||
}
|
||||
}
|
||||
|
||||
export const isCypress = () => {
|
||||
return localStorage.cypress === 'true'
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue