mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-07-11 00:30:06 +08:00
Fixing the contract tests to use the new user type
This commit is contained in:
@@ -1,34 +1,27 @@
|
|||||||
import { OasstApiClient, OasstError } from "src/lib/oasst_api_client";
|
import { OasstApiClient, OasstError } from "src/lib/oasst_api_client";
|
||||||
|
import type { BackendUserCore } from "src/types/Users";
|
||||||
|
|
||||||
describe("Contract test for Oasst API", function () {
|
describe("Contract test for Oasst API", function () {
|
||||||
// Assumes this is running the mock server.
|
// Assumes this is running the mock server.
|
||||||
const oasstApiClient = new OasstApiClient("http://localhost:8080", "test");
|
const oasstApiClient = new OasstApiClient("http://localhost:8080", "test");
|
||||||
|
|
||||||
|
const testUser = {
|
||||||
|
id: "abcd",
|
||||||
|
display_name: "test",
|
||||||
|
auth_method: "local",
|
||||||
|
} as BackendUserCore;
|
||||||
|
|
||||||
it("can fetch a task", async () => {
|
it("can fetch a task", async () => {
|
||||||
expect(
|
expect(await oasstApiClient.fetchTask("random", testUser)).to.be.not.null;
|
||||||
await oasstApiClient.fetchTask("random", {
|
|
||||||
sub: "test",
|
|
||||||
name: "test",
|
|
||||||
email: "test",
|
|
||||||
})
|
|
||||||
).to.be.not.null;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can ack a task", async () => {
|
it("can ack a task", async () => {
|
||||||
const task = await oasstApiClient.fetchTask("random", {
|
const task = await oasstApiClient.fetchTask("random", testUser);
|
||||||
sub: "test",
|
|
||||||
name: "test",
|
|
||||||
email: "test",
|
|
||||||
});
|
|
||||||
expect(await oasstApiClient.ackTask(task.id, "321")).to.be.null;
|
expect(await oasstApiClient.ackTask(task.id, "321")).to.be.null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can record a taskInteraction", async () => {
|
it("can record a taskInteraction", async () => {
|
||||||
const task = await oasstApiClient.fetchTask("random", {
|
const task = await oasstApiClient.fetchTask("random", testUser);
|
||||||
sub: "test",
|
|
||||||
name: "test",
|
|
||||||
email: "test",
|
|
||||||
});
|
|
||||||
expect(
|
expect(
|
||||||
await oasstApiClient.interactTask(
|
await oasstApiClient.interactTask(
|
||||||
"text_reply_to_message",
|
"text_reply_to_message",
|
||||||
@@ -36,11 +29,7 @@ describe("Contract test for Oasst API", function () {
|
|||||||
"321",
|
"321",
|
||||||
"1",
|
"1",
|
||||||
{ text: "Test" },
|
{ text: "Test" },
|
||||||
{
|
testUser
|
||||||
sub: "test",
|
|
||||||
name: "test",
|
|
||||||
email: "test",
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
).to.be.not.null;
|
).to.be.not.null;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user