This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from EtherealEngine/9141-added-new-bot-tests
Added automated test
- Loading branch information
Showing
7 changed files
with
252 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}) | ||
}) | ||
|
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 |
---|---|---|
@@ -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 | ||
}) | ||
}) | ||
|
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 |
---|---|---|
@@ -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 | ||
}) | ||
}) | ||
|
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 |
---|---|---|
@@ -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 | ||
}) | ||
}) | ||
|
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 |
---|---|---|
@@ -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 () => { | ||
}) | ||
}) | ||
|
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 |
---|---|---|
@@ -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 | ||
}) | ||
}) | ||
|
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 |
---|---|---|
@@ -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<typeof getEngineState>['value']).sceneLoaded, true) | ||
// }) | ||
}) |