apache / incubator-kie-issues

Apache License 2.0
12 stars 1 forks source link

Define strategy for implementing the E2E test suite for the new DMN Editor #874

Closed jomarko closed 7 months ago

jomarko commented 8 months ago

Edited: Multiple rounds of feedback incorporated.

Initial requirements:

Things we'll do that will get us there:

Structure

Test types:

NOTE: This is not black & white, though, some tests might be in a gray area between two or more types. And more types might appear as we progress.

Asserting strategy:

Remarks:

Things we won't do:


Action plan:

  1. [IN PROGRESS] Exploratory phase: phew test cases, predefined, will be used to create some ground work.
    • Creating the StoryBook and migrating the Dev Webapp there.
    • Defining basic tests for dragging nodes into the diagram and making connections between them.
  2. Expansion phase: create more tests to identify problems at a larger scale.
    • Refine our primitives, refactor the first tests, get a better sense of how things are going to look like once the test suite is bigger
    • Start integrating with the CI, improving documentation etc.
  3. Maturity phase:
    • Finish adding the initial tests we want, improve pain points and smooth edges out.
    • Ask for feedback, share the progress.
    • Document how other people on the team can use and interact with the test suites.

Next steps:

- Monitor the quality of our tests, see what is working well and what is not.
- Keep an eye on PRs to make sure everyone is adding tests when changing things.
- Help propagate the testing culture to the team, offering help and acting as owners of the test suites.
- Continuous work. It doesn't stop here.
tiagobento commented 8 months ago

@jomarko Hi! Looking good so far. A few comments from my end:

1.

I like how you defined "Goals" and "Non-goals" in the description here, it's important to know where we draw to line and stop bending and twisting to test something that should really be somewhere else. One thing I'll add to the sections you created, is that I think we would benefit a lot from separating functional from non-functional requirements. Let me explain it better.

Testing whether or not a node can be correctly dragged from the Palette to the Diagram is very close to testing whether or not the copy/paste mechanism works, but testing that nodes components are not unnecessarily re-rendered when editing the Diagram, is not. We have a lot of "unsaid" non-functional requirements for the new DMN Editor, and I think it would be great if we could map them as part of the test suite too. WDYT?

2.

Integration with External models is really complicated and needs to be thoroughly tested, and although I understand where you're coming from with saying that these tests belong on KIE Sandbox / VS Code extensions, and even agree that there should be some sort of testing for this features on their test suites, I think the DMN Editor test suite should have a lot more tests covering External models. Right now, the entire API of the DMN Editor is defined by the Props of the DmnEditor component, which include some properties related to External model integration. I.e., onRequestExternalModelByPath, onRequestExternalModelsAvailableToInclude, externalModelsByNamespace. The last one, externalModelsByNamespace, really is where the DmnEditor component gets everything it needs from External models, and there are so so many things to test, that I think we should "mock" multi-file workspaces and test them as part of the DMN Editor suite.

Note that for KIE Sandbox and VS Code Extensions, we'll also have dmn-editor-envelope at play, and it has some logic related to multi-tab editing etc, that's what's really not in scope for the DMN Editor suite, IMHO.

3.

Although I agree that we'll need some DMN files to be versioned and opened in the DMN Editor, I think we should try and aim for creating the majority of our fixtures during the tests themselves. WDYT?

4.

The "Creating custom DMN types from the java files" feature is not present on the new DMN Editor yet. See https://github.com/apache/incubator-kie-issues/issues/782

jomarko commented 8 months ago

Thank you @tiagobento let me work on second version of the strategy I think we should have for testing and I will try to incorporate your comments.

jomarko commented 8 months ago

What

We should introduce new e2e test suite for the dmn-editor module. It means we should focus on its key features, while we should not repeat the logic tested as part of other test suites.

Strategy

The most important question probably is the amount of test and the level of details we should focus on.

We should probably avoid short test scenarios like:

The reasoning behind is this:

What are then the scenarios for the end-to-end testing? We can split the scenarios into three categories.

01 Model from scratch

We live in the age of the AI, however still, some DMN models, need to be created from scratch by real human users. But from the dmn-editor test suite point of view, what such set of models is. Or let’s reword the question. What is the set of models, the dmn-editor test suite will guarantee, they can be created. Is it a set of models present:

Regardless, what the set of models we agree is needed to test, we should not try to test from scratch ‘every model from the universe’, that we want to support, because it would mean a duplication of testing the same:

We should minimize the set of tested models but trying to be sure:

We should also minimize the overlap with other test suites. For example, for modeling nodes content, i.e. expression, we should not create expression from scratch in the dmn-editor test suite. We should simplify this part using some feature like ctrl-c + ctrl-v probably. Reasoning behind this is creating expression from scratch should be part of the boxed-expression-component test suite.

02 Reusing model

Second category is a complement to the first category. Or let’s say it depends on the first category. Here users reuse logic of other models. On high level, we can say it is two phases procedure.

However, as for the first category, what are examples of such models, that we want the dmn-editor test suite will guarantee, they can be always created? Do we find them:

Regardless of the answer for the above, the situation is more complicated comparing 01, because one test now needs to operate with more models. Right now, the entire API of the DMN Editor is defined by the Props of the DmnEditor component, which include some properties related to External model integration. I.e., onRequestExternalModelByPath, onRequestExternalModelsAvailableToInclude, externalModelsByNamespace. The last one, externalModelsByNamespace, really is where the DmnEditor component gets everything it needs from External models. This should allow us to do testing of including models, as part of dmn-editor test suite, however we will be not able to avoid mocking.

That is why we need to introduce tests for including models, also into other test suites:

03 Non-Functional tests

01 and 02 are both functional tests. However wee need to test also non-functional aspects as part of the dmn-editor test suite.

Supported models

We described some models in 01 From Scratch and 02 Reusing model sections. Let’s start to call them supported models. We need to merge and optimize both sets of models from 01 and 02 and create the final set of supported models.

Consequences of supported models

Once we agree on the set of supported models, that needs to be supported by DMN editor, we need to use them as inputs for other test suites, especially for:

Then wee need to keep in mind, that any change in supported models we produce as part of dmn-editor test suite may affect other test suites and all listed test suites should be rechecked and potentially synced with the dmn-editor test suite.

Supported environments

If we speak in the context of the dmn-editor test suite, we need probably to decide what is the supported environment for the test suite? Is it probably some matrix of the [browsers] x [operating system]?

Further restrictions

Key Features

If we have a look on the key features, it is highly recommended we organize the test into two phases:

If we imagine test with steps:

The scenario above makes the test more similar to real user interaction, however makes almost impossible to maintain the test and analyze its results.

If the highlighted line with failure occurs, is that blocker for whole release? Is that some minor corner case bug? Hard to say as we mix a lot of different operations.

If we reorder the things according to the recommendation, and still testing the same model can be created:

This should be more readable and more effective form the testing time point of view as we do not switch the editor views so often.

Features that should be tested in other modules

kbowers-ibm commented 8 months ago

Thank you for creating such a thoughtful and detailed proposal Jozef, it looks great!

I agree that short test scenarios such as the ones you described are generally best avoided in such an e2e testing framework, because, as you mentioned, the functionality will be testing in more complex tests that will use that logic anyway. However the drawback then is that it could be harder to see why more complex tests are failing due to them having multiple steps and needing to debug in order to pinpoint where/why exactly it fails. The solution then as you said is to use unit tests or mocked tests, to perform these more basic tests, but should we then raise a separate ticket for the creation of such tests, or what do you think is best?

Regarding the where the models should be present for 01 Models from Scratch, and 02 Reusing Model, I think, for the sake of having a standardized practice everyone can follow, it makes the most sense to follow Luiz' example and have them inside the relevant package as part of some newly created storybook documentation.

Regarding the testing scenarios under Key Features, I think that it makes more sense to minimize the amount of times we switch views, and agree that option two would be the better test case.

ljmotta commented 7 months ago

Hey @jomarko , I've collected here all the functionalities of the DMN Editor I could think of, probably it's still missing a few things. I know we are still in the exploratory area, but I guess it can help us give north of what we will eventually cover on the tests.

functionalities

non functional