@@ -102,14 +102,32 @@ beforeEach(() => {
102
102
vi . mocked ( tasksStore ) . tasks = tasksList ;
103
103
} ) ;
104
104
105
- test ( 'model should be selected by default' , ( ) => {
105
+ test ( 'model should not be selected by default when no runtime is set' , ( ) => {
106
+ const modelsInfoList = writable < ModelInfo [ ] > ( [ dummyLlamaCppModel ] ) ;
107
+ vi . mocked ( modelsInfoStore ) . modelsInfo = modelsInfoList ;
108
+
109
+ const { container } = render ( PlaygroundCreate ) ;
110
+
111
+ // Model should not be displayed because it's filtered out when runtime is undefined
112
+ const model = within ( container ) . queryByText ( dummyLlamaCppModel . name ) ;
113
+ expect ( model ) . toBeNull ( ) ;
114
+ } ) ;
115
+
116
+ test ( 'model should be selected by default when runtime is set' , async ( ) => {
106
117
const modelsInfoList = writable < ModelInfo [ ] > ( [ dummyLlamaCppModel ] ) ;
107
118
vi . mocked ( modelsInfoStore ) . modelsInfo = modelsInfoList ;
108
119
109
120
vi . mocked ( studioClient . requestCreatePlayground ) . mockRejectedValue ( 'error creating playground' ) ;
110
121
111
122
const { container } = render ( PlaygroundCreate ) ;
112
123
124
+ // Select our runtime
125
+ const dropdown = within ( container ) . getByLabelText ( 'Select Inference Runtime' ) ;
126
+ await userEvent . click ( dropdown ) ;
127
+
128
+ const llamacppOption = within ( container ) . getByText ( InferenceType . LLAMA_CPP ) ;
129
+ await userEvent . click ( llamacppOption ) ;
130
+
113
131
const model = within ( container ) . getByText ( dummyLlamaCppModel . name ) ;
114
132
expect ( model ) . toBeInTheDocument ( ) ;
115
133
} ) ;
@@ -152,6 +170,12 @@ test('should display error message if createPlayground fails', async () => {
152
170
const errorMessage = within ( container ) . queryByLabelText ( 'Error Message Content' ) ;
153
171
expect ( errorMessage ) . not . toBeInTheDocument ( ) ;
154
172
173
+ //make sure to select model
174
+ const dropdown = within ( container ) . getByLabelText ( 'Select Model' ) ;
175
+ await userEvent . click ( dropdown ) ;
176
+ const option = within ( container ) . getByText ( dummyLlamaCppModel . name ) ;
177
+ await userEvent . click ( option ) ;
178
+
155
179
const createButton = within ( container ) . getByTitle ( 'Create playground' ) ;
156
180
await userEvent . click ( createButton ) ;
157
181
0 commit comments