1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-31 01:16:01 +02:00

feat: run cypress against current branch (#9793)

## About the changes
Currently, we're running against the older version of our UI. When
making changes to it we want to make sure we're testing the current code

**Details in comments**

---------

Co-authored-by: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com>
This commit is contained in:
Gastón Fournier 2025-04-22 11:58:22 +02:00 committed by GitHub
parent 18850a5156
commit a88e781391
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 10 deletions

View File

@ -14,15 +14,27 @@
services:
# The Unleash server contains the Unleash configuration and
# communicates with server-side SDKs and the Unleash Proxy
unleash:
image: 726824350591.dkr.ecr.eu-central-1.amazonaws.com/unleash-enterprise:latest
pull_policy: "always"
frontend:
image: node:alpine
working_dir: /app
command: npx http-server ./build -p 80 --cors --proxy http://unleash:4242
ports:
- "4242:4242"
- "3000:80"
volumes:
- ../frontend/build:/app:ro
depends_on:
unleash:
condition: service_healthy
unleash:
image: unleashorg/unleash-enterprise:latest
pull_policy: "always"
expose:
- "4242"
environment:
DATABASE_URL: "postgres://postgres:unleash@db/unleash"
DATABASE_SSL: "false"
UNLEASH_LICENSE: "${FRONTEND_TEST_LICENSE}"
LOG_LEVEL: "info"
depends_on:
db:
condition: service_healthy

View File

@ -22,9 +22,13 @@ jobs:
echo "$GITHUB_CONTEXT"
- name: Checkout
uses: actions/checkout@v4
- name: Build static frontend
run: |
cd frontend
yarn install --immutable
yarn build
- name: Start Unleash test instance
run: |
curl https://app.unleash-hosted.com/docker-login/token/${{ secrets.ECR_ENTERPRISE_TOKEN }} | docker login --username AWS --password-stdin 726824350591.dkr.ecr.eu-central-1.amazonaws.com
docker compose -f .github/docker-compose.test.yml up -d --wait -t 90
env:
FRONTEND_TEST_LICENSE: ${{ secrets.FRONTEND_TEST_LICENSE }}
@ -33,6 +37,6 @@ jobs:
with:
working-directory: frontend
env: AUTH_USER=admin,AUTH_PASSWORD=unleash4all
config: baseUrl=http://localhost:4242
config: baseUrl=http://localhost:3000
spec: cypress/integration/${{ matrix.test }}
install-command: yarn --immutable

View File

@ -17,7 +17,6 @@
"start:sandbox": "UNLEASH_API=https://sandbox.getunleash.io/ VITE_TEST_REDIRECT=true UNLEASH_BASE_PATH=/pro/ yarn run start",
"start:sandbox:enterprise": "UNLEASH_API=https://sandbox.getunleash.io/ VITE_TEST_REDIRECT=true UNLEASH_BASE_PATH=/enterprise/ yarn run start",
"start:demo2": "UNLEASH_API=https://sandbox.getunleash.io/ UNLEASH_BASE_PATH=/demo2/ yarn run start",
"start:enterprise": "UNLEASH_API=https://unleash.herokuapp.com VITE_TEST_REDIRECT=true yarn run start",
"start:demo": "UNLEASH_BASE_PATH=/demo/ UNLEASH_API=https://app.unleash-hosted.com/ yarn run start",
"test": "NODE_OPTIONS=\"${NODE_OPTIONS:-0} --no-experimental-fetch\" vitest run",
"test:snapshot": "NODE_OPTIONS=\"${NODE_OPTIONS:-0} --no-experimental-fetch\" yarn test -u",
@ -30,7 +29,6 @@
"ts:check": "tsc",
"e2e": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --no-experimental-fetch\" yarn run cypress open --config baseUrl='http://localhost:3000' --env AUTH_USER=admin,AUTH_PASSWORD=unleash4all",
"e2e:oss": "yarn --cwd frontend run cypress run --spec \"cypress/oss/**/*.spec.ts\" --config baseUrl=\"http://localhost:${EXPOSED_PORT:-4242}\" --env AUTH_USER=admin,AUTH_PASSWORD=unleash4all",
"e2e:heroku": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --no-experimental-fetch\" yarn run cypress open --config baseUrl='https://unleash.herokuapp.com' --env AUTH_USER=admin,AUTH_PASSWORD=unleash4all",
"gen:api": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --no-experimental-fetch\" orval --config orval.config.js",
"gen:api:demo": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --no-experimental-fetch\" UNLEASH_OPENAPI_URL=https://app.unleash-hosted.com/demo/docs/openapi.json yarn run gen:api",
"gen:api:sandbox": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --no-experimental-fetch\" UNLEASH_OPENAPI_URL=https://sandbox.getunleash.io/demo2/docs/openapi.json yarn run gen:api",

View File

@ -49,7 +49,7 @@ test('rewriteHTML swaps out faviconPath if cdnPrefix is set', () => {
const result = rewriteHTML(input, '', 'https://cdn.getunleash.io/v4.1.0');
expect(
result.includes(
'<link rel="icon" href="https://cdn.getunleash.io/favicon.ico" />',
'<link rel="icon" href="https://cdn.getunleash.io/v4.1.0/favicon.ico" />',
),
).toBe(true);
});

View File

@ -9,7 +9,7 @@ export const rewriteHTML = (
result = result.replace(/::baseUriPath::/gi, rewriteValue);
result = result.replace(/::cdnPrefix::/gi, cdnPrefix || '');
const faviconPrefix = cdnPrefix ? 'https://cdn.getunleash.io' : '';
const faviconPrefix = cdnPrefix ? cdnPrefix : '';
result = result.replace(/::faviconPrefix::/gi, faviconPrefix);
result = result.replace(/::uiFlags::/gi, uiFlags || '{}');