Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Display metadata information in the UI #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions src/mocks/mock-graphql-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const typeDefs = `
testSeed: Int
startTime: String
endTime: String
gitBranch: String
gitSha: String
buildTriggerActor: String
buildUrl: String
suiteRuns: [SuiteRun!]!
}

Expand Down Expand Up @@ -78,6 +82,17 @@ const generateMockData = () => {
{ id: 4, name: "Sanity" },
{ id: 5, name: "Performance" },
];

const gitBranches = ["main", "develop", "feature/authentication", "bugfix/login-issue"];
const buildTriggerActors = ["alice", "bob", "charlie", "deploy-bot", "jenkins"];


// Utility function to generate a random Git SHA (40 characters)
const generateGitSha = () =>
Array.from({ length: 40 }, () => Math.floor(Math.random() * 16).toString(16)).join("");

// Generate a random build URL
const generateBuildUrl = (id) => `https://ci.example.com/build/${id}`;

// Generate SpecRun
const generateSpecRuns = (suiteId) =>
Expand Down Expand Up @@ -110,6 +125,10 @@ const generateMockData = () => {
testSeed: Math.floor(Math.random() * 10000),
startTime: `2025-01-01T09:00:00Z`,
endTime: `2025-01-01T10:00:00Z`,
gitBranch: gitBranches[Math.floor(Math.random() * gitBranches.length)],
gitSha: generateGitSha(),
buildTriggerActor: buildTriggerActors[Math.floor(Math.random() * buildTriggerActors.length)],
buildUrl: generateBuildUrl(i + 1),
suiteRuns: generateSuiteRuns(i + 1),
}));
};
Expand Down
8 changes: 8 additions & 0 deletions src/pages/test-runs/graphQlQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export const GET_TEST_RUNS = gql`
testSeed
startTime
endTime
gitBranch
gitSha
buildTriggerActor
buildUrl
suiteRuns {
id
suiteName
Expand Down Expand Up @@ -48,6 +52,10 @@ export const GET_TEST_RUN_BY_ID = gql`
testSeed
startTime
endTime
gitBranch
gitSha
buildTriggerActor
buildUrl
suiteRuns {
id
suiteName
Expand Down
4 changes: 4 additions & 0 deletions src/pages/test-runs/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export interface ITestRun {
testSeed: number;
startTime: string;
endTime: string;
gitBranch: string;
gitSha: string;
buildTriggerActor: string;
buildUrl: string;
suiteRuns: ISuiteRun[];
}

Expand Down
53 changes: 50 additions & 3 deletions src/pages/test-runs/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
uniqueTags,
generateTagColor
} from "./list-utils";
import { Typography } from "antd/lib";

const HEADER_NAME = import.meta.env.VITE_FERN_REPORTER_HEADER_NAME;

Expand Down Expand Up @@ -88,7 +89,7 @@ export const TestRunsList = () => {
<Table.Column
title="Status"
key="status"
width={320}
width={280}
render={(_text, testRun: ITestRun) => {
const statusMap = testRunsStatus(testRun);
return (
Expand Down Expand Up @@ -121,9 +122,9 @@ export const TestRunsList = () => {
/>
<Table.Column title="Tags"
key="tags"
width={500}
width={280}
render={(_text, record: ITestRun) => (
<Space style={{minWidth: '200px'}}>
<Space wrap style={{minWidth: '200px'}}>
{
uniqueTags(record
.suiteRuns
Expand All @@ -137,6 +138,52 @@ export const TestRunsList = () => {
</Space>
)}
/>

<Table.Column
title="Git Branch"
key="gitBranch"
render={(_text, testRun: ITestRun) => (
<Typography.Paragraph
style={{color: 'inherit' }}>
{testRun.gitBranch}
</Typography.Paragraph>
)}
/>

<Table.Column
title="Git SHA"
key="gitSha"
render={(_text, testRun: ITestRun) => (
<Typography.Paragraph
style={{ color: 'inherit' }}>
{testRun.gitSha}
</Typography.Paragraph>
)}
/>

<Table.Column
title="Build Trigger Actor"
key="buildTriggerActor"
render={(_text, testRun: ITestRun) =>
<Typography.Paragraph
style={{ color: 'inherit' }}>
{testRun.buildTriggerActor}
</Typography.Paragraph>
}
/>

<Table.Column
title="Build URL"
key="buildUrl"
render={(_text, testRun: ITestRun) =>
<Typography.Link
style={{ color: '#66c2ff', textDecoration: 'underline' }}
target="_blank"
href={testRun.buildUrl}>
{testRun.buildUrl}
</Typography.Link>
}
/>
</Table>
</List>
);
Expand Down
4 changes: 4 additions & 0 deletions src/providers/testrun-graphql-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ interface TestRun {
testSeed: string;
startTime: string;
endTime: string;
gitBranch: string;
gitSha: string;
buildTriggerActor: string;
buildUrl: string;
suiteRuns: {
id: string;
suiteName: string;
Expand Down
36 changes: 36 additions & 0 deletions test/component/test-runs-list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ describe("TestRunsList Component", () => {
],
startTime: "2022-01-01T00:00:00Z",
endTime: "2022-01-01T01:00:00Z",
gitBranch: "main",
gitSha: "kf6830",
buildTriggerActor: "user1",
buildUrl: "http://example.com/build/1",
},
];

Expand All @@ -90,6 +94,10 @@ describe("TestRunsList Component", () => {
expect(screen.getByText('Spec Runs')).toBeInTheDocument();
expect(screen.getByText('Duration')).toBeInTheDocument();
expect(screen.getByText('Tags')).toBeInTheDocument();
expect(screen.getByText('Git Branch')).toBeInTheDocument();
expect(screen.getByText('Git SHA')).toBeInTheDocument();
expect(screen.getByText('Build Trigger Actor')).toBeInTheDocument();
expect(screen.getByText('Build URL')).toBeInTheDocument();
});

it("should render loading state", () => {
Expand Down Expand Up @@ -134,6 +142,10 @@ describe("TestRunsList Component", () => {
suiteRuns: [{ suiteName: "Suite 1", specRuns: [] }],
startTime: "2022-01-01T00:00:00Z",
endTime: "2022-01-01T01:00:00Z",
gitBranch: "main",
gitSha: "kf6830",
buildTriggerActor: "user1",
buildUrl: "http://example.com/build/1",
},
];

Expand All @@ -153,6 +165,10 @@ describe("TestRunsList Component", () => {
await waitFor(() => {
expect(screen.getByText("Project A")).toBeInTheDocument();
expect(screen.getByText("Suite 1")).toBeInTheDocument();
expect(screen.getByText("main")).toBeInTheDocument();
expect(screen.getByText("kf6830")).toBeInTheDocument();
expect(screen.getByText("user1")).toBeInTheDocument();
expect(screen.getByText("http://example.com/build/1")).toBeInTheDocument();
});
});

Expand All @@ -164,6 +180,10 @@ describe("TestRunsList Component", () => {
suiteRuns: [{ suiteName: "Suite 1", specRuns: [] }],
startTime: "2022-01-01T00:00:00Z",
endTime: "2022-01-01T01:00:00Z",
gitBranch: "main",
gitSha: "kf6830",
buildTriggerActor: "user1",
buildUrl: "http://example.com/build/1",
},
];
const fetchNextPageMock = jest.fn();
Expand Down Expand Up @@ -233,6 +253,10 @@ describe("TestRunsList Component", () => {
],
startTime: "2022-01-01T00:00:00Z",
endTime: "2022-01-01T01:00:00Z",
gitBranch: "main",
gitSha: "kf6830",
buildTriggerActor: "user1",
buildUrl: "http://example.com/build/1",
},
];

Expand Down Expand Up @@ -295,6 +319,10 @@ describe("TestRunsList Component", () => {
],
startTime: "2022-01-01T00:00:00Z",
endTime: "2022-01-01T01:00:00Z",
gitBranch: "main",
gitSha: "kf6830",
buildTriggerActor: "user1",
buildUrl: "http://example.com/build/1",
},
];

Expand Down Expand Up @@ -324,6 +352,10 @@ describe("TestRunsList Component", () => {
suiteRuns: [{ suiteName: "Suite 1", specRuns: [] }],
startTime: "2022-01-01T00:00:00Z",
endTime: "2022-01-01T01:00:00Z",
gitBranch: "main",
gitSha: "kf6830",
buildTriggerActor: "user1",
buildUrl: "http://example.com/build/1",
},
];

Expand Down Expand Up @@ -378,6 +410,10 @@ describe("TestRunsList Component", () => {
],
startTime: "2022-01-01T00:00:00Z",
endTime: "2022-01-01T01:00:00Z",
gitBranch: "main",
gitSha: "kf6830",
buildTriggerActor: "user1",
buildUrl: "http://example.com/build/1",
},
];

Expand Down
4 changes: 4 additions & 0 deletions test/utils/dataMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const testRun: ITestRun = {
"testSeed": 1717396142,
"startTime": "2024-06-03T06:29:32.938772Z",
"endTime": "2024-06-03T06:29:34.517009Z",
"gitBranch": "main",
"gitSha": "e1e7d6f",
"buildTriggerActor": "test-runner",
"buildUrl": "example.com",
"suiteRuns": [
{
"id": 1,
Expand Down
1 change: 1 addition & 0 deletions test/utils/summaryDataMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {IReportSummary} from "../../src/pages/test-summaries/interfaces";
export const reportSummary: IReportSummary = {
StartTime: "2024-04-20T04:20:00.000000Z",
SuiteRunID: 1,
SuiteName: "Dummy Suite",
TestProjectName: "Dummy Project",
TotalPassedSpecRuns: 3,
TotalSkippedSpecRuns: 0,
Expand Down