testeranto 0.158.0 → 0.159.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,6 @@ export default async () => {
7
7
  `testeranto/bundles/node`,
8
8
  `testeranto/bundles/web`,
9
9
  `testeranto/bundles/pure`,
10
- `testeranto/reports`,
11
10
  `testeranto/reports/`,
12
11
  `testeranto/features/`,
13
12
  `testeranto/externalTests/`,
@@ -25,6 +25,13 @@ export const TestPage = () => {
25
25
  const [lintErrors, setLintErrors] = useState('');
26
26
  const [loading, setLoading] = useState(true);
27
27
  const [error, setError] = useState(null);
28
+ const [testsExist, setTestsExist] = useState(true);
29
+ const [errorCounts, setErrorCounts] = useState({
30
+ typeErrors: 0,
31
+ staticErrors: 0,
32
+ runTimeErrors: 0
33
+ });
34
+ const [summary, setSummary] = useState(null);
28
35
  const { projectName, '*': splat } = useParams();
29
36
  const pathParts = splat ? splat.split('/') : [];
30
37
  const runtime = pathParts.pop() || '';
@@ -37,14 +44,37 @@ export const TestPage = () => {
37
44
  // setProjectName(projectName);
38
45
  const fetchData = async () => {
39
46
  try {
40
- const { testData, logs, typeErrors, lintErrors } = await fetchTestData(projectName, testPath, runtime);
41
- setTestData(testData);
42
- setLogs(logs);
43
- setTypeErrors(typeErrors);
44
- setLintErrors(lintErrors);
47
+ // First fetch test data
48
+ const testResponse = await fetchTestData(projectName, testPath, runtime);
49
+ setTestData(testResponse.testData);
50
+ setTestsExist(!!testResponse.testData);
51
+ setLogs(testResponse.logs);
52
+ setTypeErrors(testResponse.typeErrors);
53
+ setLintErrors(testResponse.lintErrors);
54
+ // Then fetch summary.json
55
+ try {
56
+ const summaryResponse = await fetch(`reports/${projectName}/summary.json`);
57
+ if (!summaryResponse.ok)
58
+ throw new Error('Failed to fetch summary');
59
+ const allSummaries = await summaryResponse.json();
60
+ const testSummary = allSummaries[testPath];
61
+ console.log("testSummary", testSummary);
62
+ if (testSummary) {
63
+ setSummary(testSummary);
64
+ setErrorCounts({
65
+ typeErrors: testSummary.typeErrors || 0,
66
+ staticErrors: testSummary.staticErrors || 0,
67
+ runTimeErrors: testSummary.runTimeErrors || 0
68
+ });
69
+ }
70
+ }
71
+ catch (err) {
72
+ console.error('Failed to load summary:', err);
73
+ }
45
74
  }
46
75
  catch (err) {
47
76
  setError(err instanceof Error ? err.message : 'Unknown error');
77
+ setTestsExist(false);
48
78
  }
49
79
  finally {
50
80
  setLoading(false);
@@ -62,30 +92,30 @@ export const TestPage = () => {
62
92
  React.createElement(NavBar, { title: decodedTestPath, backLink: `/projects/${projectName}`, navItems: [
63
93
  {
64
94
  to: `#results`,
65
- label: (testData === null || testData === void 0 ? void 0 : testData.givens.some(g => g.whens.some(w => w.error) || g.thens.some(t => t.error)))
95
+ label: !testsExist
66
96
  ? '❌ BDD'
67
- : '✅ BDD',
97
+ : (testData === null || testData === void 0 ? void 0 : testData.givens.some(g => g.whens.some(w => w.error) || g.thens.some(t => t.error)))
98
+ ? '❌ BDD'
99
+ : '✅ BDD',
68
100
  active: route === 'results'
69
101
  },
70
102
  {
71
103
  to: `#logs`,
72
- label: (logs === null || logs === void 0 ? void 0 : logs.includes('error')) || (logs === null || logs === void 0 ? void 0 : logs.includes('fail'))
73
- ? '❌ Logs'
74
- : '✅ Logs',
104
+ label: `Runtime logs`,
75
105
  active: route === 'logs'
76
106
  },
77
107
  {
78
108
  to: `#types`,
79
- label: typeErrors
80
- ? `❌ ${typeErrors.split('\n').filter(l => l.includes('error')).length} Type Errors`
81
- : '✅ Type check',
109
+ label: errorCounts.typeErrors > 0
110
+ ? `tsc ( * ${errorCounts.typeErrors})`
111
+ : 'tsc ✅ ',
82
112
  active: route === 'types'
83
113
  },
84
114
  {
85
115
  to: `#lint`,
86
- label: lintErrors
87
- ? `❌ ${lintErrors.split('\n').filter(l => l.includes('error')).length} Lint Errors`
88
- : '✅ Lint',
116
+ label: errorCounts.staticErrors > 0
117
+ ? `eslint ( *${errorCounts.staticErrors}) `
118
+ : 'eslint ✅',
89
119
  active: route === 'lint'
90
120
  },
91
121
  ], rightContent: React.createElement(Button, { variant: "info", onClick: () => alert("Magic robot activated!"), className: "ms-2" }, "\uD83E\uDD16") }),
@@ -96,7 +126,12 @@ export const TestPage = () => {
96
126
  }
97
127
  } },
98
128
  React.createElement(Tab.Content, { className: "mt-3" },
99
- React.createElement(Tab.Pane, { eventKey: "results" }, testData ? (React.createElement("div", { className: "test-results" },
129
+ React.createElement(Tab.Pane, { eventKey: "results" }, !testsExist ? (React.createElement(Alert, { variant: "danger", className: "mt-3" },
130
+ React.createElement("h4", null, "Tests did not run to completion"),
131
+ React.createElement("p", null, "The test results file (tests.json) was not found or could not be loaded."),
132
+ React.createElement("div", { className: "mt-3" },
133
+ React.createElement(Button, { variant: "outline-light", onClick: () => setRoute('logs'), className: "me-2" }, "View Runtime Logs"),
134
+ React.createElement(Button, { variant: "outline-light", onClick: () => navigate(`/projects/${projectName}#${runtime}`) }, "View Build Logs")))) : testData ? (React.createElement("div", { className: "test-results" },
100
135
  React.createElement("div", { className: "mb-3" }),
101
136
  testData.givens.map((given, i) => (React.createElement("div", { key: i, className: "mb-4 card" },
102
137
  React.createElement("div", { className: "card-header bg-primary text-white" },
@@ -13,200 +13,41 @@ export const fetchTestData = async (projectName, filepath, runTime) => {
13
13
  .split(".")
14
14
  .slice(0, -1)
15
15
  .join(".")}/${runTime}`;
16
- const [testRes, logsRes, typeRes, lintRes] = await Promise.all([
17
- fetch(`${basePath}/tests.json`),
18
- fetch(`${basePath}/logs.txt`),
19
- fetch(`${basePath}/type_errors.txt`),
20
- fetch(`${basePath}/lint_errors.txt`),
21
- ]);
22
- return {
23
- // testData: await testRes.json(),
24
- testData: fakeTestJson,
25
- logs: await logsRes.text(),
26
- typeErrors: await typeRes.text(),
27
- lintErrors: await lintRes.text(),
28
- };
16
+ try {
17
+ const [testRes, logsRes, typeRes, lintRes] = await Promise.all([
18
+ fetch(`${basePath}/tests.json`),
19
+ fetch(`${basePath}/logs.txt`),
20
+ fetch(`${basePath}/type_errors.txt`),
21
+ fetch(`${basePath}/lint_errors.txt`),
22
+ ]);
23
+ if (!testRes.ok) {
24
+ return {
25
+ testData: null,
26
+ logs: await logsRes.text(),
27
+ typeErrors: await typeRes.text(),
28
+ lintErrors: await lintRes.text(),
29
+ error: "Tests did not complete successfully. Please check the build and runtime logs for errors."
30
+ };
31
+ }
32
+ return {
33
+ testData: await testRes.json(),
34
+ logs: await logsRes.text(),
35
+ typeErrors: await typeRes.text(),
36
+ lintErrors: await lintRes.text(),
37
+ error: null
38
+ };
39
+ }
40
+ catch (err) {
41
+ return {
42
+ testData: null,
43
+ logs: "",
44
+ typeErrors: "",
45
+ lintErrors: "",
46
+ error: `Failed to load test data: ${err instanceof Error ? err.message : String(err)}`
47
+ };
48
+ }
29
49
  };
30
50
  export const fetchBuildLogs = async (projectName, runtime) => {
31
51
  const res = await fetch(`reports/${projectName}/src/lib/${projectName}.${testName}/${runtime}/metafile.json`);
32
52
  return await res.json();
33
53
  };
34
- const fakeTestJson = {
35
- name: "Testing the Rectangle class",
36
- givens: [
37
- {
38
- key: "test0",
39
- name: "Default",
40
- whens: [
41
- {
42
- name: "setWidth: 4",
43
- error: true,
44
- },
45
- {
46
- name: "setHeight: 19",
47
- error: true,
48
- },
49
- ],
50
- thens: [
51
- {
52
- name: "getWidth: 4",
53
- error: false,
54
- },
55
- {
56
- name: "getHeight: 19",
57
- error: false,
58
- },
59
- ],
60
- error: null,
61
- features: [
62
- "https://api.github.com/repos/adamwong246/testeranto/issues/8",
63
- ],
64
- },
65
- {
66
- key: "test1",
67
- name: "Default",
68
- whens: [
69
- {
70
- name: "setWidth: 4",
71
- error: true,
72
- },
73
- {
74
- name: "setHeight: 5",
75
- error: true,
76
- },
77
- ],
78
- thens: [
79
- {
80
- name: "getWidth: 4",
81
- error: false,
82
- },
83
- {
84
- name: "getHeight: 5",
85
- error: false,
86
- },
87
- {
88
- name: "area: 20",
89
- error: false,
90
- },
91
- {
92
- name: "AreaPlusCircumference: 38",
93
- error: false,
94
- },
95
- ],
96
- error: null,
97
- features: ["Rectangles have width and height."],
98
- },
99
- {
100
- key: "test2",
101
- name: "Default",
102
- whens: [
103
- {
104
- name: "setHeight: 4",
105
- error: true,
106
- },
107
- {
108
- name: "setWidth: 33",
109
- error: true,
110
- },
111
- ],
112
- thens: [
113
- {
114
- name: "area: 132",
115
- error: false,
116
- },
117
- ],
118
- error: null,
119
- features: ["Rectangles have area"],
120
- },
121
- {
122
- key: "test2_1",
123
- name: "Default",
124
- whens: [],
125
- thens: [
126
- {
127
- name: "getWidth: 2",
128
- error: false,
129
- },
130
- {
131
- name: "getHeight: 2",
132
- error: false,
133
- },
134
- ],
135
- error: null,
136
- features: ["Rectangles have default size"],
137
- },
138
- {
139
- key: "test3",
140
- name: "Default",
141
- whens: [
142
- {
143
- name: "setHeight: 5",
144
- error: true,
145
- },
146
- {
147
- name: "setWidth: 5",
148
- error: true,
149
- },
150
- ],
151
- thens: [
152
- {
153
- name: "area: 25",
154
- error: false,
155
- },
156
- ],
157
- error: null,
158
- features: [
159
- "file:///Users/adam/Code/testeranto-starter/src/Rectangle/README.md",
160
- ],
161
- },
162
- {
163
- key: "test4",
164
- name: "Default",
165
- whens: [
166
- {
167
- name: "setHeight: 6",
168
- error: true,
169
- },
170
- {
171
- name: "setWidth: 6",
172
- error: true,
173
- },
174
- ],
175
- thens: [
176
- {
177
- name: "area: 36",
178
- error: false,
179
- },
180
- ],
181
- error: null,
182
- features: ["Rectangles have area"],
183
- },
184
- {
185
- key: "test5",
186
- name: "Default",
187
- whens: [],
188
- thens: [
189
- {
190
- name: "getWidth: 2",
191
- error: false,
192
- },
193
- {
194
- name: "getHeight: 2",
195
- error: false,
196
- },
197
- ],
198
- error: null,
199
- features: ["Rectangles have default size, again"],
200
- },
201
- ],
202
- checks: [],
203
- fails: 0,
204
- features: [
205
- "https://api.github.com/repos/adamwong246/testeranto/issues/8",
206
- "Rectangles have width and height.",
207
- "Rectangles have area",
208
- "Rectangles have default size",
209
- "file:///Users/adam/Code/testeranto-starter/src/Rectangle/README.md",
210
- "Rectangles have default size, again",
211
- ],
212
- };