Changing the AI model in the preferences does not change the text of the status bar#14053
Conversation
…tComponentTest.java Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
…tComponentTest.java Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
| when(prefs.getAiProvider()).thenAnswer(_ -> providerProp.get()); | ||
| when(prefs.getSelectedChatModel()).thenAnswer(_ -> { | ||
| return switch (providerProp.get()) { | ||
| case OPEN_AI -> | ||
| openAiModelProp.get(); | ||
| case MISTRAL_AI -> | ||
| mistralModelProp.get(); | ||
| case GEMINI -> | ||
| geminiModelProp.get(); | ||
| case HUGGING_FACE -> | ||
| hfModelProp.get(); | ||
| case GPT4ALL -> | ||
| gpt4AllModelProp.get(); | ||
| }; | ||
| }); |
There was a problem hiding this comment.
I think this is a bit nonsense. The answer of getSelectedChatModel() is ignored, instead you are looking up on a local variable providerProp, which is a few lines above set to OPEN_AI.
You could just make this a constant and abolish the switch, if i read this correctly.
| AiChatComponent component = createComponent(FXCollections.observableArrayList(), FXCollections.observableArrayList()); | ||
|
|
||
| // Change provider | ||
| prefs.aiProviderProperty().set(provider); |
| // Set the provider and the corresponding model | ||
| prefs.aiProviderProperty().set(provider); | ||
| switch (provider) { | ||
| case OPEN_AI -> | ||
| prefs.openAiChatModelProperty().set(newModel); | ||
| case MISTRAL_AI -> | ||
| prefs.mistralAiChatModelProperty().set(newModel); | ||
| case GEMINI -> | ||
| prefs.geminiChatModelProperty().set(newModel); | ||
| case HUGGING_FACE -> | ||
| prefs.huggingFaceChatModelProperty().set(newModel); | ||
| case GPT4ALL -> | ||
| prefs.gpt4AllChatModelProperty().set(newModel); | ||
| } |
There was a problem hiding this comment.
The switch is a bit useless imho, i dont see that in testing setting the model of another provider affects the tested provider. Set them up in the setup method. Then the enumsource can also be used.
There was a problem hiding this comment.
And this is the second test with little changes -

and this is an output from test -

@calixtus is it okay now or should I do any other changes because honestly I dont know what else can I do in this class, but if you have some tips how to do it better fell free to write it.
|
Ok, what i think whats causing my confusion is that the tests try to test two different things: On one hand if computeNoticeTest produces the correct text and on the other if the observables are triggering the computeNoticeTest method. |
|
@calixtus so what should i do now should i remake tests to only test that observables are triggering the computeNoticeTest method (because i think thats the main point what the output of this issue should be) or should i only test that computeNoticeTest produce the correct text or both can you please help me with this one so we can close this issue successfully? I think that we can do something like this we can create little function in test class getNoticeLabelText() which accesses the label (our notice text) via reflection |
|
ok, to move forward, we decided to merge in the state as is. |
…the status bar (JabRef#14053) * changed initializeNotice() in AiChatComponent class / now should work properly / need to add test * add test for checking if the value of ai model is changing * changed CHANGELOG.md * deleted System.out from AiChatComponent.java * some changes in CHANGELOG.md * another changes in CHANGELOG.md * updates test for AiChatComponent class * CHANGELOG.md changes * edit CHANGELOG.md * update for tests in AiChatComponentTest class / update for function computeNoticeText() in AiChatComponent class * Fix submodules * Fix submodules * Update * Update csl-locales * Update submodules * Fix submodules * Update jabgui/src/test/java/org/jabref/gui/ai/components/aichat/AiChatComponentTest.java Co-authored-by: Subhramit Basu <subhramit.bb@live.in> * Update jabgui/src/test/java/org/jabref/gui/ai/components/aichat/AiChatComponentTest.java Co-authored-by: Subhramit Basu <subhramit.bb@live.in> * Update AiChatComponentTest.java * Update AiChatComponentTest.java - make som cleanup changes --------- Co-authored-by: Subhramit Basu <subhramit.bb@live.in>






Closes #13855
Steps to test
Mandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)