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

PLT-7646 Fix progress % values for properties in the Timeline-View grid #21

Merged
merged 11 commits into from
Sep 29, 2023

Conversation

amnambiar
Copy link
Collaborator

@amnambiar amnambiar commented Sep 22, 2023

https://input-output.atlassian.net/browse/PLT-7646

BE PR input-output-hk/dapps-certification#90

Summary by CodeRabbit

  • New Feature: Introduced CircularProgressBar and ProgressCard components for better progress visualization.
  • New Feature: Added RepoAccessStatus component to display repository access status.
  • New Feature: Implemented StatusIcon component for displaying various status icons.
  • Refactor: Simplified routing structure in App.tsx and removed unused imports and components.
  • Refactor: Updated Button component to support passing an icon element.
  • Refactor: Enhanced TextArea component with onBlur validation and floating label functionality.
  • Refactor: Improved TableComponent to support collapsible rows and show/hide column functionality.
  • Refactor: Modified ColViz component for better visual presentation and interaction.
  • Refactor: Updated useLocalStorage hook for better error handling and value type flexibility.
  • Bug Fix: Fixed image paths in repoAccessStatus.config.ts.
  • Test: Commented out test cases for LogsView component.
  • Chore: Updated CSS styles across multiple components for improved UI.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 22, 2023

Walkthrough

This comprehensive update focuses on enhancing the user interface, improving performance, and refining error handling. Key changes include consolidation of font styles, simplification of routing structure, introduction of new components like CircularProgressBar and RepoAccessStatus, and modifications to existing components for better functionality and visual appeal. The code also improves local storage handling and introduces more robust error handling mechanisms.

Changes

File(s) Summary
public/index.html Consolidated external CSS files for fonts into a single file to improve performance.
src/api/onRequest.ts Enhanced error handling by resetting user session in case of unauthorized requests.
src/app/App.tsx Simplified routing structure and removed unused imports and components.
src/components/Button/Button.scss, src/components/Button/Button.tsx Added flexbox properties for alignment and introduced an icon property to the Button component.
src/components/CreateCertificate/CreateCertificate.tsx Replaced Button with LoadingButton and added Snackbar for error display.
src/components/LogsView/... Renamed InformationTable to LogsView, updated styling, and improved log handling.
src/components/ProgressCard/... Introduced CircularProgressBar and ProgressCard components for displaying progress.
src/components/RepoAccessStatus/... Added RepoAccessStatus component to display repository access status.
src/components/Table/Table.tsx Refactored table component to support collapsible rows and show/hide column functionality.
src/components/TextArea/TextArea.tsx Improved textarea handling with onBlur event and floating label status based on value.
src/hooks/useLocalStorage.ts Updated useLocalStorage hook to handle different data types and improved error handling.
src/pages/certification/... Enhanced certification task progress calculation and display, and added local storage handling for form values.

🐇
"In the land of code, where logic is king,
Changes are made, improvements they bring.
Fonts are consolidated, routes simplified,
New components created, with style applied.
Errors are handled, with care and grace,
Progress displayed, in its own space.
A rabbit hops by, leaving tracks in the sand,
Celebrating the changes, they're truly grand!" 🎉


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

@amnambiar amnambiar changed the base branch from master to PLT-7344 September 22, 2023 13:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 6d324bb and a2286c6.
Files selected for processing (3)
  • src/pages/certification/Certification.helper.tsx (2 hunks)
  • src/pages/certification/certification-result/CertificationResult.tsx (5 hunks)
  • src/pages/certification/components/TimelineView/TimelineView.tsx (10 hunks)
Files skipped from review due to trivial changes (1)
  • src/pages/certification/Certification.helper.tsx
Additional comments (Suppressed): 15
src/pages/certification/certification-result/CertificationResult.tsx (5)
  • 1-4: The useRef hook has been added to the import statement from 'react'. Ensure that this new hook is being used correctly in the component.

  • 21-27: A new helper function isTaskSuccess and a new constant taskKeys have been imported from Certification.helper. Make sure these are defined and exported correctly in the helper file.

  • 32-38: Two new useRef hooks have been introduced: propertyBasedTestProgressTotal and currentPropertyBasedTestProgress. These hooks are used to store mutable values which can persist across re-renders without causing additional renders when their values change. This seems to be an appropriate use of useRef.

  • 55-70: The logic for processing the result JSON has been updated. Now, it not only processes the finished JSON but also calculates the progress of property-based testing. The calculation is based on the success status of each task in the result JSON. This seems like a reasonable approach to calculate the progress, but ensure that the isTaskSuccess function correctly determines the success status of a task.

  • 114-120: The ProgressCard component is now being rendered with dynamic values for currentValue and totalValue, which are derived from the refs currentPropertyBasedTestProgress and propertyBasedTestProgressTotal. This is a good improvement as it allows the progress bar to reflect the actual progress of property-based testing.

src/pages/certification/components/TimelineView/TimelineView.tsx (10)
  • 1-4: The useRef hook is imported from React but it's not used in the old hunk. Ensure that this new import is necessary and used appropriately in other parts of the code.

  • 15-23: The ICertificationTask and isTaskSuccess are newly imported from Certification.helper. Make sure these imports are used correctly in the updated code.

  • 34-38: A new property key has been added to the PlanObj interface. Ensure that this change doesn't break any existing functionality where PlanObj is used.

  • 66-70: The useRef hook is used to create currentPropertyBasedTestProgress. This is a new addition to the component state. Make sure its usage aligns with the intended behavior of the component.

  • 91-104: The logic for setting plannedTestingTasks has been modified. The new logic includes a check for TaskConfig before returning an object. This is a good practice as it prevents potential errors if TaskConfig is undefined.

  • 123-129: The function recalculateTestTaskProgress is called when a task succeeds. This is a new addition to the code. Ensure that this function call doesn't introduce any unexpected side effects.

  • 137-141: The function recalculateTestTaskProgress is defined here. It adds the name of the task to currentPropertyBasedTestProgress if it's not already present. This seems to be a part of the new logic for tracking progress.

  • 268-281: The ProgressCard component is now rendered with dynamic values for currentValue and totalValue. This is a significant improvement over the commented-out static values in the old hunk.

  • 294-300: The index parameter is added to the map function. Ensure that this new parameter is used correctly in the updated code.

  • 307-328: The logic for rendering the progress of each task has been updated. The new logic includes checks for the run status and task progress, and renders different components based on these checks. This seems to be a part of the new logic for tracking progress.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between a2286c6 and e43ade5.
Files selected for processing (1)
  • src/pages/certification/certification-result/fullReportTable.css (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/pages/certification/certification-result/fullReportTable.css

Base automatically changed from PLT-7344 to master September 25, 2023 15:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between e43ade5 and 40a999a.
Files selected for processing (2)
  • src/hooks/useLocalStorage.ts (1 hunks)
  • src/hooks/useLogs.ts (2 hunks)
Files skipped from review due to trivial changes (2)
  • src/hooks/useLocalStorage.ts
  • src/hooks/useLogs.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 3

Commits Files that changed from the base of the PR and between 40a999a and e98172d.
Files selected for processing (2)
  • src/components/LogsView/LogsView.tsx (1 hunks)
  • src/pages/certification/components/TimelineView/TimelineView.tsx (10 hunks)
Additional comments (Suppressed): 11
src/components/LogsView/LogsView.tsx (2)
  • 12-19: The new prop latestTestingProgress is introduced in the function signature. Ensure that all calls to this component throughout the codebase have been updated to match the new signature if necessary.

  • 70-78: This block of code introduces a new logic to handle the progress of property-based tests. It checks if the latestTestingProgress function is provided, and if the current log entry is the second last one with "run-certify" in its source. If these conditions are met, it parses the text of the log entry as JSON and passes it to the latestTestingProgress function. This seems like a specific use case, so ensure that it doesn't interfere with other uses of the LogsView component.

src/pages/certification/components/TimelineView/TimelineView.tsx (9)
  • 4-4: The useRef hook is imported but not used in the old hunk. Ensure that it's necessary for the new code.

  • 15-21: The import statement has been expanded to include ICertificationTask and isTaskSuccess. Make sure these are being used in the new code.

  • 34-38: A new property key has been added to the PlanObj interface. Confirm that this change doesn't break any existing functionality where PlanObj is used.

  • 66-67: The currentPropertyBasedTestProgress state variable has been introduced using useRef. This seems to be a new addition to manage the progress of the current property-based test.

  • 83-112: The assignProgressToTasks function has been introduced to assign progress to tasks based on the received progress data. It updates the plannedTestingTasks state with the calculated progress. This is a significant change from the previous logic, which directly updated the plannedTestingTasks state inside the handleTestingTimelineDetails function.

  • 145-149: The recalculateTestTaskProgress function has been introduced to update the currentPropertyBasedTestProgress ref with the name of the completed task. This seems to be a new feature for tracking the progress of property-based tests.

  • 192-195: The processLatestTestingProgressFromLogs function has been introduced to process the latest testing progress from logs and assign it to tasks. This seems to be a new feature for updating task progress based on log data.

  • 292-292: The ProgressCard component is now being used with dynamic values for currentValue and totalValue. Ensure that these values are calculated correctly and the component displays the expected progress.

  • 311-312: The index parameter has been added to the map function. Make sure this doesn't break any existing functionality where the map function is used.

@amnambiar
Copy link
Collaborator Author

amnambiar commented Sep 29, 2023

@RSoulatIOHK Resolved the calculations within the progress% in TimelineView ; and added the Property Based Testing progress card in both Timeline View and Full Report View when run is finished.

Calculations are updated here - https://input-output.atlassian.net/browse/PLT-7646?focusedCommentId=217176

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 4

Commits Files that changed from the base of the PR and between e98172d and 4dcebd8.
Files selected for processing (6)
  • src/components/LogsView/LogsView.tsx (1 hunks)
  • src/components/RepoAccessStatus/repoAccessStatus.config.ts (1 hunks)
  • src/pages/certification/Certification.helper.tsx (3 hunks)
  • src/pages/certification/certification-result/CertificationResult.tsx (5 hunks)
  • src/pages/certification/components/AuditorRunTestForm/AuditorRunTestForm.tsx (6 hunks)
  • src/pages/certification/components/TimelineView/TimelineView.tsx (8 hunks)
Files skipped from review due to trivial changes (2)
  • src/components/RepoAccessStatus/repoAccessStatus.config.ts
  • src/pages/certification/components/AuditorRunTestForm/AuditorRunTestForm.tsx
Additional comments (Suppressed): 16
src/pages/certification/certification-result/CertificationResult.tsx (5)
  • 1-4: The useRef hook is imported but not used in the old hunk. Ensure that this new import is necessary for the changes made in the new hunks.

  • 21-27: New functions and types are imported from Certification.helper. Make sure these are implemented correctly and used as intended in the new code.

  • 32-39: A new state variable testTaskProgress is introduced using the useRef hook. This seems to be used for storing progress information of tasks.

  • 54-80: The logic for processing the result JSON has been significantly expanded. It now includes a loop over the keys of the result JSON, where each key is matched with a task configuration. If a match is found and the corresponding value in the result JSON is truthy, a new object is created and pushed into testTaskProgress.current. This seems to be part of the new progress calculation logic.

  • 124-134: The ProgressCard component is now rendered with dynamic values for currentValue and totalValue, calculated by the newly imported functions calculateCurrentProgress and calculateExpectedProgress. This should provide a more accurate representation of the progress based on the actual data.

-                {/* <ProgressCard title={"Property Based Testing"} currentValue={100} totalValue={1000} /> */}
+                <ProgressCard
+                  title={"Property Based Testing"}
+                  currentValue={calculateCurrentProgress(testTaskProgress.current)}
+                  totalValue={calculateExpectedProgress(testTaskProgress.current)}
+                />
src/pages/certification/Certification.helper.tsx (2)
  • 1-53: The new hunk introduces several interfaces to define the structure of certification tasks, testing progress, and planned tasks. This is a good practice as it improves code readability and maintainability by providing clear definitions of the data structures used in the code. The CertificationTasks array has been updated to use the newly introduced ICertificationTask interface.

  • 152-176: New utility functions parseTestCount, calculateCurrentProgress, and calculateExpectedProgress have been added. These functions seem to be well-implemented and should improve the modularity and readability of the code.

src/pages/certification/components/TimelineView/TimelineView.tsx (8)
  • 1-4: The useRef hook has been added to the import statement from React. Ensure that this new hook is used appropriately in the code and that its implications are understood.

  • 14-29: Several new imports have been added, including calculateCurrentProgress, calculateExpectedProgress, getProgressCardInfo, ICertificationTask, IFinishedTestingTaskDetails, ITestingProgress, PlanObj, and isTaskSuccess. Make sure these new imports are used correctly and efficiently in the code.

  • 32-40: A new component StatusIcon has been imported and two new constants PROGRESS_PASS and PROGRESS_FAIL have been defined. Ensure that these changes align with the intended functionality of the code.

  • 89-144: The logic for setting planned testing tasks has been significantly updated. The new logic seems more comprehensive and handles different scenarios more accurately. However, it's important to verify that these changes don't introduce any unexpected behavior or bugs.

-              item.progress = Math.trunc(
-                ((currentProgressStats["successes"] +
-                  currentProgressStats["failures"]) /
-                  currentProgressStats["expected"]) *
-                  100
-              );
+              item.progress = currentProgressStats["expected"] ? Math.trunc(
+                ((currentProgressStats["successes"] + currentProgressStats["failures"]) / 
+                  (currentProgressStats["expected"] - currentProgressStats["discarded"])) * 100
+              ) : "On Going";

In the old hunk, the progress was calculated as a percentage of successes and failures over expected. In the new hunk, discarded tests are subtracted from the expected total before calculating the percentage. This seems to be a more accurate way of calculating progress, but it's important to verify that this change doesn't have any unintended side effects.

  • 183-205: A new function processLatestTestingProgressFromLogs has been introduced. This function updates the planned testing tasks based on the latest testing progress from logs. It appears to handle different scenarios correctly, but it's important to verify that it works as expected in all cases.

  • 207-220: The getTaskProgress function has been introduced to determine the progress of each task. It uses the StatusIcon component to display the status of each task. Ensure that this function is working as expected and that it accurately reflects the status of each task.

  • 302-324: The FileCoverageContainer and ProgressCard components are now conditionally rendered based on whether the run status is "finished". The calculateCurrentProgress and calculateExpectedProgress functions are used to calculate the current and total values for the ProgressCard component. Make sure these changes work as expected and improve the user experience.

-                  {/* <ProgressCard title={"Property Based Testing"} currentValue={100} totalValue={1000}/> */}
+                  <ProgressCard 
+                    title={"Property Based Testing"} 
+                    currentValue={calculateCurrentProgress(plannedTestingTasks)} 
+                    totalValue={calculateExpectedProgress(plannedTestingTasks)}
+                  />
  • 338-344: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [338-357]

The logic for displaying task progress in the table has been updated. Instead of using an image to indicate complete progress, the getTaskProgress function is now used. This should provide a more consistent and flexible way of displaying task progress.

-                              {task.progress === 100 ? (
-                                <img
-                                  className="image"
-                                  src="/images/status-check.svg"
-                                  alt="complete"
-                                />
-                              ) : (
-                                <span>{task.progress}%</span>
-                              )}
+                              {getTaskProgress(task, index)}
src/components/LogsView/LogsView.tsx (1)
  • 7-13: The LogsView component now accepts an additional prop latestTestingProgress. This function is expected to be called with the second last log entry when polling ends and the source of the log entry contains 'run-certify'. Ensure that this new prop is correctly passed wherever this component is used.

src/components/LogsView/LogsView.tsx Show resolved Hide resolved
src/components/LogsView/LogsView.tsx Show resolved Hide resolved
@amnambiar amnambiar merged commit 3797183 into master Sep 29, 2023
@amnambiar amnambiar deleted the PLT-7646 branch September 29, 2023 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants