From a66ae288878562d8376530647f1a635a02faef20 Mon Sep 17 00:00:00 2001 From: Craig Atkinson Date: Sat, 20 Apr 2024 10:16:36 -0500 Subject: [PATCH] Expanding test failures if there are 15 or less (#1307) * Expanding test failures if there are 15 or less * Updating cypress test --- ui/cypress/e2e/failed_tests.cy.js | 8 +- ui/cypress/fixtures/failed_test_cases_20.json | 322 ++++++++++++++++++ ui/src/TestCase/TestCaseFailurePanelList.tsx | 3 +- .../TestCaseFailurePanelList.spec.tsx | 38 +++ 4 files changed, 367 insertions(+), 4 deletions(-) create mode 100644 ui/cypress/fixtures/failed_test_cases_20.json diff --git a/ui/cypress/e2e/failed_tests.cy.js b/ui/cypress/e2e/failed_tests.cy.js index 960843a17..d3b25e89f 100644 --- a/ui/cypress/e2e/failed_tests.cy.js +++ b/ui/cypress/e2e/failed_tests.cy.js @@ -95,17 +95,19 @@ describe("test run with failed test cases", () => { cy.getCodeText().should("contain", "System err line 1"); }); - it("should show test cases collapsed initially when 6 failed test cases", () => { + it("should show test cases collapsed initially when 20 failed test cases", () => { const publicId = "321908"; - const testCaseIndexes = [1, 2, 3, 4, 5, 6]; + const testCaseIndexes = [ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + ]; cy.intercept("GET", `run/${publicId}/summary`, { fixture: "test_run_summary.json", }); cy.intercept("GET", `run/${publicId}/cases/failed`, { - fixture: "failed_test_cases_6.json", + fixture: "failed_test_cases_20.json", }); cy.interceptTestRunBasicRequests(publicId); diff --git a/ui/cypress/fixtures/failed_test_cases_20.json b/ui/cypress/fixtures/failed_test_cases_20.json new file mode 100644 index 000000000..8465f2661 --- /dev/null +++ b/ui/cypress/fixtures/failed_test_cases_20.json @@ -0,0 +1,322 @@ +[ + { + "idx": 1, + "test_suite_idx": 1, + "name": "should fail1", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec1", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec1.should fail1(FailingSpec1.groovy:8)\n" + } + }, + { + "idx": 2, + "test_suite_idx": 1, + "name": "should fail2", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec2", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied2:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure2", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec2.should fail2(FailingSpec2.groovy:8)\n" + } + }, + { + "idx": 3, + "test_suite_idx": 1, + "name": "should fail3", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec3", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec3.should fail1(FailingSpec3.groovy:8)\n" + } + }, + { + "idx": 4, + "test_suite_idx": 1, + "name": "should fail4", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec4", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec4.should fail1(FailingSpec4.groovy:8)\n" + } + }, + { + "idx": 5, + "test_suite_idx": 1, + "name": "should fail5", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec5", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec5.should fail1(FailingSpec5.groovy:8)\n" + } + }, + { + "idx": 6, + "test_suite_idx": 1, + "name": "should fail6", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec6", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 7, + "test_suite_idx": 1, + "name": "should fail7", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec7", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 8, + "test_suite_idx": 1, + "name": "should fail8", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec8", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 9, + "test_suite_idx": 1, + "name": "should fail9", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec9", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 10, + "test_suite_idx": 1, + "name": "should fail10", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec10", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 11, + "test_suite_idx": 1, + "name": "should fail11", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec11", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 12, + "test_suite_idx": 1, + "name": "should fail1", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec12", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 13, + "test_suite_idx": 1, + "name": "should fail13", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec13", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 14, + "test_suite_idx": 1, + "name": "should fail14", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec14", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 15, + "test_suite_idx": 1, + "name": "should fail15", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec15", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 16, + "test_suite_idx": 1, + "name": "should fail16", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec16", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 17, + "test_suite_idx": 1, + "name": "should fail17", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec17", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 18, + "test_suite_idx": 1, + "name": "should fail18", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec18", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 19, + "test_suite_idx": 1, + "name": "should fail19", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec19", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + }, + { + "idx": 20, + "test_suite_idx": 1, + "name": "should fail20", + "package_name": "projektor.example.spock", + "class_name": "FailingSpec20", + "duration": 0.237, + "passed": false, + "has_system_out": true, + "has_system_err": true, + "failure": { + "failure_message": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n", + "failure_type": "org.spockframework.runtime.SpockComparisonFailure", + "failure_text": "Condition not satisfied:\n\n1 \u003d\u003d 2\n |\n false\n\n\tat projektor.example.spock.FailingSpec6.should fail1(FailingSpec6.groovy:8)\n" + } + } +] diff --git a/ui/src/TestCase/TestCaseFailurePanelList.tsx b/ui/src/TestCase/TestCaseFailurePanelList.tsx index 6363ddb41..2d4ee5e26 100644 --- a/ui/src/TestCase/TestCaseFailurePanelList.tsx +++ b/ui/src/TestCase/TestCaseFailurePanelList.tsx @@ -9,6 +9,7 @@ import CleanLinkText from "../Link/CleanLinkText"; import { makeStyles } from "@material-ui/core/styles"; const showFullFailureMaxFailureCount = 5; +const expandAllFailuresCount = 15; interface TestCaseFailurePanelListProps { failedTestCases: TestCase[]; @@ -37,7 +38,7 @@ const TestCaseFailurePanelList = ({ const classes = useStyles({}); const initialExpandCollapseState = - failedTestCases.length <= showFullFailureMaxFailureCount + failedTestCases.length <= expandAllFailuresCount ? ExpandCollapseState.EXPAND_ALL : ExpandCollapseState.COLLAPSE_ALL; const [expandCollapseAll, setExpandCollapseState] = diff --git a/ui/src/TestCase/__tests__/TestCaseFailurePanelList.spec.tsx b/ui/src/TestCase/__tests__/TestCaseFailurePanelList.spec.tsx index 0d873a17c..4968eddf3 100644 --- a/ui/src/TestCase/__tests__/TestCaseFailurePanelList.spec.tsx +++ b/ui/src/TestCase/__tests__/TestCaseFailurePanelList.spec.tsx @@ -45,6 +45,44 @@ describe("TestCaseFailureListPanel", () => { ); }); + it("should expand all test failures when there are 15", () => { + const failure: TestFailure = { + failureMessage: "My failure message", + failureText: "My longer and more descriptive failure text", + failureType: "", + }; + + const testCases = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15].map( + (idx) => createTestCaseWithFailure(idx, failure), + ); + + const { getByTestId } = render( + , + ); + + expect(getByTestId("test-case-summary-2-15")).toHaveClass("Mui-expanded"); + }); + + it("should not expand all test failures when there are 20", () => { + const failure: TestFailure = { + failureMessage: "My failure message", + failureText: "My longer and more descriptive failure text", + failureType: "", + }; + + const testCases = [ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + ].map((idx) => createTestCaseWithFailure(idx, failure)); + + const { getByTestId } = render( + , + ); + + expect(getByTestId("test-case-summary-2-1")).not.toHaveClass( + "Mui-expanded", + ); + }); + function createTestCaseWithFailure( idx: number, failure: TestFailure,