Skip to content

Commit

Permalink
Fix node API response expecting PeerInfo parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwo committed Mar 27, 2024
1 parent 262414b commit 832a82c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
18 changes: 18 additions & 0 deletions webui/src/helpers/baseInterfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// The interfaces in this file match those in base_requests.go

export interface Request {
namespace?: string
}

export interface GetRequest extends Request {}

export interface ListRequest extends GetRequest {
limit?: number
next_token?: string
order_by?: string
reverse?: boolean
}

export interface ListResponse {
NextToken: string
}
6 changes: 4 additions & 2 deletions webui/src/helpers/nodeInterfaces.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// src/interfaces.ts

import { ListRequest } from "./baseInterfaces"

export interface NodesResponse {
NextToken: string
Nodes: Node[]
}

export interface Node {
PeerInfo: PeerInfo
NodeID: string
NodeType: string
Labels: Labels
ComputeNodeInfo: ComputeNodeInfo
Expand Down Expand Up @@ -65,6 +67,6 @@ export interface ParsedNodeData {
// action: string;
}

export interface NodeListRequest {
export interface NodeListRequest extends ListRequest {
labels: string | undefined
}
6 changes: 3 additions & 3 deletions webui/src/pages/NodesDashboard/NodesTable/NodesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ function parseData(nodes: Node[]): ParsedNodeData[] {
const outputs: string[] = node.ComputeNodeInfo?.Publishers ?? []

return {
id: node.PeerInfo.ID,
id: node.NodeID,
type: node.NodeType,
environment: node.Labels.env,
inputs,
outputs,
inputs: inputs,
outputs: outputs,
version: node.BacalhauVersion.GitVersion,
// action: "Action",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function renderWithNumberOfNodes(numberOfNodes: number) {

await waitFor(() => {
screen
.findByDisplayValue(`/${mockNodes[0].PeerInfo.ID}/i`)
.findByDisplayValue(`/${mockNodes[0].NodeID}/i`)
.then((contentRendered) => {
// Test to see if the content is in the document
expect(contentRendered).toBeInTheDocument()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function renderWithNumberOfNodes(numberOfNodes: number) {
expect(nodesTableContainer.length).toBeGreaterThan(0)
})

const firstNodeID = mockNodes[0].PeerInfo.ID
const firstNodeID = mockNodes[0].NodeID
const c1 = screen.getAllByText(firstNodeID)[0]
expect(c1.innerHTML).toContain(firstNodeID)

Expand All @@ -81,7 +81,7 @@ async function renderWithNumberOfNodes(numberOfNodes: number) {
expect(nodesDisplayed.length).toEqual(lastNodeIndex)

// Test to see if the last node is in the document
const lastNodeID = mockNodes[lastNodeIndex - 1].PeerInfo.ID
const lastNodeID = mockNodes[lastNodeIndex - 1].NodeID
const c2 = screen.getAllByText(lastNodeID)[0]
expect(c2.innerHTML).toContain(lastNodeID)

Expand Down
10 changes: 1 addition & 9 deletions webui/tests/mocks/nodeMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,7 @@ export function generateMockNode(): Node {
.toString()

return {
PeerInfo: {
ID: id,
Addrs: [
`${faker.internet.ip()}/udp/${faker.number.int({
min: 2048,
max: 65535,
})}/quic-v1`,
],
},
NodeID: id,
NodeType: "Compute",
Labels: {
Architecture: `arch-${faker.string.alphanumeric(10)}`,
Expand Down

0 comments on commit 832a82c

Please sign in to comment.