diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b7b786b..c959a922 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,8 @@ name: CI +env: + NODE_VERSION: 18.16.1 + on: push: branches: @@ -27,6 +30,32 @@ jobs: npx nx affected --target=test --parallel=3 --ci --code-coverage npx nx affected --target=build --parallel=3 + cypress-run: + name: End-to-end tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Checkout + uses: actions/checkout@v4 + with: + repository: geonetwork/geonetwork-ui + path: './geonetwork-ui' + - name: Build the gn-ui backend + run: sudo docker-compose -f geonetwork-ui/support-services/docker-compose.yml up -d init + + - name: Install dependencies + run: npm i + + - name: Run tests + run: npx nx e2e mel-datahub-e2e + agents: name: Nx Cloud - Agents uses: nrwl/ci/.github/workflows/nx-cloud-agents.yml@v0.13.1 diff --git a/README.md b/README.md index 11508899..9a2e5841 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,15 @@ ## Start the app -To start the development server run `nx serve datahub`. Open your browser and navigate to http://localhost:4200/. Happy coding! +To start the development server run `npm start` or `nx serve datahub`. Open your browser and navigate to http://localhost:4200/. Happy coding! + +## E2e tests + +The e2e tests can be run using the `support-services` from geonetwork-ui in the background. + +Simply run `docker compose up -d` within your checked out https://github.com/geonetwork/geonetwork-ui/tree/main/support-services folder. The CI uses the same docker backend and data. + +Then run `npm run e2e:datahub` or `npm run e2e:datahub-dev` (if you want to run and watch them in a browser). ## Generate code diff --git a/apps/datahub-e2e/project.json b/apps/datahub-e2e/project.json index a48bb0c8..4004865a 100644 --- a/apps/datahub-e2e/project.json +++ b/apps/datahub-e2e/project.json @@ -1,5 +1,5 @@ { - "name": "datahub-e2e", + "name": "mel-datahub-e2e", "$schema": "../../node_modules/nx/schemas/project-schema.json", "projectType": "application", "sourceRoot": "apps/datahub-e2e/src", @@ -9,14 +9,14 @@ "options": { "cypressConfig": "apps/datahub-e2e/cypress.config.ts", "testingType": "e2e", - "devServerTarget": "datahub:serve:development" + "devServerTarget": "mel-datahub:serve:development" }, "configurations": { "production": { - "devServerTarget": "datahub:serve:production" + "devServerTarget": "mel-datahub:serve:production" }, "ci": { - "devServerTarget": "datahub:serve-static" + "devServerTarget": "mel-datahub:serve-static" } } }, @@ -26,5 +26,5 @@ } }, "tags": [], - "implicitDependencies": ["datahub"] + "implicitDependencies": ["mel-datahub"] } diff --git a/apps/datahub-e2e/src/e2e/app.cy.ts b/apps/datahub-e2e/src/e2e/app.cy.ts deleted file mode 100644 index e42aeb70..00000000 --- a/apps/datahub-e2e/src/e2e/app.cy.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { getGreeting } from '../support/app.po'; - -describe('datahub-e2e', () => { - beforeEach(() => cy.visit('/')); - - it('should display welcome message', () => { - // Custom command example, see `../support/commands.ts` file - cy.login('my-email@something.com', 'myPassword'); - - // Function helper example, see `../support/app.po.ts` file - getGreeting().contains(/Welcome/); - }); -}); diff --git a/apps/datahub-e2e/src/e2e/home.cy.ts b/apps/datahub-e2e/src/e2e/home.cy.ts new file mode 100644 index 00000000..4a0c9464 --- /dev/null +++ b/apps/datahub-e2e/src/e2e/home.cy.ts @@ -0,0 +1,11 @@ +describe('datahub-e2e', () => { + beforeEach(() => cy.visit('/home')) + + it('should display the title', () => { + cy.get('.mel-page-title').should('be.visible') + }) + it('should display the search bar and placeholder', () => { + cy.get('gn-ui-fuzzy-search').should('be.visible') + cy.get('gn-ui-autocomplete').should('have.length.gt', 0) + }) +}) diff --git a/apps/datahub-e2e/src/e2e/search.cy.ts b/apps/datahub-e2e/src/e2e/search.cy.ts new file mode 100644 index 00000000..30b52a76 --- /dev/null +++ b/apps/datahub-e2e/src/e2e/search.cy.ts @@ -0,0 +1,20 @@ +describe('datahub-e2e', () => { + beforeEach(() => cy.visit('/search')) + + it('should display the title', () => { + cy.get('.mel-page-title').should('be.visible') + }) + it('should display the number of result hits', () => { + cy.get('gn-ui-results-hits-number').should('contain', 12) + }) + it('should display record results in preview cards', () => { + cy.get('mel-datahub-results-list-grid') + .find('mel-datahub-results-card-search') + .eq(0) + .find('h1') + .should( + 'have.text', + ' Cartographie des sols agricoles de la plaine du Rhône ' + ) + }) +}) diff --git a/apps/datahub/project.json b/apps/datahub/project.json index b6012e6d..0a8787a9 100644 --- a/apps/datahub/project.json +++ b/apps/datahub/project.json @@ -1,5 +1,5 @@ { - "name": "datahub", + "name": "mel-datahub", "$schema": "../../node_modules/nx/schemas/project-schema.json", "projectType": "application", "prefix": "mel-datahub", @@ -61,10 +61,10 @@ "executor": "@angular-devkit/build-angular:dev-server", "configurations": { "production": { - "buildTarget": "datahub:build:production" + "buildTarget": "mel-datahub:build:production" }, "development": { - "buildTarget": "datahub:build:development", + "buildTarget": "mel-datahub:build:development", "proxyConfig": "proxy-config.js" } }, @@ -73,7 +73,7 @@ "extract-i18n": { "executor": "@angular-devkit/build-angular:extract-i18n", "options": { - "buildTarget": "datahub:build" + "buildTarget": "mel-datahub:build" } }, "lint": { @@ -90,7 +90,7 @@ "serve-static": { "executor": "@nx/web:file-server", "options": { - "buildTarget": "datahub:build", + "buildTarget": "mel-datahub:build", "staticFilePath": "dist/apps/datahub/browser" } } diff --git a/package-lock.json b/package-lock.json index 08b8bfcd..889239de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16595,7 +16595,14 @@ "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", "peer": true, "engines": { - "node": ">= 10" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "node_modules/geonetwork-ui/node_modules/cliui": { @@ -16942,7 +16949,7 @@ "yallist": "^4.0.0" }, "engines": { - "node": ">=10" + "node": ">= 12.13.0" } }, "node_modules/geonetwork-ui/node_modules/magic-string": { @@ -17342,6 +17349,46 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/geonetwork-ui/node_modules/source-map-loader": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/source-map-loader/-/source-map-loader-4.0.1.tgz", + "integrity": "sha512-oqXpzDIByKONVY8g1NUPOTQhe0UTU5bWUl32GSkqK2LjJj0HmwTMVKxcUip0RgAYhY1mqgOxjbQM48a0mmeNfA==", + "peer": true, + "dependencies": { + "abab": "^2.0.6", + "iconv-lite": "^0.6.3", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": ">= 14.15.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.72.1" + } + }, + "node_modules/geonetwork-ui/node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "peer": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/geonetwork-ui/node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/geonetwork-ui/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", diff --git a/package.json b/package.json index 4a827784..362271ba 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,13 @@ "version": "0.0.0", "license": "MIT", "scripts": { - "start": "nx serve datahub", + "start": "nx serve mel-datahub", "format": "nx format:write", "format:check": "nx format:check", + "lint:all": "nx run-many --target=lint", + "e2e:all": "nx run-many --target=e2e", + "e2e:datahub": "nx e2e mel-datahub-e2e", + "e2e:datahub-dev": "nx e2e mel-datahub-e2e --watch", "i18n:extract": "ngx-translate-extract -s --fi ' ' --input ./apps --output ./apps/datahub/src/assets/i18n/{en_MEL,fr_MEL}.json --clean --format json && npm run format:write" }, "private": true,