JonasPammer commented on issue #132:
URL: https://github.com/apache/grails-geb/issues/132#issuecomment-2817047697

   ok: (DownloadSupportSpec should be able to use download methods)
   
   
![Image](https://github.com/user-attachments/assets/5da43396-aef3-4f99-80ce-b7a0c2b6c266)
   
   nok: (download @ href)
   
   
![Image](https://github.com/user-attachments/assets/fbe3a516-2b6d-4591-b2da-2ba7ace0ee2f)
   
   
![Image](https://github.com/user-attachments/assets/b65eb621-d8f5-4284-bddd-d3179ec78e05)
   
   because it uses uri
   
   
![Image](https://github.com/user-attachments/assets/914ee859-8a75-4164-9644-21e265d9ca78)
   
   proof of concept patch:
   
   ```patch
   diff --git 
i/spock-container-test-app/grails-app/controllers/org/demo/spock/UploadController.groovy
 
w/spock-container-test-app/grails-app/controllers/org/demo/spock/UploadController.groovy
   index 9f9a19c..1d56e1c 100644
   --- 
i/spock-container-test-app/grails-app/controllers/org/demo/spock/UploadController.groovy
   +++ 
w/spock-container-test-app/grails-app/controllers/org/demo/spock/UploadController.groovy
   @@ -1,5 +1,7 @@
    package org.demo.spock
    
   +import org.springframework.http.MediaType
   +
    import java.nio.charset.StandardCharsets
    
    class UploadController {
   @@ -19,4 +21,10 @@ class UploadController {
            }
            render(view: 'store', model: [text: text])
        }
   +    
   +    def download(){
   +        response.setContentType(MediaType.TEXT_PLAIN_VALUE)
   +        response.setHeader("Content-disposition", 
"attachment;filename=\"test.txt\"")
   +        response.outputStream << "hello".getBytes(StandardCharsets.UTF_8)
   +    }
    }
   \ No newline at end of file
   diff --git i/spock-container-test-app/grails-app/views/upload/index.gsp 
w/spock-container-test-app/grails-app/views/upload/index.gsp
   index 148474e..f3d13ad 100644
   --- i/spock-container-test-app/grails-app/views/upload/index.gsp
   +++ w/spock-container-test-app/grails-app/views/upload/index.gsp
   @@ -4,6 +4,7 @@
        <title>Upload Test</title>
    </head>
    <body>
   +<a id="download" href="/upload/download">Download</a>
    <g:uploadForm action="store">
        <input type="file" name="myFile">
        <input type="submit" value="Upload File">
   diff --git 
i/spock-container-test-app/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
 
w/spock-container-test-app/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
   index 0244a14..c39805e 100644
   --- 
i/spock-container-test-app/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
   +++ 
w/spock-container-test-app/src/integration-test/groovy/org/demo/spock/DownloadSupportSpec.groovy
   @@ -2,6 +2,7 @@ package org.demo.spock
   
    import grails.plugin.geb.ContainerGebSpec
    import grails.testing.mixin.integration.Integration
   +import org.demo.spock.pages.UploadPage
   
    @Integration
    class DownloadSupportSpec extends ContainerGebSpec {
   @@ -13,4 +14,14 @@ class DownloadSupportSpec extends ContainerGebSpec {
            then:
            downloadText().contains('Welcome to Grails')
        }
   +    void 'should be able to download href'() {
   +        setup:
   +        def page = to UploadPage
   +        
   +        when:
   +        downloadedText = downloadText(page.downloadAnchor.@href as String)
   +
   +        then:
   +        downloadedText.contains('hello')
   +    }
    }
   \ No newline at end of file
   diff --git 
i/spock-container-test-app/src/integration-test/groovy/org/demo/spock/pages/UploadPage.groovy
 
w/spock-container-test-app/src/integration-test/groovy/org/demo/spock/pages/UploadPage.groovy
   index b29bc85..76e141a 100644
   --- 
i/spock-container-test-app/src/integration-test/groovy/org/demo/spock/pages/UploadPage.groovy
   +++ 
w/spock-container-test-app/src/integration-test/groovy/org/demo/spock/pages/UploadPage.groovy
   @@ -9,6 +9,7 @@ class UploadPage extends Page {
        static at = { title == 'Upload Test' }
   
        static content = {
   +        downloadAnchor { $('a', id: 'download') }
            fileInput { $('input', name: 'myFile').module(FileInput) }
            submitBtn { $('input', type: 'submit') }
        }
   
   ```


-- 
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