import * as t from "dev/responses/clusterStatus/tools";
import * as responses from "dev/responses";

import * as workflow from "test/workflow";
import { intercept, location, route, shortcuts } from "test/tools";

const { resources } = workflow.cluster;
export const agentData = responses.resourceAgentMetadata.ocfHeartbeatDummy;

export const resourceA = t.primitive("A", {
  utilization: [
    { id: "A_test_one", name: "test_one", value: "10" },
    { id: "A_test_two", name: "test_two", value: "20" },
  ],
  agentname: agentData.name,
});

export const clusterStatus = t.cluster("test-cluster", "ok", {
  resource_list: [resourceA],
});

export const interceptWithUtilization = (
  additionalRouteList: intercept.Route[] = [],
) => {
  return shortcuts.interceptWithCluster({
    clusterStatus,
    additionalRouteList: [
      route.resourceAgentDescribeAgent({
        clusterName: clusterStatus.cluster_name,
        agentName: resourceA.agentname,
        agentData,
      }),
      ...additionalRouteList,
    ],
  });
};

export const openUtilizationTab = async () => {
  await page.goto(
    location.resource({
      clusterName: clusterStatus.cluster_name,
      resourceId: resourceA.id,
    }),
  );
  await resources.selectTab("utilization");
};
