Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

Commit 8cb17c6

Browse files
committed
test: fix tests app termination
1 parent 5fe46aa commit 8cb17c6

File tree

14 files changed

+393
-207
lines changed

14 files changed

+393
-207
lines changed

bin/test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@ import 'reflect-metadata'
22
import { assert } from '@japa/assert'
33
import { expectTypeOf } from '@japa/expect-type'
44
import { processCLIArgs, configure, run } from '@japa/runner'
5-
import { createApp } from '../tests/functional/app.js'
5+
import { createApp } from '../tests/integration/app.js'
66
import { fileSystem } from '@japa/file-system'
77
import app from '@adonisjs/core/services/app'
8+
import { ApplicationService } from '@adonisjs/core/types'
89

10+
let testApp: ApplicationService
911
processCLIArgs(process.argv.slice(2))
1012
configure({
1113
suites: [
1214
{
1315
name: 'units',
1416
files: ['tests/units/**/*.spec.(js|ts)'],
1517
},
18+
{
19+
name: 'integration',
20+
files: ['tests/integration/**/*.spec.(js|ts)'],
21+
},
1622
{
1723
name: 'functional',
1824
files: ['tests/functional/**/*.spec.(js|ts)'],
@@ -21,12 +27,13 @@ configure({
2127
plugins: [assert(), expectTypeOf(), fileSystem()],
2228
setup: [
2329
async () => {
24-
await createApp()
30+
testApp = await createApp()
2531
},
2632
],
2733
teardown: [
2834
async () => {
2935
await app.terminate()
36+
await testApp.terminate()
3037
},
3138
],
3239
})

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@
6969
"@types/node": "^20.14.5",
7070
"@types/sinon": "^17.0.3",
7171
"algoliasearch": "^5.6.1",
72+
"better-sqlite3": "^11.3.0",
7273
"c8": "^10.1.2",
7374
"copyfiles": "^2.4.1",
7475
"del-cli": "^5.1.0",
7576
"eslint": "^9.9.0",
77+
"luxon": "^3.5.0",
7678
"meilisearch": "^0.42.0",
7779
"np": "^10.0.6",
7880
"prettier": "^3.3.2",
@@ -81,8 +83,7 @@
8183
"testcontainers": "^10.13.1",
8284
"ts-node": "^10.9.2",
8385
"typescript": "^5.4.5",
84-
"typesense": "^1.8.2",
85-
"luxon": "^3.5.0"
86+
"typesense": "^1.8.2"
8687
},
8788
"peerDependencies": {
8889
"@adonisjs/core": "^6.2.0",

src/engines/typesense.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ export class TypesenseEngine implements MagnifyEngine {
5050
const Static = models[0].constructor as SearchableModel
5151
const collection = await this.#getOrCreateCollectionFromModel(Static)
5252

53-
console.log('removed models', models)
54-
5553
await Promise.all(
5654
models.map((model) => collection.documents(model.$searchKeyValue.toString()).delete())
5755
)

tests/functional/configuration.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Configure from '@adonisjs/core/commands/configure'
22
import { IgnitorFactory } from '@adonisjs/core/factories'
3-
import { ApplicationService } from '@adonisjs/core/types'
43
import { FileSystem } from '@japa/file-system'
54
import { test } from '@japa/runner'
65
import { fileURLToPath } from 'node:url'
@@ -21,7 +20,7 @@ async function configure(fs: FileSystem, choice: number) {
2120
},
2221
})
2322

24-
const app = ignitor.createApp('web')
23+
const app = ignitor.createApp('console')
2524
await app.init()
2625
await app.boot()
2726

@@ -53,6 +52,8 @@ test.group('Configuration', (group) => {
5352
context.fs.basePath = fileURLToPath(BASE_URL)
5453
})
5554

55+
group.each.disableTimeout()
56+
5657
test('configure algolia engine', async ({ fs, assert }) => {
5758
await configure(fs, 0)
5859

tests/functional/meilisearch.spec.ts

Lines changed: 0 additions & 56 deletions
This file was deleted.

tests/functional/typesense.spec.ts

Lines changed: 0 additions & 138 deletions
This file was deleted.
File renamed without changes.

tests/functional/app.ts renamed to tests/integration/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export async function createApp() {
6666
new URL('../fixtures/migrations/create_users_table.ts', import.meta.url),
6767
testApp.migrationsPath('create_users_table.ts')
6868
)
69+
70+
return testApp
6971
}
7072

7173
export async function initializeDatabase(app: ApplicationService) {
@@ -104,8 +106,6 @@ async function seedDatabase() {
104106
yield { name: 'Amos Larson Sr.' }
105107
}
106108

107-
// for (let i = 0; i < 44; i++) {
108109
const toCreate = [...collection()]
109110
await User.createMany(toCreate)
110-
// }
111111
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)