diff --git a/e2e/dev/all-editor-action.test.ts b/e2e/dev/all-editor-action.test.ts new file mode 100644 index 0000000..a5eaa06 --- /dev/null +++ b/e2e/dev/all-editor-action.test.ts @@ -0,0 +1,31 @@ +import assert from 'assert' +import { Vector3 } from 'three' +import { EtherealEngineBot } from 'ee-bot/src/bot/bot-class' +import { BotHooks } from 'ee-bot/src/enums/BotHooks' + +const vector3 = new Vector3() + +//const domain = process.env.APP_HOST +const domain = 'localhost:3000' +const locationName = 'apartment' +const sqrt2 = Math.sqrt(2) + +describe('My Bot Tests', () => { + const bot = new EtherealEngineBot({ name: 'bot', headless:false, verbose: true }) + before(async () => { + await bot.launchBrowser() + await bot.enterLocation(`https://${domain}/location/${locationName}`) + await bot.awaitHookPromise(BotHooks.LocationLoaded) + await bot.clickAllButtons() + }) + + after(async () => { + await bot.quit() + }) + + it('Can spawn in the world', async () => { + const pos = await bot.awaitHookPromise(BotHooks.GetPlayerPosition) + // assert(vector3.copy(pos).length() < sqrt2 * 2) // sqrt2 * 2 is the default size of our spawn area + }) +}) + diff --git a/e2e/dev/alldirection.test.ts b/e2e/dev/alldirection.test.ts new file mode 100644 index 0000000..2cf06dd --- /dev/null +++ b/e2e/dev/alldirection.test.ts @@ -0,0 +1,39 @@ +import assert from 'assert' +import { Vector3 } from 'three' +import { EtherealEngineBot } from 'ee-bot/src/bot/bot-class' +import { BotHooks } from 'ee-bot/src/enums/BotHooks' + +//const vector3 = new Vector3() + +//const domain = process.env.APP_HOST +const domain = 'localhost:3000' +const locationName = 'apartment' +const sqrt2 = Math.sqrt(2) + +describe('My Bot Tests', () => { + const bot = new EtherealEngineBot({ name: 'bot', headless:false, verbose: true }) + before(async () => { + await bot.launchBrowser() + await bot.enterLocation(`https://${domain}/location/${locationName}`) + await bot.awaitHookPromise(BotHooks.LocationLoaded) + await bot.moveBot('forward', 2000) + await bot.moveBot('backward',2000) + await bot.moveBot('left',2000) + await bot.moveBot('right',2000) + await bot.moveBot('jump',2000) + await bot.moveBot('up',2000) + await bot.moveBot('down',2000) + await bot.moveBot('arrowleft',1000) + await bot.moveBot('arrowright',1000) + }) + + after(async () => { + await bot.quit() + }) + + it('Can spawn in the world', async () => { + const pos = await bot.awaitHookPromise(BotHooks.GetPlayerPosition) + //assert(vector3.copy(pos).length() < sqrt2 * 2) // sqrt2 * 2 is the default size of our spawn area + }) +}) + diff --git a/e2e/dev/emote.test.ts b/e2e/dev/emote.test.ts new file mode 100644 index 0000000..08b3158 --- /dev/null +++ b/e2e/dev/emote.test.ts @@ -0,0 +1,31 @@ +import assert from 'assert' +import { Vector3 } from 'three' +import { EtherealEngineBot } from 'ee-bot/src/bot/bot-class' +import { BotHooks } from 'ee-bot/src/enums/BotHooks' + +//const vector3 = new Vector3() + +//const domain = process.env.APP_HOST +const domain = 'localhost:3000' +const locationName = 'apartment' +const sqrt2 = Math.sqrt(2) + +describe('My Bot Tests', () => { + const bot = new EtherealEngineBot({ name: 'bot', headless:false, verbose: true }) + before(async () => { + await bot.launchBrowser() + await bot.enterLocation(`https://${domain}/location/${locationName}`) + await bot.awaitHookPromise(BotHooks.LocationLoaded) + await bot.clickEmoteButtonAndSelectEmote() + }) + + after(async () => { + await bot.quit() + }) + + it('Can spawn in the world', async () => { + const pos = await bot.awaitHookPromise(BotHooks.GetPlayerPosition) + //assert(vector3.copy(pos).length() < sqrt2 * 2) // sqrt2 * 2 is the default size of our spawn area + }) +}) + diff --git a/e2e/dev/moveforward.test.ts b/e2e/dev/moveforward.test.ts new file mode 100644 index 0000000..355aee2 --- /dev/null +++ b/e2e/dev/moveforward.test.ts @@ -0,0 +1,31 @@ +import assert from 'assert' +import { Vector3 } from 'three' +import { EtherealEngineBot } from 'ee-bot/src/bot/bot-class' +import { BotHooks } from 'ee-bot/src/enums/BotHooks' + +//const vector3 = new Vector3() + +//const domain = process.env.APP_HOST +const domain = 'localhost:3000' +const locationName = 'apartment' +const sqrt2 = Math.sqrt(2) + +describe('My Bot Tests', () => { + const bot = new EtherealEngineBot({ name: 'bot', headless:false, verbose: true }) + before(async () => { + await bot.launchBrowser() + await bot.enterLocation(`https://${domain}/location/${locationName}`) + await bot.awaitHookPromise(BotHooks.LocationLoaded) + await bot.moveBot('forward',2000) + }) + + after(async () => { + await bot.quit() + }) + + it('Can spawn in the world', async () => { + const pos = await bot.awaitHookPromise(BotHooks.GetPlayerPosition) + //assert(vector3.copy(pos).length() < sqrt2 * 2) // sqrt2 * 2 is the default size of our spawn area + }) +}) + diff --git a/e2e/dev/physics-triggers.test.ts b/e2e/dev/physics-triggers.test.ts new file mode 100644 index 0000000..2a97c0f --- /dev/null +++ b/e2e/dev/physics-triggers.test.ts @@ -0,0 +1,34 @@ +import assert from 'assert' +import { Vector3 } from 'three' +import { EtherealEngineBot } from 'ee-bot/src/bot/bot-class' +import { BotHooks } from 'ee-bot/src/enums/BotHooks' +import { makeAdmin } from 'ee-bot/src/bot/utils/make-user-admin' + +const vector3 = new Vector3() + +//const domain = process.env.APP_HOST +const domain = 'localhost:3000' +const locationName = 'default' +const sqrt2 = Math.sqrt(2) + +describe('My Bot Tests', () => { + const bot = new EtherealEngineBot({ name: 'bot', headless:false, verbose: true }) + before(async () => { + await bot.launchBrowser() + //await bot.enterLocation(`https://${domain}`) + //await bot.awaitHookPromise(BotHooks.LocationLoaded) + await bot.enterEditor(`https://${domain}/studio/default-project/apartment`,`https://${domain}` ) + await bot.physics_triggers() + await bot.enterLocation(`https://${domain}/location/${locationName}`) + await bot.awaitHookPromise(BotHooks.LocationLoaded) + await bot.moveBot('forward',2000) + }) + + after(async () => { + await bot.quit() + }) + + it('Can spawn in the world', async () => { + }) +}) + diff --git a/e2e/dev/portal.test.ts b/e2e/dev/portal.test.ts new file mode 100644 index 0000000..b0fbd1f --- /dev/null +++ b/e2e/dev/portal.test.ts @@ -0,0 +1,33 @@ +import assert from 'assert' +import { Vector3 } from 'three' +import { EtherealEngineBot } from 'ee-bot/src/bot/bot-class' +import { BotHooks } from 'ee-bot/src/enums/BotHooks' + +const vector3 = new Vector3() + +//const domain = process.env.APP_HOST +const domain = 'localhost:3000' +const locationName = 'apartment' +const sqrt2 = Math.sqrt(2) + +describe('My Bot Tests', () => { + const bot = new EtherealEngineBot({ name: 'bot', headless:false, verbose: true }) + before(async () => { + await bot.launchBrowser() + await bot.enterLocation(`https://${domain}/location/${locationName}`) + await bot.awaitHookPromise(BotHooks.LocationLoaded) + await bot.moveBot('forward',3000) + await bot.moveBot('left',2000) + await bot.moveBot('backward',4000) + }) + + after(async () => { + await bot.quit() + }) + + it('Can spawn in the world', async () => { + const pos = await bot.awaitHookPromise(BotHooks.GetPlayerPosition) + // assert(vector3.copy(pos).length() < sqrt2 * 2) // sqrt2 * 2 is the default size of our spawn area + }) +}) + diff --git a/e2e/editor/xrui.test.ts b/e2e/editor/xrui.test.ts new file mode 100644 index 0000000..9563135 --- /dev/null +++ b/e2e/editor/xrui.test.ts @@ -0,0 +1,53 @@ +import assert from 'assert' +import { EtherealEngineBot } from 'ee-bot/src/bot/bot-class' +import { BotHooks } from 'ee-bot/src/enums/BotHooks' + +import { delay } from '@etherealengine/engine/src/common/functions/delay' +import type { Engine } from '@etherealengine/engine/src/ecs/classes/Engine' +import { EngineState } from '@etherealengine/engine/src/ecs/classes/EngineState' + +const domain = process.env.APP_HOST || 'localhost:3000' +const editorUrl = `https://${domain}/studio` + +describe('Editor Scene Tests', () => { + const bot = new EtherealEngineBot({ name: 'bot', verbose: true, headless: false }) + before(async () => { + await bot.launchBrowser() + await bot.enterEditor(`https://${domain}/studio/`,`https://${domain}`) + }) + + after(async () => { + await bot.quit() + }) + + it('should load scene', async () => { + // open root editor page + await bot.navigate(editorUrl) + + // click on project + await bot.clickElementById('open-ee-development-test-suite') + + // click on scene + await bot.page.waitForSelector(`[class^='_sceneContainer_1b1hs_126']`, { visible: true }) + await bot.page.click(`[class^='_sceneContainer_1b1hs_126']`) + + await delay(6000) + + // assert scene has loaded + await bot.awaitHookPromise(BotHooks.SceneLoaded) + + const serializedEngine = JSON.parse(await bot.runHook(BotHooks.SerializeEngine)) // as Engine + const engineState = serializedEngine.store.stateMap['engine'] as any as typeof EngineState._TYPE + assert.equal(serializedEngine.isEditor, true) + assert.equal(engineState.sceneLoaded, true) + }) + + // it.skip('should unload scene and load second scene', async () => { + // await bot.page.click('#rc-tabs-0-tab-scenePanel') + // await bot.page.click(`[class^='_sceneContainer']:nth-child(2)`) + // await bot.awaitHookPromise(BotHooks.SceneLoaded) + // const serializedEngine = JSON.parse(await bot.runHook(BotHooks.SerializeEngine)) as Engine + // assert.equal(serializedEngine.isEditor, true) + // assert.equal((serializedEngine.store.state['engine'] as any as ReturnType['value']).sceneLoaded, true) + // }) +})