@@ -191,6 +191,54 @@ describe('CreateProject', () => {
191191 expect ( screen . getByPlaceholderText ( 'project-slug' ) ) . toHaveValue ( 'another' ) ;
192192 } ) ;
193193
194+ it ( 'should not overwrite a user-entered project name when the name happens to match the current platform key' , async ( ) => {
195+ // Regression test: previously, the check `projectName !== platform.key` would incorrectly
196+ // treat the name as auto-generated if it matched the current platform slug, causing a
197+ // platform switch to overwrite a name the user explicitly typed.
198+ const { organization} = initializeOrg ( {
199+ organization : {
200+ access : [ 'project:read' ] ,
201+ features : [ 'team-roles' ] ,
202+ allowMemberProjectCreation : true ,
203+ } ,
204+ } ) ;
205+
206+ render ( < CreateProject /> , { organization} ) ;
207+
208+ // User explicitly types a name that happens to match a platform id
209+ await userEvent . type ( screen . getByPlaceholderText ( 'project-slug' ) , 'apple-ios' ) ;
210+
211+ // User then selects a different platform
212+ await userEvent . click ( screen . getByTestId ( 'platform-ruby-rails' ) ) ;
213+
214+ // The name they typed should be preserved, not replaced with 'ruby-rails'
215+ expect ( screen . getByPlaceholderText ( 'project-slug' ) ) . toHaveValue ( 'apple-ios' ) ;
216+ } ) ;
217+
218+ it ( 'should allow platform to fill the project name again after the user clears it' , async ( ) => {
219+ const { organization} = initializeOrg ( {
220+ organization : {
221+ access : [ 'project:read' ] ,
222+ features : [ 'team-roles' ] ,
223+ allowMemberProjectCreation : true ,
224+ } ,
225+ } ) ;
226+
227+ render ( < CreateProject /> , { organization} ) ;
228+
229+ // User types a name
230+ await userEvent . type ( screen . getByPlaceholderText ( 'project-slug' ) , 'my-project' ) ;
231+ expect ( screen . getByPlaceholderText ( 'project-slug' ) ) . toHaveValue ( 'my-project' ) ;
232+
233+ // User clears the field (signals they want the platform to drive the name again)
234+ await userEvent . clear ( screen . getByPlaceholderText ( 'project-slug' ) ) ;
235+ expect ( screen . getByPlaceholderText ( 'project-slug' ) ) . toHaveValue ( '' ) ;
236+
237+ // Now selecting a platform should fill the name
238+ await userEvent . click ( screen . getByTestId ( 'platform-apple-ios' ) ) ;
239+ expect ( screen . getByPlaceholderText ( 'project-slug' ) ) . toHaveValue ( 'apple-ios' ) ;
240+ } ) ;
241+
194242 it ( 'should display success message on proj creation' , async ( ) => {
195243 const { organization} = initializeOrg ( {
196244 organization : {
0 commit comments