From 45f42075373a8aaabf3be07b409dd53b0b960fcc Mon Sep 17 00:00:00 2001 From: MateuszMichalowski <79852198+MateuszMichalowski@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:00:08 +0200 Subject: [PATCH] build(frontend): merged code from master (#3367) * fix * fix test * update docker compose call * update e2e test * change docker-compose to docker compose in all workflows * use mariadb container with enabled external_network * add sleep to test_database * add maybe new parameter --service-ports needed for docker compose run else there weren't any open ports * try another approach * save change (._.); * fix(frontend): fix e2e setup & add additional check in validation rules. * fix(frontend): fix e2e setup --------- Co-authored-by: einhornimmond Co-authored-by: einhornimmond --- .github/workflows/test_database.yml | 6 +- .github/workflows/test_dht_node.yml | 4 +- .github/workflows/test_dlt_connector.yml | 2 +- .github/workflows/test_federation.yml | 4 +- admin/src/graphql/updateContributionLink.js | 3 - docker-compose.apple-m1.override.yml | 2 - docker-compose.override.yml | 2 - docker-compose.reset.yml | 70 +++++++++++++++++++ docker-compose.test.yml | 2 - docker-compose.yml | 4 +- e2e-tests/.nvmrc | 1 + e2e-tests/cypress/e2e/models/Toasts.ts | 6 +- .../user_authentication_steps.ts | 1 + .../user_profile_change_password_steps.ts | 1 - frontend/src/validation-rules.js | 29 ++++---- 15 files changed, 100 insertions(+), 37 deletions(-) create mode 100644 docker-compose.reset.yml create mode 100644 e2e-tests/.nvmrc diff --git a/.github/workflows/test_database.yml b/.github/workflows/test_database.yml index 1dba8999e..6f0c1d760 100644 --- a/.github/workflows/test_database.yml +++ b/.github/workflows/test_database.yml @@ -43,13 +43,13 @@ jobs: uses: actions/checkout@v3 - name: Database | docker-compose - run: docker compose -f docker-compose.yml up --detach mariadb + run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach mariadb - name: Database | up - run: docker compose -f docker-compose.yml run -T database yarn up + run: docker compose -f docker-compose.yml up --no-deps database - name: Database | reset - run: docker compose -f docker-compose.yml run -T database yarn reset + run: docker compose -f docker-compose.yml -f docker-compose.reset.yml up --no-deps database lint: if: needs.files-changed.outputs.database == 'true' diff --git a/.github/workflows/test_dht_node.yml b/.github/workflows/test_dht_node.yml index 6fd24784b..acd19bb57 100644 --- a/.github/workflows/test_dht_node.yml +++ b/.github/workflows/test_dht_node.yml @@ -71,14 +71,14 @@ jobs: - name: Load Docker Image run: docker load < /tmp/dht-node.tar - - name: docker compose mariadb + - name: docker-compose mariadb run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mariadb - name: Sleep for 30 seconds run: sleep 30s shell: bash - - name: docker compose database + - name: docker-compose database run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database - name: Sleep for 30 seconds diff --git a/.github/workflows/test_dlt_connector.yml b/.github/workflows/test_dlt_connector.yml index d831913fc..099f0dd1a 100644 --- a/.github/workflows/test_dlt_connector.yml +++ b/.github/workflows/test_dlt_connector.yml @@ -61,7 +61,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: DLT-Connector | docker compose mariadb + - name: DLT-Connector | docker-compose mariadb run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mariadb - name: Sleep for 30 seconds diff --git a/.github/workflows/test_federation.yml b/.github/workflows/test_federation.yml index 66ea5736e..3fb08ea64 100644 --- a/.github/workflows/test_federation.yml +++ b/.github/workflows/test_federation.yml @@ -70,14 +70,14 @@ jobs: - name: Load Docker Image run: docker load < /tmp/federation.tar - - name: docker compose mariadb + - name: docker-compose mariadb run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps mariadb - name: Sleep for 30 seconds run: sleep 30s shell: bash - - name: docker compose database + - name: docker-compose database run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database - name: Sleep for 30 seconds diff --git a/admin/src/graphql/updateContributionLink.js b/admin/src/graphql/updateContributionLink.js index 24824bd86..21cfd7f45 100644 --- a/admin/src/graphql/updateContributionLink.js +++ b/admin/src/graphql/updateContributionLink.js @@ -8,7 +8,6 @@ export const updateContributionLink = gql` $cycle: String! $validFrom: String $validTo: String - $maxAmountPerMonth: Decimal $maxPerCycle: Int! = 1 $id: Int! ) { @@ -19,7 +18,6 @@ export const updateContributionLink = gql` cycle: $cycle validFrom: $validFrom validTo: $validTo - maxAmountPerMonth: $maxAmountPerMonth maxPerCycle: $maxPerCycle id: $id ) { @@ -32,7 +30,6 @@ export const updateContributionLink = gql` createdAt validFrom validTo - maxAmountPerMonth cycle maxPerCycle } diff --git a/docker-compose.apple-m1.override.yml b/docker-compose.apple-m1.override.yml index 585a4555e..888bb551e 100644 --- a/docker-compose.apple-m1.override.yml +++ b/docker-compose.apple-m1.override.yml @@ -3,8 +3,6 @@ # To use it it is required to explicitly define if you want to build with it: # > docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.apple-m1.override.yml up -version: "3.4" - services: ######################################################## # FRONTEND ############################################# diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 08e02f1d7..4807a6bbf 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -1,5 +1,3 @@ -version: "3.4" - services: ######################################################## diff --git a/docker-compose.reset.yml b/docker-compose.reset.yml new file mode 100644 index 000000000..13708bdef --- /dev/null +++ b/docker-compose.reset.yml @@ -0,0 +1,70 @@ +# This file defines the production settings. It is overwritten by docker-compose.override.yml, +# which defines the development settings. The override.yml is loaded by default. Therefore it +# is required to explicitly define if you want an production build: +# > docker-compose -f docker-compose.yml up + +services: + + + + ######################################################## + # DATABASE ############################################# + ######################################################## + database: + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/database:local-production_reset + build: + context: ./database + target: production_reset + depends_on: + - mariadb + networks: + - internal-net + - external-net # this is required to fetch the packages + environment: + # Envs used in Dockerfile + # - DOCKER_WORKDIR="/app" + - BUILD_DATE + - BUILD_VERSION + - BUILD_COMMIT + - NODE_ENV="production" + - DB_HOST=mariadb + # Application only envs + #env_file: + # - ./frontend/.env + + ######################################################## + # DLT-DATABASE ############################################# + ######################################################## + dlt-database: + # name the image so that it cannot be found in a DockerHub repository, otherwise it will not be built locally from the 'dockerfile' but pulled from there + image: gradido/dlt-database:local-production_reset + build: + context: ./dlt-database + target: production_reset + depends_on: + - mariadb + networks: + - internal-net + - external-net # this is required to fetch the packages + environment: + # Envs used in Dockerfile + # - DOCKER_WORKDIR="/app" + - BUILD_DATE + - BUILD_VERSION + - BUILD_COMMIT + - NODE_ENV="production" + - DB_HOST=mariadb + # Application only envs + #env_file: + # - ./frontend/.env + + +networks: + external-net: + internal-net: + internal: true + +volumes: + db_vol: + diff --git a/docker-compose.test.yml b/docker-compose.test.yml index a0562adf8..6b6b2c04f 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -1,5 +1,3 @@ -version: "3.4" - services: ######################################################## # FRONTEND ############################################# diff --git a/docker-compose.yml b/docker-compose.yml index 4243956c4..76243a98a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,6 @@ # is required to explicitly define if you want an production build: # > docker-compose -f docker-compose.yml up -version: "3.4" - services: ######################################################## @@ -67,7 +65,7 @@ services: context: ./mariadb target: mariadb_server environment: - - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 + - MARIADB_ALLOW_EMPTY_PASSWORD=1 - MARIADB_USER=root networks: - internal-net diff --git a/e2e-tests/.nvmrc b/e2e-tests/.nvmrc new file mode 100644 index 000000000..9dfdb2923 --- /dev/null +++ b/e2e-tests/.nvmrc @@ -0,0 +1 @@ +v19.5.0 \ No newline at end of file diff --git a/e2e-tests/cypress/e2e/models/Toasts.ts b/e2e-tests/cypress/e2e/models/Toasts.ts index efd5052fb..091d1ca19 100644 --- a/e2e-tests/cypress/e2e/models/Toasts.ts +++ b/e2e-tests/cypress/e2e/models/Toasts.ts @@ -2,9 +2,9 @@ export class Toasts { // selectors - toastSlot = '.b-toaster-slot' - toastTypeSuccess = '.b-toast-success' - toastTypeError = '.b-toast-danger' + toastSlot = '#__BVID__toaster-container' + toastTypeSuccess = '.toast.text-bg-success' + toastTypeError = '.toast.text-bg-danger' toastTitle = '.gdd-toaster-title' toastMessage = '.gdd-toaster-body' } diff --git a/e2e-tests/cypress/support/step_definitions/user_authentication_steps.ts b/e2e-tests/cypress/support/step_definitions/user_authentication_steps.ts index 4b3b9cf16..f700be692 100644 --- a/e2e-tests/cypress/support/step_definitions/user_authentication_steps.ts +++ b/e2e-tests/cypress/support/step_definitions/user_authentication_steps.ts @@ -42,6 +42,7 @@ When('the user enters the e-mail address {string}', (email: string) => { When('the user submits the e-mail form', () => { forgotPasswordPage.submitEmail() + cy.get(forgotPasswordPage.successComponent).debug() cy.get(forgotPasswordPage.successComponent).should('be.visible') }) diff --git a/e2e-tests/cypress/support/step_definitions/user_profile_change_password_steps.ts b/e2e-tests/cypress/support/step_definitions/user_profile_change_password_steps.ts index 84ffe46c6..0dc233a87 100644 --- a/e2e-tests/cypress/support/step_definitions/user_profile_change_password_steps.ts +++ b/e2e-tests/cypress/support/step_definitions/user_profile_change_password_steps.ts @@ -7,7 +7,6 @@ const profilePage = new ProfilePage() When('the user opens the change password menu', () => { cy.get(profilePage.openChangePassword).click() cy.get(profilePage.newPasswordRepeatInput).should('be.visible') - cy.get(profilePage.submitNewPasswordBtn).should('have.class','btn-light') }) When('the user fills the password form with:', (table: DataTable) => { diff --git a/frontend/src/validation-rules.js b/frontend/src/validation-rules.js index 6a15aa67b..793929b3e 100644 --- a/frontend/src/validation-rules.js +++ b/frontend/src/validation-rules.js @@ -71,27 +71,33 @@ export const loadAllRules = (i18nCallback, apollo) => { }) defineRule('containsLowercaseCharacter', (value) => { - return !!value.match(/[a-z]+/) || i18nCallback.t('site.signup.lowercase') + const isMatch = value && !!value.match(/[a-z]+/) + return isMatch || i18nCallback.t('site.signup.lowercase') }) defineRule('containsUppercaseCharacter', (value) => { - return !!value.match(/[A-Z]+/) || i18nCallback.t('site.signup.uppercase') + const isMatch = value && !!value.match(/[A-Z]+/) + return isMatch || i18nCallback.t('site.signup.uppercase') }) defineRule('containsNumericCharacter', (value) => { - return !!value.match(/[0-9]+/) || i18nCallback.t('site.signup.one_number') + const isMatch = value && !!value.match(/[0-9]+/) + return isMatch || i18nCallback.t('site.signup.one_number') }) defineRule('atLeastEightCharacters', (value) => { - return !!value.match(/.{8,}/) || i18nCallback.t('site.signup.minimum') + const isMatch = value && !!value.match(/.{8,}/) + return isMatch || i18nCallback.t('site.signup.minimum') }) defineRule('atLeastOneSpecialCharacter', (value) => { - return !!value.match(/[^a-zA-Z0-9 \t\n\r]/) || i18nCallback.t('site.signup.special-char') + const isMatch = value && !!value.match(/[^a-zA-Z0-9 \t\n\r]/) + return isMatch || i18nCallback.t('site.signup.special-char') }) defineRule('noWhitespaceCharacters', (value) => { - return !value.match(/[ \t\n\r]+/) || i18nCallback.t('site.signup.no-whitespace') + const isMatch = value && !value.match(/[ \t\n\r]+/) + return isMatch || i18nCallback.t('site.signup.no-whitespace') }) defineRule('samePassword', (value, [pwd], ctx) => { @@ -99,16 +105,13 @@ export const loadAllRules = (i18nCallback, apollo) => { }) defineRule('usernameAllowedChars', (value) => { - return ( - !!value.match(/^[a-zA-Z0-9_-]+$/) || i18nCallback.t('form.validation.username-allowed-chars') - ) + const isMatch = value && !!value.match(/^[a-zA-Z0-9_-]+$/) + return isMatch || i18nCallback.t('form.validation.username-allowed-chars') }) defineRule('usernameHyphens', (value) => { - return ( - !!value.match(/^[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9]+?)*$/) || - i18nCallback.t('form.validation.username-hyphens') - ) + const isMatch = value && !!value.match(/^[a-zA-Z0-9]+(?:[_-][a-zA-Z0-9]+?)*$/) + return isMatch || i18nCallback.t('form.validation.username-hyphens') }) defineRule('usernameUnique', async (value) => {