Skip to content

Commit

Permalink
Merge pull request #1475 from culturecreates/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sahalali authored Dec 2, 2024
2 parents e49c3aa + bc9c9a0 commit 62529b8
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 110 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build-production-deploy-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ jobs:
environment: 'production'
grep: ''
grepTags: '@essential'
CYPRESS_ADMIN_EN_EMAIL: ${{ vars.CYPRESS_ADMIN_EN_EMAIL }}
CYPRESS_ADMIN_FR_EMAIL: ${{ vars.CYPRESS_ADMIN_FR_EMAIL }}
CYPRESS_GUEST_EN_EMAIL: ${{ vars.CYPRESS_GUEST_EN_EMAIL }}
CYPRESS_GUEST_FR_EMAIL: ${{ vars.CYPRESS_GUEST_FR_EMAIL }}
secrets:
DOCKER_PAT: ${{ secrets.DOCKER_PAT }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/build-staging-deploy-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,7 @@ on:
branches:
- develop
jobs:
trigger-cypress-tests:
uses: ./.github/workflows/run-cypress-tests.yml
with:
environment: 'staging'
grep: ''
grepTags: '@general'
CYPRESS_ADMIN_EN_EMAIL: ${{ vars.CYPRESS_ADMIN_EN_EMAIL }}
CYPRESS_ADMIN_FR_EMAIL: ${{ vars.CYPRESS_ADMIN_FR_EMAIL }}
CYPRESS_GUEST_EN_EMAIL: ${{ vars.CYPRESS_GUEST_EN_EMAIL }}
CYPRESS_GUEST_FR_EMAIL: ${{ vars.CYPRESS_GUEST_FR_EMAIL }}
secrets:
DOCKER_PAT: ${{ secrets.DOCKER_PAT }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}

build-and-deploy:
needs: trigger-cypress-tests
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
Expand Down
76 changes: 24 additions & 52 deletions .github/workflows/run-cypress-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ on:
description: 'Grep tags for selecting tests'
required: false
default: '@essential'
CYPRESS_ADMIN_EN_EMAIL:
description: 'Admin email for English tests'
required: true
type: string
CYPRESS_ADMIN_FR_EMAIL:
description: 'Admin email for French tests'
required: true
type: string
CYPRESS_GUEST_EN_EMAIL:
description: 'Guest email for English tests'
required: true
type: string
CYPRESS_GUEST_FR_EMAIL:
description: 'Guest email for French tests'
required: true
type: string

workflow_call:
inputs:
Expand All @@ -47,22 +31,6 @@ on:
required: false
type: string
default: '@essential'
CYPRESS_ADMIN_EN_EMAIL:
description: 'Admin email for English tests'
required: true
type: string
CYPRESS_ADMIN_FR_EMAIL:
description: 'Admin email for French tests'
required: true
type: string
CYPRESS_GUEST_EN_EMAIL:
description: 'Guest email for English tests'
required: true
type: string
CYPRESS_GUEST_FR_EMAIL:
description: 'Guest email for French tests'
required: true
type: string

secrets:
DOCKER_PAT:
Expand Down Expand Up @@ -163,23 +131,31 @@ jobs:
- name: Pull cypress docker image
run: docker pull ghcr.io/kmdvs/cms-cypress_regression_tests:main

- name: Write grep and grepTags to cypress.env.json
- name: Run Cypress tests
run: |
mkdir -p cypress
cd cypress
mkdir -p logs screenshots videos
echo '{
"grep": "${{ inputs.grep }}",
"grepTags": "${{ inputs.grepTags }}"
}' > cypress.env.json
- name: Verify contents of cypress.env.json
run: |
cat cypress/cypress.env.json
grep_value="${{ inputs.grep }}"
echo "Original grep_value: '$grep_value'"
grep_value_clean=$(echo "$grep_value" | tr -d '\n\r')
echo "Cleaned grep_value: '$grep_value_clean'"
- name: Run Cypress tests
run: |
if [ -z "$grep_value_clean" ]; then
grep_value_json='""'
else
grep_value_json=$(printf '%s' "$grep_value_clean" | sed 's/"/\\"/g; s/.*/"&"/')
fi
echo "JSON grep_value: '$grep_value_json'"
# Properly format the --env argument for Cypress
env_json="{\"grepTags\":\"${{ inputs.grepTags }}\",\"grep\":${grep_value_json}}"
echo "Formatted env JSON: $env_json"
# Simulate the Cypress --env argument
env_arg=$(printf '%s' "$env_json")
echo "Simulated --env argument for Cypress: $env_arg"
# Validate JSON formatting
echo "$env_json" | jq . # Validate JSON formatting
base_url="http://test.footlight.app:3000/"
Expand All @@ -189,10 +165,7 @@ jobs:
-e DEBUG="" \
-e XDG_RUNTIME_DIR=/tmp/runtime \
-e CYPRESS_BASE_URL=$base_url \
-e CYPRESS_ADMIN_EN_EMAIL="${{ inputs.CYPRESS_ADMIN_EN_EMAIL }}" \
-e CYPRESS_ADMIN_FR_EMAIL="${{ inputs.CYPRESS_ADMIN_FR_EMAIL }}" \
-e CYPRESS_GUEST_EN_EMAIL="${{ inputs.CYPRESS_GUEST_EN_EMAIL }}" \
-e CYPRESS_GUEST_FR_EMAIL="${{ inputs.CYPRESS_GUEST_FR_EMAIL }}" \
-e CYPRESS_PRINT_LOGS_TO_CONSOLE="never" \
-e CYPRESS_ADMIN_EN_PASSWORD=${{ secrets.CYPRESS_PASSWORD }} \
-e CYPRESS_ADMIN_FR_PASSWORD=${{ secrets.CYPRESS_PASSWORD }} \
-e CYPRESS_GUEST_EN_PASSWORD=${{ secrets.CYPRESS_PASSWORD }} \
Expand All @@ -201,9 +174,8 @@ jobs:
-v ${GITHUB_WORKSPACE}/cypress/screenshots:/e2e/cypress/screenshots \
-v ${GITHUB_WORKSPACE}/cypress/videos:/e2e/cypress/videos \
-v ${GITHUB_WORKSPACE}/cypress/logs:/e2e/cypress/logs \
-v ${GITHUB_WORKSPACE}/cypress/cypress.env.json:/e2e/cypress/cypress.env.json \
ghcr.io/kmdvs/cms-cypress_regression_tests:main \
npx cypress run --browser firefox > ${GITHUB_WORKSPACE}/cypress/logs/debug-firefox.log 2>&1
npx cypress run --browser firefox --env "$env_arg"
- name: Upload Cypress Debug Logs
uses: actions/upload-artifact@v3
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/trigger-cypress-tests-on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Run regression tests on pull request to Develop

on:
pull_request:
branches:
- develop

jobs:
trigger-cypress-tests:
uses: ./.github/workflows/run-cypress-tests.yml
with:
environment: 'staging'
grep: ''
grepTags: '@general'
secrets:
DOCKER_PAT: ${{ secrets.DOCKER_PAT }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
63 changes: 26 additions & 37 deletions src/pages/Dashboard/AddEvent/AddEvent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,24 @@ function AddEvent() {
}
}
};
const mapEntities = (entities) => {
return entities
?.map((entity) => {
if (entity?.entityId) {
return {
disambiguatingDescription: entity.entity?.disambiguatingDescription,
id: entity.entityId,
name: entity.entity?.name,
type: entity.type,
logo: entity.entity?.logo,
image: entity.entity?.image?.find((image) => image?.isMain),
...(entity.entity?.contactPoint ? { contactPoint: entity.entity.contactPoint } : {}),
creator: entity.entity?.creator,
};
}
})
?.filter((mappedEntity) => mappedEntity);
};

useEffect(() => {
dispatch(clearActiveFallbackFieldsInfo());
Expand Down Expand Up @@ -1814,19 +1832,8 @@ function AddEvent() {
isDataValid(eventData?.contactPoint?.name)
)
initialAddedFields = initialAddedFields?.concat(otherInformationFieldNames?.contact);
if (eventData?.organizer) {
let initialOrganizers = eventData?.organizer?.map((organizer) => {
return {
disambiguatingDescription: organizer?.entity?.disambiguatingDescription,
id: organizer?.entityId,
name: organizer?.entity?.name,
type: organizer?.type,
logo: organizer?.entity?.logo,
image: organizer?.entity?.image?.find((image) => image?.isMain),
contactPoint: organizer?.entity?.contactPoint,
creator: organizer?.entity?.creator,
};
});
if (eventData.organizer) {
const initialOrganizers = mapEntities(eventData.organizer);
setSelectedOrganizers(
treeEntitiesOption(
initialOrganizers,
Expand All @@ -1837,18 +1844,9 @@ function AddEvent() {
),
);
}
if (eventData?.performer) {
let initialPerformers = eventData?.performer?.map((performer) => {
return {
disambiguatingDescription: performer?.entity?.disambiguatingDescription,
id: performer?.entityId,
name: performer?.entity?.name,
type: performer?.type,
logo: performer?.entity?.logo,
image: performer?.entity?.image?.find((image) => image?.isMain),
creator: performer?.entity?.creator,
};
});

if (eventData.performer) {
const initialPerformers = mapEntities(eventData.performer);
setSelectedPerformers(
treeEntitiesOption(
initialPerformers,
Expand All @@ -1860,18 +1858,9 @@ function AddEvent() {
);
initialAddedFields = initialAddedFields?.concat(otherInformationFieldNames?.performerWrap);
}
if (eventData?.collaborators) {
let initialSupporters = eventData?.collaborators?.map((supporter) => {
return {
disambiguatingDescription: supporter?.entity?.disambiguatingDescription,
id: supporter?.entityId,
name: supporter?.entity?.name,
type: supporter?.type,
logo: supporter?.entity?.logo,
image: supporter?.entity?.image?.find((image) => image?.isMain),
creator: supporter?.entity?.creator,
};
});

if (eventData.collaborators) {
const initialSupporters = mapEntities(eventData.collaborators);
setSelectedSupporters(
treeEntitiesOption(
initialSupporters,
Expand Down

0 comments on commit 62529b8

Please sign in to comment.