Test orders

This commit is contained in:
2026-04-27 11:05:09 +02:00
parent 4e02ea021d
commit a84f600fa2
3 changed files with 47 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
import { test, describe } from "vitest"
import { jwtService } from "../config/jwtService.config.js"
describe("Tokens Objenious", () => {
/*
describe("Tokens Objenious", (test) => {
const jwt = jwtService
test("Solicicitud normal de auth", async () => {
@@ -14,4 +14,4 @@ describe("Tokens Objenious", () => {
console.log("acceso refresh objenious", token)
})
})
*/

View File

@@ -3,7 +3,6 @@ import { OrderRepository } from "./OrderRepository.js";
import { CreateOrderDTO, OrderQuery } from "../domain/Order.js";
import { postgresClient } from "../config/config.test.js";
import assert from "node:assert";
import { Query } from "pg";
const order1 = <CreateOrderDTO>{
correlation_id: "fakeRMQid-1234",
@@ -30,11 +29,6 @@ describe("Test OrderRepository", {}, (ctx) => {
const result1 = await orderRepo.createOrder(order1)
assert.ok(result1.data != undefined, result1.error as string)
testIds.push(result1.data.id)
// Order2 -> Para el test de crearOrder
// const result2 = await orderRepo.createOrder(order2)
// assert(result2.data != undefined)
// testIds.push(result2.data.id)
})
it("Insert new Order", async () => {
@@ -75,7 +69,6 @@ describe("Test OrderRepository", {}, (ctx) => {
it("Get pending orders should return all pending orders in ASC order", async () => {
// We already have 'testId' from before block
// Insert two more orders
const orderA = { ...order1, correlation_id: "pending-A" }
const orderB = { ...order1, correlation_id: "pending-B" }
@@ -174,12 +167,17 @@ describe("Test OrderRepository", {}, (ctx) => {
it("Query generates with parameters", async () => {
const params: OrderQuery = {
conditions: {
status: "-eq 'pending'"
status: "-eq 'pending'",
retry_count: "-gte 2",
webhook_host: "-eq NULL"
}
}
//@ts-expect-error
const res = orderRepo.generateTableQuery("test", params)
console.log("Query:", res)
assert.ok(res != undefined)
assert.ok(res != undefined, "Query must be defined")
assert.ok(res.values.length == 3, "Query parameters must be the same as conditions")
})
})

37
test_api.ts Normal file
View File

@@ -0,0 +1,37 @@
import { NosHttpClient } from "./packages/sim-consumidor-nos/infrastructure/NosHttpClient.js";
import { NosRepository } from "./packages/sim-consumidor-nos/infrastructure/NosRepository.js";
import { env } from "./packages/sim-consumidor-nos/config/env/env.js";
async function main() {
console.log("NOS_BASE_URL", env.NOS_BASE_URL);
const client = new NosHttpClient(env.NOS_BASE_URL);
// Try to get a subscriber
const res = await client.get("/subscribers", { params: { limit: 1 } });
console.log("SUBSCRIBER:", res.data.content[0].physicalId);
const iccid = res.data.content[0].physicalId;
try {
const history = await client.get(`/subscribers/${iccid}/history`);
console.log("HISTORY:", history.data);
} catch(e) {
console.error("HISTORY ERROR");
}
try {
const audit = await client.get(`/subscribers/${iccid}/audit`);
console.log("AUDIT:", audit.data);
} catch(e) {
console.error("AUDIT ERROR");
}
try {
const actions = await client.get(`/subscribers/${iccid}/actions`);
console.log("ACTIONS:", actions.data);
} catch(e) {
console.error("ACTIONS ERROR");
}
}
main().catch(console.error);