-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
133 additions
and
42 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
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 |
---|---|---|
|
@@ -11,11 +11,10 @@ import type { | |
import { pocketbase } from '@slangroom/pocketbase'; | ||
import test from 'ava'; | ||
import { Slangroom } from '@slangroom/core'; | ||
import 'dotenv/config'; | ||
|
||
const email = process.env['EMAIL']!; | ||
const password = process.env['PASSWORD']!; | ||
const pb_address = process.env['PB_ADDRESS']! as ServerUrl; | ||
const email = "[email protected]"; | ||
const password = "testtest"; | ||
const pb_address = "http://127.0.0.1:8090/" as ServerUrl; | ||
|
||
type DataCreate = { | ||
create_parameters: CreateRecordParameters; | ||
|
@@ -123,11 +122,11 @@ test('should retrieve paginated list of records', async (t) => { | |
data, | ||
}); | ||
const output = res.result['output'] as { | ||
records?: { items?: []; page?: number; perPage?: number }; | ||
records?: { items?: []; page?: string; perPage?: string}; | ||
}; | ||
t.truthy(Array.isArray(output.records?.items)); | ||
t.is(output.records?.page, 2); | ||
t.is(output.records?.perPage, 20); | ||
t.is(output.records?.page, '2'); | ||
t.is(output.records?.perPage, '20'); | ||
}); | ||
|
||
test('should retrieve first record that match filters', async (t) => { | ||
|
@@ -172,7 +171,7 @@ test('should retrieve one record', async (t) => { | |
pb_address, | ||
show_parameters: { | ||
collection: 'organizations', | ||
id: 'ouja6pwgxuyn2sd', | ||
id: 'p7viyzsihrn52uj', | ||
fields: 'name', | ||
requestKey: null, | ||
expand:null | ||
|
@@ -199,14 +198,14 @@ test('should create a record', async (t) => { | |
`; | ||
const slangroom = new Slangroom(pocketbase); | ||
|
||
|
||
const data: DataCreate = { | ||
pb_address, | ||
create_parameters: { | ||
collection: 'organizations', | ||
record: { | ||
name, | ||
}, | ||
}, | ||
}, | ||
record_parameters: { | ||
expand: null, | ||
|
@@ -226,7 +225,7 @@ test('should create a record', async (t) => { | |
}); | ||
|
||
test('should update a record', async (t) => { | ||
|
||
|
||
const scriptCreate = ` | ||
Rule unknown ignore | ||
|
@@ -280,7 +279,7 @@ test('should update a record', async (t) => { | |
|
||
const outputCreate = createResult.result['output'] as { id: string, name: string} | ||
const updatedName = `test-${randomString()}` | ||
|
||
const dataUpdate: DataUpdate = { | ||
pb_address, | ||
update_parameters: { | ||
|
Binary file not shown.
85 changes: 85 additions & 0 deletions
85
pkg/pocketbase/test/pb_migrations/1708946882_created_organizations.js
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,85 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((db) => { | ||
const collection = new Collection({ | ||
"id": "ffzsqtnsh1w2ayd", | ||
"created": "2024-02-26 11:28:02.724Z", | ||
"updated": "2024-02-26 11:28:02.724Z", | ||
"name": "organizations", | ||
"type": "base", | ||
"system": false, | ||
"schema": [ | ||
{ | ||
"system": false, | ||
"id": "a9jbay3n", | ||
"name": "name", | ||
"type": "text", | ||
"required": false, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"min": null, | ||
"max": null, | ||
"pattern": "" | ||
} | ||
}, | ||
{ | ||
"system": false, | ||
"id": "z1xvmjl0", | ||
"name": "owners", | ||
"type": "relation", | ||
"required": false, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"collectionId": "_pb_users_auth_", | ||
"cascadeDelete": false, | ||
"minSelect": null, | ||
"maxSelect": 1, | ||
"displayFields": null | ||
} | ||
}, | ||
{ | ||
"system": false, | ||
"id": "cy2pwsn3", | ||
"name": "avatar", | ||
"type": "file", | ||
"required": false, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"mimeTypes": [], | ||
"thumbs": [], | ||
"maxSelect": 1, | ||
"maxSize": 5242880, | ||
"protected": false | ||
} | ||
}, | ||
{ | ||
"system": false, | ||
"id": "u6ro0mgl", | ||
"name": "description", | ||
"type": "editor", | ||
"required": false, | ||
"presentable": false, | ||
"unique": false, | ||
"options": { | ||
"convertUrls": false | ||
} | ||
} | ||
], | ||
"indexes": [], | ||
"listRule": null, | ||
"viewRule": null, | ||
"createRule": null, | ||
"updateRule": null, | ||
"deleteRule": null, | ||
"options": {} | ||
}); | ||
|
||
return Dao(db).saveCollection(collection); | ||
}, (db) => { | ||
const dao = new Dao(db); | ||
const collection = dao.findCollectionByNameOrId("ffzsqtnsh1w2ayd"); | ||
|
||
return dao.deleteCollection(collection); | ||
}) |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.