Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
fixed route test
Browse files Browse the repository at this point in the history
  • Loading branch information
MoizAdnan committed Aug 1, 2024
1 parent c197302 commit a04b888
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ import { destroyEngine } from '@etherealengine/ecs/src/Engine'
import { Application } from '../../../declarations'
import { createFeathersKoaApp } from '../../createApp'

const newProjectName1 = 'projecttest_test_project_name_1'
const newProjectName1 = '@org/projecttest_test_project_name_1'

const cleanup = async (app: Application) => {
const project1Dir = path.resolve(appRootPath.path, `packages/projects/projects/${newProjectName1}/`)
const project1Dir = path.resolve(appRootPath.path, `packages/projects/projects/${newProjectName1.split('/')[0]}/`)
deleteFolderRecursive(project1Dir)
try {
await app.service(projectPath).remove(null, { query: { name: newProjectName1 } })
Expand Down
2 changes: 1 addition & 1 deletion packages/server-core/src/projects/project/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { createFeathersKoaApp } from '../../createApp'
import { useGit } from '../../util/gitHelperFunctions'

const cleanup = async (app: Application, projectName: string) => {
const projectDir = path.resolve(appRootPath.path, `packages/projects/projects/${projectName}/`)
const projectDir = path.resolve(appRootPath.path, `packages/projects/projects/${projectName.split('/')[0]}/`)
deleteFolderRecursive(projectDir)
const removingProjects = await app.service(projectPath).find({ query: { name: projectName } })
if (removingProjects.data.length) await app.service(projectPath).remove(removingProjects.data[0].id)
Expand Down
11 changes: 6 additions & 5 deletions packages/server-core/src/route/route/route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ import { createFeathersKoaApp } from '../../createApp'

const params = { isInternal: true } as any

const cleanup = async (app: Application, projectName: string) => {
const projectDir = path.resolve(appRootPath.path, `packages/projects/projects/${projectName}/`)
const cleanup = async (app: Application, projectName: string, projectId: string) => {
const projectDir = path.resolve(appRootPath.path, `packages/projects/projects/${projectName.split('/')[0]}/`)
deleteFolderRecursive(projectDir)
try {
await app.service(projectPath).remove(null, { query: { name: projectName } })
await app.service(projectPath).remove(projectId)
} catch (e) {
//
}
Expand Down Expand Up @@ -80,22 +80,23 @@ describe('route.test', () => {
let app: Application
let testProject: string
let testRoute: string
let testProjectId: string

before(async () => {
app = createFeathersKoaApp()
await app.setup()
})

after(async () => {
await cleanup(app, testProject)
await cleanup(app, testProject, testProjectId)
await destroyEngine()
})

it('should find the installed project routes', async () => {
testProject = `@org1/test-project-${uuidv4()}`
testRoute = `test-route-${uuidv4()}`

await app.service(projectPath).create({ name: testProject }, params)
testProjectId = await (await app.service(projectPath).create({ name: testProject }, params)).id
updateXREngineConfigForTest(testProject, testRoute)

const installedRoutes = await app.service('routes-installed').find()
Expand Down
10 changes: 9 additions & 1 deletion packages/server-core/src/route/route/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ declare module '@etherealengine/common/declarations' {

export const getInstalledRoutes = () => {
return async () => {
const rootPath = path.resolve(__dirname, '../../../../projects/projects/')
const projects = fs
.readdirSync(path.resolve(__dirname, '../../../../projects/projects/'), { withFileTypes: true })
.readdirSync(rootPath, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
.map((orgname) => {
return fs
.readdirSync(path.join(rootPath, orgname), { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => `${orgname}/${dirent.name}`)
})
.flat()

const data: InstalledRoutesInterface[] = []
await Promise.all(
Expand Down

0 comments on commit a04b888

Please sign in to comment.