Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ String buildTableReportContent(List<ZeroCodeCsvReport> rows) {

for (ZeroCodeCsvReport row : rows) {
String scen = trunc(row.getScenarioName(), SCEN_WIDTH);
String step = pad(row.getStepName(), STEP_WIDTH);
String method = pad(row.getMethod(), METH_WIDTH);
String step = trunc(row.getStepName(), STEP_WIDTH);
String method = trunc(row.getMethod(), METH_WIDTH);
boolean isPass = RESULT_PASS.equals(row.getResult());
String resCell = isPass ? "PASSED ✅" : "FAILED ❌";
double delay = row.getResponseDelayMilliSec() != null ? row.getResponseDelayMilliSec() : 0.0;
Expand Down Expand Up @@ -559,7 +559,10 @@ private static String trunc(String text, int width) {
if (text == null) text = "";
text = text.trim();
if (text.length() <= width) return pad(text, width);
return text.substring(0, width - 2) + "..";
int keep = width - 3;
int head = (keep + 1) / 2;
int tail = keep - head;
return text.substring(0, head) + "..." + text.substring(text.length() - tail);
}

private static String rpad(double value, int width) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,32 @@ public void buildTableReport_truncatesLongScenarioAt48Chars() {
);

String table = zeroCodeReportGenerator.buildTableReportContent(rows);
// truncated text ends with ".." and is exactly 48 chars (46 base + "..")
assertThat(table, containsString("GIVEN the very long scenario name that exceeds.."));
// truncated text keeps first 23 + "..." + last 22 chars, exactly 48 chars wide
assertThat(table, containsString("GIVEN the very long sce...imit set for the table"));
}

@Test
public void buildTableReport_truncatesLongStepAt25CharsKeepingFirstAndLastPart() {
String longStep = "verify_the_response_contains_all_expected_fields_correctly";
List<ZeroCodeCsvReport> rows = Arrays.asList(
csvRow("Scenario", longStep, "GET", RESULT_PASS, 50.0)
);

String table = zeroCodeReportGenerator.buildTableReportContent(rows);
// truncated text keeps first 11 + "..." + last 11 chars, exactly 25 chars wide
assertThat(table, containsString("verify_the_...s_correctly"));
}

@Test
public void buildTableReport_truncatesLongMethodAt22CharsKeepingFirstAndLastPart() {
String longMethod = "PATCH_WITH_CUSTOM_HEADERS_AND_LONG_NAME";
List<ZeroCodeCsvReport> rows = Arrays.asList(
csvRow("Scenario", "step", longMethod, RESULT_PASS, 50.0)
);

String table = zeroCodeReportGenerator.buildTableReportContent(rows);
// truncated text keeps first 10 + "..." + last 9 chars, exactly 22 chars wide
assertThat(table, containsString("PATCH_WITH...LONG_NAME"));
}

@Test
Expand Down
Loading