Skip to content

Commit 6ed6141

Browse files
committed
fix win tests
1 parent 29973ef commit 6ed6141

2 files changed

Lines changed: 35 additions & 5 deletions

File tree

packages/cli/test/commands/agent.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { resolve } from "node:path";
1+
import { join, resolve } from "node:path";
22

33
import { readConfig } from "@allurereport/core";
44
import {
@@ -359,7 +359,7 @@ describe("agent command", () => {
359359
}),
360360
);
361361
expect(logMock).toHaveBeenNthCalledWith(1, "agent output: /tmp/allure-agent-123");
362-
expect(logMock).toHaveBeenNthCalledWith(2, "agent index: /tmp/allure-agent-123/index.md");
362+
expect(logMock).toHaveBeenNthCalledWith(2, `agent index: ${join("/tmp/allure-agent-123", "index.md")}`);
363363
expect(logMock).toHaveBeenNthCalledWith(3, "npm test");
364364
expect(logMock.mock.invocationCallOrder[0]).toBeLessThan((executeAllureRun as Mock).mock.invocationCallOrder[0]);
365365
expect(writeLatestAgentState).toHaveBeenNthCalledWith(
@@ -437,7 +437,7 @@ describe("agent command", () => {
437437
},
438438
});
439439
expect(consoleModule.log).toHaveBeenCalledWith(`agent output: ${resolvedOutput}`);
440-
expect(consoleModule.log).toHaveBeenCalledWith(`agent index: ${resolvedOutput}/index.md`);
440+
expect(consoleModule.log).toHaveBeenCalledWith(`agent index: ${join(resolvedOutput, "index.md")}`);
441441
expect(consoleModule.log).toHaveBeenCalledWith(`agent expectations: ${resolvedExpectations}`);
442442
});
443443

@@ -557,7 +557,7 @@ describe("agent command", () => {
557557
expect(readConfig).not.toHaveBeenCalled();
558558
expect(executeAllureRun).not.toHaveBeenCalled();
559559
expect(consoleModule.log).toHaveBeenCalledWith(`agent output: ${outputDir}`);
560-
expect(consoleModule.log).toHaveBeenCalledWith(`agent index: ${outputDir}/index.md`);
560+
expect(consoleModule.log).toHaveBeenCalledWith(`agent index: ${join(outputDir, "index.md")}`);
561561
expect(consoleModule.error).toHaveBeenCalledWith(
562562
'Invalid --expect-label "module". Expected the form name=value, for example module=cli',
563563
);
@@ -589,7 +589,7 @@ describe("agent command", () => {
589589
expect(readConfig).not.toHaveBeenCalled();
590590
expect(executeAllureRun).not.toHaveBeenCalled();
591591
expect(consoleModule.log).toHaveBeenCalledWith(`agent output: ${outputDir}`);
592-
expect(consoleModule.log).toHaveBeenCalledWith(`agent index: ${outputDir}/index.md`);
592+
expect(consoleModule.log).toHaveBeenCalledWith(`agent index: ${join(outputDir, "index.md")}`);
593593
expect(consoleModule.error).toHaveBeenCalledWith(
594594
"Could not load expectations from /cwd/expected.yaml: Expected a YAML or JSON object",
595595
);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { join } from "node:path";
2+
3+
import { epic, feature, label, story } from "allure-js-commons";
4+
import { beforeEach, describe, expect, it } from "vitest";
5+
6+
import { formatAgentOutputLinks, resolveAgentIndexPath } from "../src/paths.js";
7+
8+
beforeEach(async () => {
9+
await epic("coverage");
10+
await feature("agent-mode");
11+
await story("agent-output-paths");
12+
await label("coverage", "agent-mode");
13+
});
14+
15+
describe("agent output path helpers", () => {
16+
it("should resolve the agent index path using native path joining", () => {
17+
const outputDir = join("tmp", "allure-agent-123");
18+
19+
expect(resolveAgentIndexPath(outputDir)).toBe(join(outputDir, "index.md"));
20+
});
21+
22+
it("should format the output directory and index path links together", () => {
23+
const outputDir = join("tmp", "allure-agent-123");
24+
25+
expect(formatAgentOutputLinks(outputDir)).toEqual([
26+
`agent output: ${outputDir}`,
27+
`agent index: ${join(outputDir, "index.md")}`,
28+
]);
29+
});
30+
});

0 commit comments

Comments
 (0)