diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index ce7c56b06b..73a86dab8a 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -44,7 +44,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ needs.checks.outputs.ref }} # use the PR head ref if applicable; otherwise keep default behaviour persist-credentials: false @@ -57,9 +57,7 @@ jobs: cache: 'npm' - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v2 - with: - main-branch-name: 'main' + uses: nrwl/nx-set-shas@v3 - name: Install dependencies run: npm ci diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 96aeaa13e3..c6cc169081 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: persist-credentials: false fetch-depth: 0 @@ -38,9 +38,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v2 - with: - main-branch-name: 'main' + uses: nrwl/nx-set-shas@v3 - run: npm ci - run: npx nx format:check - run: npx nx affected -t lint --parallel=3 @@ -79,7 +77,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: persist-credentials: false fetch-depth: 0 @@ -89,9 +87,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: 'npm' - name: Derive appropriate SHAs for base and head for `nx affected` commands - uses: nrwl/nx-set-shas@v2 - with: - main-branch-name: 'main' + uses: nrwl/nx-set-shas@v3 - run: npm ci - run: npx nx affected -t build --parallel=3 @@ -102,7 +98,7 @@ jobs: steps: - name: Checkout branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: persist-credentials: false fetch-depth: 0 @@ -142,13 +138,18 @@ jobs: comment_tag: build-options GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - cypress-run: - name: End-to-end tests + e2e-run: + name: End-to-end tests, GeoNetwork v${{ matrix.gn_version }} runs-on: ubuntu-latest - outputs: - screenshotsUrl: ${{ steps.upload-screenshots.outputs.artifact-url }} + strategy: + fail-fast: false + matrix: + gn_version: [4.2.2, 4.2.8, 4.4.0] steps: - uses: actions/checkout@v4 + with: + persist-credentials: false + fetch-depth: 0 - name: Use Node.js ${{ env.NODE_VERSION }} uses: actions/setup-node@v3 @@ -156,24 +157,29 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: 'npm' + - name: Derive appropriate SHAs for base and head for `nx affected` commands + uses: nrwl/nx-set-shas@v3 + - name: Create pipeline docker image - run: cd tools && docker build . -f pipelines/Dockerfile -t geonetwork/geonetwork-ui-tools-pipelines:latest + working-directory: tools + run: docker build . -f pipelines/Dockerfile -t geonetwork/geonetwork-ui-tools-pipelines:latest - - name: Build the backend - run: sudo docker-compose -f support-services/docker-compose.yml up -d init + - name: Start up backend support services + env: + GEONETWORK_VERSION: ${{ matrix.gn_version }} + working-directory: support-services + run: docker compose up --quiet-pull init - - name: Install dependencies - run: | - npm ci + - run: npm ci - - name: Run tests - run: npx nx run-many --target=e2e + - name: Run e2e tests + run: npx nx affected --target=e2e - uses: actions/upload-artifact@v4 if: always() id: upload-screenshots with: - name: cypress-screenshots + name: cypress-screenshots-gn-${{ matrix.gn_version }} path: | apps/datahub-e2e/cypress/screenshots/**/* apps/metadata-editor-e2e/cypress/screenshots/**/* @@ -193,7 +199,7 @@ jobs: steps: - name: Checkout branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: persist-credentials: false fetch-depth: 0 diff --git a/.github/workflows/snyk-security.yml b/.github/workflows/snyk-security.yml index e114be3fed..57461efd08 100644 --- a/.github/workflows/snyk-security.yml +++ b/.github/workflows/snyk-security.yml @@ -35,7 +35,7 @@ jobs: security-events: write # for github/codeql-action/upload-sarif to upload SARIF results runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run Snyk to check for vulnerabilities uses: snyk/actions/node@master diff --git a/.github/workflows/webcomponents.yml b/.github/workflows/webcomponents.yml index e090eb78bb..fbcea28878 100644 --- a/.github/workflows/webcomponents.yml +++ b/.github/workflows/webcomponents.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ needs.checks.outputs.ref }} persist-credentials: false diff --git a/apps/datahub-e2e/project.json b/apps/datahub-e2e/project.json index f188bfa518..7a3d5997a3 100644 --- a/apps/datahub-e2e/project.json +++ b/apps/datahub-e2e/project.json @@ -10,7 +10,8 @@ "cypressConfig": "apps/datahub-e2e/cypress.config.js", "devServerTarget": "datahub:serve:development", "testingType": "e2e", - "browser": "chrome" + "browser": "chrome", + "port": "cypress-auto" }, "configurations": { "production": { diff --git a/apps/metadata-editor-e2e/project.json b/apps/metadata-editor-e2e/project.json index fe64bd1e65..306cdf0d07 100644 --- a/apps/metadata-editor-e2e/project.json +++ b/apps/metadata-editor-e2e/project.json @@ -10,7 +10,8 @@ "cypressConfig": "apps/metadata-editor-e2e/cypress.config.js", "devServerTarget": "metadata-editor:serve:development", "testingType": "e2e", - "browser": "chrome" + "browser": "chrome", + "port": "cypress-auto" }, "configurations": { "production": { diff --git a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts new file mode 100644 index 0000000000..ed249ca863 --- /dev/null +++ b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts @@ -0,0 +1,60 @@ +describe('editor form', () => { + beforeEach(() => { + cy.login('admin', 'admin', false) + + // Alpine convention record + cy.visit('/edit/8698bf0b-fceb-4f0f-989b-111e7c4af0a4') + + cy.clearRecordDrafts() + + // aliases + cy.get('gn-ui-form-field[ng-reflect-model=abstract] textarea').as( + 'abstractField' + ) + cy.get('@abstractField').invoke('val').as('abstractFieldInitialValue') + cy.get('[data-cy=save-status]') + .invoke('attr', 'data-cy-value') + .as('saveStatus') + }) + + it('form shows correctly', () => { + cy.get('gn-ui-record-form').should('be.visible') + cy.get('gn-ui-record-form gn-ui-form-field').should('have.length.gt', 0) + cy.get('@abstractField') + .invoke('val') + .should('contain', 'Perimeter der Alpenkonvention in der Schweiz.') + cy.get('@saveStatus').should('eq', 'record_up_to_date') + cy.screenshot({ capture: 'fullPage' }) + }) + + it('draft record is kept', () => { + cy.get('@abstractField').clear() + cy.get('@abstractField').type('modified abstract') + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(1000) // waiting for draft saving to kick in + cy.reload() + cy.get('@abstractField').invoke('val').should('eq', 'modified abstract') + cy.get('@saveStatus').should('eq', 'draft_changes_pending') + + cy.clearRecordDrafts() + + cy.get('@saveStatus').should('eq', 'record_up_to_date') + cy.get('@abstractField') + .invoke('val') + .should('contain', 'Perimeter der Alpenkonvention in der Schweiz.') + }) + + it('saving record works', () => { + cy.get('@abstractField').clear() + cy.get('@abstractField').type('modified abstract before saving') + cy.get('md-editor-publish-button').click() + cy.get('@saveStatus').should('eq', 'record_up_to_date') + + // restore abstract + cy.get('@abstractField').clear() + cy.get('@abstractField').then(function (field) { + cy.wrap(field).type(this.abstractFieldInitialValue) + }) + cy.get('md-editor-publish-button').click() + }) +}) diff --git a/apps/metadata-editor/src/app/edit/components/top-toolbar/top-toolbar.component.html b/apps/metadata-editor/src/app/edit/components/top-toolbar/top-toolbar.component.html index 89cd41f9d4..b1f5cec581 100644 --- a/apps/metadata-editor/src/app/edit/components/top-toolbar/top-toolbar.component.html +++ b/apps/metadata-editor/src/app/edit/components/top-toolbar/top-toolbar.component.html @@ -13,6 +13,8 @@