Page MenuHomePhabricator

Front-End unit tests: some false positives when checking the existence of components
Closed, ResolvedPublic

Description

In these tests, if I understand correctly, we don't test well the existence of components:

tests/jest/views/function/FunctionDefinition.test.js
50:		expect( wrapper.findComponent( FunctionDefinitionName ) ).toBeTruthy();
51:		expect( wrapper.findComponent( FunctionDefinitionAliases ) ).toBeTruthy();
52:		expect( wrapper.findComponent( FunctionDefinitionInputs ) ).toBeTruthy();
53:		expect( wrapper.findComponent( FunctionDefinitionOutput ) ).toBeTruthy();
54:		expect( wrapper.findComponent( FunctionDefinitionFooter ) ).toBeTruthy();

tests/jest/views/function/viewer/FunctionViewerAboutNames.test.js
40:		expect( wrapper.findComponent( FunctionViewerSidebar ) ).toBeTruthy();

tests/jest/views/function/definition/FunctionDefinitionFooter.test.js
56:		expect( wrapper.findComponent( DialogContainer ) ).toBeTruthy();

tests/jest/views/function/viewer/FunctionViewerAboutExamples.test.js
52:		expect( wrapper.findComponent( TableComponent ) ).toBeTruthy();

tests/jest/views/function/viewer/FunctionViewerAboutAliases.test.js
40:		expect( wrapper.findComponent( FunctionViewerSidebar ) ).toBeTruthy();

findComponent just returns a new wrapper, which may not hold anything. When we remove the corresponding component from the tested modules, the tests continue to pass (I checked that with FunctionDefinition.test.js).

If we want to check the existence of components, we also rather call .exists(). An example of a well written test (I checked that it gives a true positive and fails when we remove the component): https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/WikiLambda/+/9cc8307777d1cf85783d0ff09d916146bac1e191/tests/jest/views/function/FunctionDetails.test.js#103

However, when I attempt to add a .exists() to the false positive tests, the test fails.

Event Timeline

Change 828901 had a related patch set uploaded (by Teleosteen; author: Teleosteen):

[mediawiki/extensions/WikiLambda@master] Fix false positives when checking the existence of components

https://gerrit.wikimedia.org/r/828901

Change 828901 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Fix false positives when checking the existence of components

https://gerrit.wikimedia.org/r/828901