-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces explicit delegation to improve convenience and support for IDE autocompletion. The following delegates have been added: - `browser` object delegate - `page` object delegate - `report(String)` method delegate - `getPageSource()` method delegate - Refactor `ContainerAwareDownloadSupport` to a more generic support trait and move `createFileInputSource` method to it. - Move support classes to `support` package.
- Loading branch information
Showing
6 changed files
with
100 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
src/testFixtures/groovy/grails/plugin/geb/ContainerAwareDownloadSupport.groovy
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/testFixtures/groovy/grails/plugin/geb/support/ContainerSupport.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2024-2025 original author or authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package grails.plugin.geb.support | ||
|
||
import geb.download.DownloadSupport | ||
import grails.plugin.geb.ContainerGebSpec | ||
import groovy.transform.CompileStatic | ||
import groovy.transform.SelfType | ||
import org.testcontainers.images.builder.Transferable | ||
import spock.lang.Shared | ||
|
||
/** | ||
* Features for supporting Geb tests running in a container. | ||
* | ||
* @author Mattias Reichel | ||
* @since 4.1 | ||
*/ | ||
@CompileStatic | ||
@SelfType(ContainerGebSpec) | ||
trait ContainerSupport implements DownloadSupport { | ||
|
||
@Shared | ||
@Delegate | ||
static DownloadSupport downloadSupport | ||
|
||
/** | ||
* Sets the {@link DownloadSupport} instance to use for file downloads. | ||
* This allows for setting a custom implementation of {@code DownloadSupport} | ||
* when downloading from a container. | ||
* | ||
* @param downloadSupport the {@code DownloadSupport} instance to use | ||
* @since 4.1 | ||
*/ | ||
static void setDownloadSupport(DownloadSupport downloadSupport) { | ||
this.downloadSupport = downloadSupport | ||
} | ||
|
||
/** | ||
* Copies a file from the host to the container for assignment to a Geb FileInput module. | ||
* This method is useful when you need to upload a file to a form in a Geb test and will work cross-platform. | ||
* | ||
* @param hostPath relative path to the file on the host | ||
* @param containerPath absolute path to where to put the file in the container | ||
* @return the file object to assign to the FileInput module | ||
* @since 4.2 | ||
*/ | ||
File createFileInputSource(String hostPath, String containerPath) { | ||
container.copyFileToContainer(Transferable.of(new File(hostPath).bytes), containerPath) | ||
return new ContainerGebFileInputSource(containerPath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters