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

Implement multiple examples loading and generation in the Interactive Server. #1367

Merged
merged 9 commits into from
Oct 21, 2024

Conversation

StarKhan6368
Copy link
Collaborator

@StarKhan6368 StarKhan6368 commented Oct 20, 2024

What: Implement multiple examples loading and generation in the Interactive Server.

Load multiple examples and generate more examples in interactive examples UI.

Why:

  • At present, we are limited to loading only a single existing example, regardless of the number available. As a result, the user can view just that one example and is restricted to generating only one additional example if no examples are present.
  • This PR allows for the loading of multiple existing examples and provides the user with the capability to generate additional examples if necessary.
  • Adding Generate More button when there are already existing examples
  • Show each example as a separate row under each operation

Checklist:

StarKhan6368 and others added 9 commits October 20, 2024 13:19
- Fixes - bug with exactValue validation in interactive example tests.
- Use the fileSource attribute in rows to match example file to scenario
- Add tests to ensure canonical path is used for matching.
- Update existing test for Feature.createContractTestFromExampleFile.
- Use AtomicInteger for unique example file names.
- Include TestResult report in case of test failure with testLogs.
- Ability to Load and display multiple existing examples.
- Ability to Generate additional examples when necessary.
- Update ExamplesCommandTest accordingly.
- Update CSS and JS files.
- Remove chevronDown and dropdown functionality from drill-downs.
- Add and implement Generate more buttons for multiple generations
- Functions to dynamically update the examples table and recalculate
  the row-spans when adding new examples.
- Use dynamic serial numbering no reliance on thymeleaf.
- Modifications to how data is stored and accessed in JS.
- Clean up TestInteractionsLog.combineLog for consistency.
- Group also by content-type when grouping endpoints.
- Update updateSpans function in JS to also consider content-type.
- Other CSS fixes.
* main:
  Loading config file from classpath Also in case of env property or classpath checking if the file exists before returning
- This change will be incorporated into a separate PR.
- Rename `atomicCounter` to `exampleFileNamePostFixCounter` to better
  describe the functionality.
Copy link
Member

@harikrishnan83 harikrishnan83 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@@ -14,56 +16,81 @@ class ExamplesView {
companion object {
fun getEndpoints(feature: Feature, examplesDir: File): List<Endpoint> {
val examples = examplesDir.getExamplesFromDir()
return feature.scenarios.map {
val example = getExistingExampleFile(it, examples)
val scenarioExPairList = getScenarioExamplesPairs(feature.scenarios, examples)
Copy link
Member

Choose a reason for hiding this comment

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

Please expand Ex to Example, will be easier to read

val example = getExistingExampleFile(it, examples)
val scenarioExPairList = getScenarioExamplesPairs(feature.scenarios, examples)

return scenarioExPairList.map { (scenario, ex) ->
Copy link
Member

Choose a reason for hiding this comment

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

same as above, expand ex to example

method = scenario.method,
responseStatus = scenario.httpResponsePattern.status,
contentType = scenario.httpRequestPattern.headersPattern.contentType,
exampleFile = ex?.first,
Copy link
Member

Choose a reason for hiding this comment

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

Can we further explode ex to exampleFile and exampleMismatchReason? so that we avoid using first and second

)
}.filterEndpoints().sortEndpoints()
Copy link
Member

Choose a reason for hiding this comment

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

any reason we stopped sorting endpoints? was this intentional?

@harikrishnan83 harikrishnan83 merged commit c4fe26d into main Oct 21, 2024
2 checks passed
@StarKhan6368 StarKhan6368 deleted the multiple_examples branch October 21, 2024 12:26
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