Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe("CheckRunNow", () => {
value={{
refresh: jest.fn(),
isAdmin: true,
isViewer: false,
hasResourceAccess: jest.fn(),
hasAnyResourceAccess: jest.fn(),
roles: ["admin"]
Expand Down Expand Up @@ -77,6 +78,7 @@ describe("CheckRunNow", () => {
value={{
refresh: jest.fn(),
isAdmin: true,
isViewer: false,
hasResourceAccess: jest.fn(),
hasAnyResourceAccess: jest.fn(),
roles: ["guest"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,55 @@ import PlaybooksRunActionsResults from "../PlaybooksActionsResults";

describe("PlaybooksRunActionsResults", () => {
it("renders 'No result' when result is falsy", () => {
render(<PlaybooksRunActionsResults action={{}} />);
render(
<PlaybooksRunActionsResults
action={{
id: "1",
name: "test",
status: "completed",
playbook_run_id: "1",
start_time: "2024-01-01"
}}
/>
);
expect(screen.getByText("No result")).toBeInTheDocument();
});

it("renders stdout when result has stdout", () => {
const action = { result: { stdout: "Hello, world!" } };
const action = {
id: "1",
name: "test",
status: "completed" as const,
playbook_run_id: "1",
start_time: "2024-01-01",
result: { stdout: "Hello, world!" }
};
render(<PlaybooksRunActionsResults action={action} />);
expect(screen.getByText("Hello, world!")).toBeInTheDocument();
});

it("renders logs when result has logs", () => {
const action = { result: { logs: "Hello, world!" } };
const action = {
id: "1",
name: "test",
status: "completed" as const,
playbook_run_id: "1",
start_time: "2024-01-01",
result: { logs: "Hello, world!" }
};
render(<PlaybooksRunActionsResults action={action} />);
expect(screen.getByText("Hello, world!")).toBeInTheDocument();
});

it("renders JSON when result has neither stdout nor logs", () => {
const action = { result: { foo: "bar" } };
const action = {
id: "1",
name: "test",
status: "completed" as const,
playbook_run_id: "1",
start_time: "2024-01-01",
result: { foo: "bar" }
};
render(<PlaybooksRunActionsResults action={action} />);
expect(
screen.getByText("foo", {
Expand All @@ -31,14 +62,26 @@ describe("PlaybooksRunActionsResults", () => {

it("shows stdout as the first tab", () => {
const action = {
id: "1",
name: "test",
status: "completed" as const,
playbook_run_id: "1",
start_time: "2024-01-01",
result: { stdout: "Hello, world!", stderr: "Goodbye, world!" }
};
render(<PlaybooksRunActionsResults action={action} />);
expect(screen.getByText("Hello, world!")).toBeInTheDocument();
});

it("renders error when action has error", () => {
const action = { error: "Something went wrong" };
const action = {
id: "1",
name: "test",
status: "failed" as const,
playbook_run_id: "1",
start_time: "2024-01-01",
error: "Something went wrong"
};
render(<PlaybooksRunActionsResults action={action} />);
expect(
screen.getByText("Something went wrong", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const playbook: RunnablePlaybook & {
updated_at: "2021-09-01T00:00:00Z",
spec: {
icon: "playbook.svg",
actions: [],
components: [
{
types: ["kubernetes"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const mockPlaybook: PlaybookSpec = {
spec: {
actions: [
{
name: "test-action",
exec: {
script: 'echo "{{.}}"'
}
Expand Down
Loading