Copilot commented on code in PR #159:
URL: https://github.com/apache/grails-forge-ui/pull/159#discussion_r3678555408


##########
app/launch/src/components/NextSteps/__tests__/NextSteps.test.jsx:
##########
@@ -0,0 +1,23 @@
+import React from 'react'
+import { fireEvent, render, screen } from '@testing-library/react'
+import { vi } from 'vitest'
+
+import NextSteps from '../NextSteps'
+
+vi.mock('../../../state/store', () => ({
+  useStarterForm: () => ({ name: 'sample-app' }),
+}))
+
+it('shows ZIP unpack instructions without GitHub repository details', () => {
+  render(
+    <NextSteps
+      info={{ show: true, type: 'zip' }}
+      onClose={vi.fn()}
+      onStartOver={vi.fn()}
+    />
+  )
+
+  expect(screen.getByText('Unzip the archive')).toBeTruthy()
+  fireEvent.click(screen.getByRole('button', { name: 'Unix/Linux/macOS' }))
+  expect(screen.getByText('unzip sample-app.zip')).toBeTruthy()
+})

Review Comment:
   This test only validates the *nix unzip instruction. Since the UI provides a 
Windows OS option (and the component should provide a Windows unzip command), 
add an assertion that the Windows selection shows the expected command to 
prevent regressions.



##########
app/launch/src/components/NextSteps/NextSteps.jsx:
##########
@@ -25,25 +24,12 @@ const sortedOsOpts = osOpts.sort((a, b) => {
 
 const NextSteps = ({ info, theme = 'light', onClose, onStartOver }) => {
   const { name } = useStarterForm()
-  const { htmlUrl, cloneUrl } = info
   const [os, setOs] = useState(guessedOs)
 
   const unpackCommand = useMemo(() => {
-    switch (info.type.toLowerCase()) {
-      case 'clone': {
-        const all = `git clone ${cloneUrl}`
-        const cmd = { [OS_NIX]: all, [OS_WINDOWS]: all }
-        return { action: 'Clone the repo', cmd }
-      }
-      case 'zip': {
-        const nix = `unzip ${name}.zip`
-        const unzip = { [OS_NIX]: nix }
-        return { action: 'Unzip the archive', cmd: unzip }
-      }
-      default:
-        return null
-    }
-  }, [info.type, cloneUrl, name])
+    const nix = `unzip ${name}.zip`
+    return { action: 'Unzip the archive', cmd: { [OS_NIX]: nix } }
+  }, [name])

Review Comment:
   On Windows, `unpackCommand.cmd[os]` is undefined (only `OS_NIX` is 
provided), so selecting the Windows OS option renders the “Unzip the archive” 
step with no command to run/copy. Since the UI offers a Windows option, the 
unzip step should include a Windows command as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to