-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
3,627 additions
and
1,712 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
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
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,46 @@ | ||
name: Cypress Tests | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
e2e-tests: | ||
runs-on: ubuntu-latest | ||
env: | ||
CYPRESS_COMMAND_TIMEOUT: ${{ vars.CYPRESS_COMMAND_TIMEOUT }} | ||
steps: | ||
- name: Checkout (GitHub) | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.CYPRESS_CONTAINER_REGISTRY_TOKEN }} | ||
|
||
- name: Build and run dev container task | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: ghcr.io/${{ vars.DOCKER_NAMESPACE }}/${{ vars.DEVCONTAINER_IMAGE_NAME }} | ||
cacheFrom: ghcr.io/${{ vars.DOCKER_NAMESPACE }}/${{ vars.DEVCONTAINER_IMAGE_NAME }} | ||
push: always | ||
runCmd: cd web && yarn test:e2e:ci | ||
|
||
- name: Upload Cypress videos | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cypress-videos | ||
path: web/cypress/videos/**/*.mp4 | ||
if: failure() | ||
|
||
- name: Upload Cypress screenshots | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cypress-screenshots | ||
path: web/cypress/screenshots/**/*.png | ||
if: failure() |
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
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,32 @@ | ||
# This Docker Compose file extends services from docker-compose.yaml | ||
# specifically for running end-to-end (e2e) tests. | ||
# It simplifies configuration by overriding certain values here. | ||
# | ||
# Additionally, the volume mounts defined in docker-compose.yaml | ||
# are customizable to ensure that test data is stored in docker/volumes/cypress. | ||
|
||
name: dify-cypress | ||
services: | ||
api: | ||
extends: | ||
file: docker-compose.yaml | ||
service: api | ||
ports: | ||
- 5001:5001 | ||
|
||
db: | ||
extends: | ||
file: docker-compose.yaml | ||
service: db | ||
ports: | ||
- 54321:5432 | ||
|
||
redis: | ||
extends: | ||
file: docker-compose.yaml | ||
service: redis | ||
|
||
networks: | ||
ssrf_proxy_network: | ||
driver: bridge | ||
internal: true |
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
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
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
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,54 @@ | ||
import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor' | ||
import { createEsbuildPlugin } from '@badeball/cypress-cucumber-preprocessor/esbuild' | ||
import createBundler from '@bahmutov/cypress-esbuild-preprocessor' | ||
import { defineConfig } from 'cypress' | ||
import { PostgresClient } from './cypress/support/db' | ||
|
||
export default defineConfig({ | ||
e2e: { | ||
baseUrl: 'http://localhost:3000', | ||
specPattern: '**/*.feature', | ||
video: true, | ||
env: { | ||
SLOW_DOWN: false, | ||
}, | ||
// it might take a while for nextjs to compile the page on first visit | ||
defaultCommandTimeout: Number(process.env.CYPRESS_COMMAND_TIMEOUT) || 10000, | ||
async setupNodeEvents( | ||
on: Cypress.PluginEvents, | ||
config: Cypress.PluginConfigOptions, | ||
): Promise<Cypress.PluginConfigOptions> { | ||
await addCucumberPreprocessorPlugin(on, config) | ||
|
||
on( | ||
'file:preprocessor', | ||
createBundler({ | ||
plugins: [createEsbuildPlugin(config)], | ||
}), | ||
) | ||
|
||
const dbInstance = new PostgresClient() | ||
|
||
on('task', { | ||
runQuery: async ({ query, params }: { query: string; params?: any[] }) => { | ||
// This will only create a new connection if it's not already connected | ||
await dbInstance.connect({ | ||
user: 'postgres', | ||
host: 'localhost', | ||
database: 'dify', | ||
password: 'difyai123456', | ||
port: 54321, | ||
}) | ||
return dbInstance.query(query, params) | ||
}, | ||
}) | ||
|
||
on('after:run', async () => { | ||
// This will be called once after all tests | ||
await dbInstance.close() | ||
}) | ||
|
||
return config | ||
}, | ||
}, | ||
}) |
Oops, something went wrong.