Skip to content

Commit

Permalink
Merge pull request #657 from geonetwork/CI/e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Nov 15, 2023
2 parents e523bd1 + 3db4a23 commit eb6728e
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 30 deletions.
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
push:
branches:
- main
- develop
pull_request:
types: [opened, synchronize, ready_for_review]

Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: End-to-end tests
on:
push:
branches:
- main
- develop
pull_request:
types: [opened, synchronize, ready_for_review]

jobs:
cypress-run:
name: Cypress test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build the backend
run: sudo docker-compose -f support-services/docker-compose.yml up -d init

- name: install dependencies
run: |
npm ci
- name: E2E tests
run: npx nx run-many --target=e2e
3 changes: 2 additions & 1 deletion apps/datahub-e2e/src/e2e/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ describe('datasets', () => {
cy.get('@optionsLabel').should('eql', [
'Agence wallonne du Patrimoine (SPW - Territoire, Logement, Patrimoine, Énergie - Agence wallonne du Patrimoine) (1)',
'atmo Hauts-de-France (1)',
'Barbie Inc. (1)',
'Bundesamt für Raumentwicklung (1)',
"Canton du Valais - Service de l'environnement (SEN) - Protection des sols (1)",
'Cellule informatique et géomatique (SPW - Intérieur et Action sociale - Direction fonctionnelle et d’appui) (1)',
Expand All @@ -279,7 +280,7 @@ describe('datasets', () => {
'Géo2France (1)',
"Helpdesk carto du SPW (SPW - Secrétariat général - SPW Digital - Département de la Géomatique - Direction de l'Intégration des géodonnées) (2)",
'Métropole Européenne de Lille (1)',
'Région Hauts-de-France (2)',
'Région Hauts-de-France (1)',
'Service public de Wallonie (SPW) (2)',
"Société Publique de Gestion de l'Eau (SPGE) (1)",
])
Expand Down
10 changes: 5 additions & 5 deletions apps/datahub-e2e/src/e2e/organizations.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ describe('organizations', () => {
})
it('should display organization information', () => {
cy.get('@organizationsName')
.eq(2)
.eq(3)
.invoke('text')
.should('contain', 'Bundesamt für Raumentwicklung')
cy.get('@organizationsDesc')
.eq(2)
.eq(3)
.invoke('text')
.should('contain', 'Bundesamt für Raumentwicklung')
cy.get('@organizationsRecordsCount')
.eq(2)
.eq(3)
.invoke('text')
.should('contain', '1')
})
it('should display an actual logo', () => {
cy.get('@organizations')
.eq(8)
.eq(9)
.find('img')
.should('have.attr', 'src')
.and('contain', 'G%C3%A9o2France-4-3_decoupe.png')
Expand Down Expand Up @@ -124,7 +124,7 @@ describe('organizations', () => {
it('should go to next page with arrow', () => {
cy.then(() => {
cy.get('@pagination').find('[data-cy=next-page]').click()
cy.get('@organizations').should('have.length', 2)
cy.get('@organizations').should('have.length', 3)
})
})
it('should go back to the first page with arrow', () => {
Expand Down
22 changes: 13 additions & 9 deletions apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,27 @@ describe('dashboard', () => {
.then((text) => {
pageOne = text
})
cy.get('gn-ui-pagination-buttons').find('gn-ui-button').last().click()
})
//TODO remove skip when dump contains more than 15 records
it.skip('should display different results on click on specific page and change url', () => {
cy.visit('/records/search?_page=2')
cy.get('gn-ui-pagination-buttons').find('gn-ui-button').eq(1).click()
cy.get('gn-ui-record-table')
.find('.record-table-col')
.first()
.invoke('text')
.then((text) => {
expect(text).not.to.equal(pageOne)
cy.url().should('include', 'page=2')
expect(text).to.equal(pageOne)
cy.url().should('include', 'page=1')
})
})
it('should display different results on click on specific page and change url', () => {
cy.visit('/records/search?_page=2')
cy.get('gn-ui-pagination-buttons').find('gn-ui-button').eq(1).click()
cy.get('gn-ui-pagination-buttons').find('gn-ui-button').last().click()
cy.get('gn-ui-record-table')
.find('.record-table-col')
.first()
.invoke('text')
.then((text) => {
expect(text).to.equal(pageOne)
cy.url().should('include', 'page=1')
expect(text).not.to.equal(pageOne)
cy.url().should('include', 'page=2')
})
})
})
Expand All @@ -46,6 +47,9 @@ describe('dashboard', () => {
.then((list) => {
originalFirstItem = list.trim()
cy.get('.record-table-header').first().click()
// Takes time to refresh results
// eslint-disable-next-line cypress/no-unnecessary-waiting
// cy.wait(500)
cy.get('gn-ui-record-table')
.find('.record-table-col')
.first()
Expand Down
15 changes: 12 additions & 3 deletions apps/metadata-editor-e2e/src/e2e/my-org.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
describe('my-org', () => {
beforeEach(() => {
cy.loginGN('barbie', 'p4ssworD_', false)
cy.intercept({
method: 'GET',
url: 'http://localhost:4200/geonetwork/srv/api/userselections/0/101',
}).as('dataGetFirst')
cy.visit(`/records/my-org`)
cy.get('md-editor-dashboard-menu').find('a').first().click()
cy.get('main').children('div').first().children('div').eq(1).as('linkGroup')
cy.wait('@dataGetFirst').its('response.statusCode').should('equal', 200)
cy.get('main').children('div').first().as('linkGroup')
})
describe('my-org display', () => {
it('should show my-org name and logo', () => {
Expand All @@ -28,8 +33,12 @@ describe('my-org', () => {
})
describe('routing', () => {
it('should access the datahub with a filter', () => {
cy.get('@linkGroup').find('a').click()
cy.url().should('include', 'search/publisher=')
cy.get('@linkGroup')
.find('a')
.should('have.attr', 'href')
.then((href) => {
expect(href).to.include('search?publisher=Barbie+Inc')
})
})
it('should access the user list page and show my-org users', () => {
cy.visit(`/records/my-org`)
Expand Down
16 changes: 6 additions & 10 deletions apps/metadata-editor-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@ declare namespace Cypress {
Cypress.Commands.add(
'loginGN',
(username: string, password: string, redirect = true) => {
cy.visit('http://localhost:8080/geonetwork/srv/eng/catalog.search#/home')
cy.get('.cookie-warning-actions').then(($cookie) => {
if ($cookie.is(':visible')) {
$cookie.find('button').eq(0).click()
cy.scrollTo('top')
}
Cypress.on('uncaught:exception', (err) => {
if (err.message.includes('Jsonix')) return false
if (err.message.includes('postMessage')) return false
})

cy.wait(250)
cy.get('li.signin-dropdown').click()
cy.get('#inputUsername').type(username)
cy.get('#inputPassword').type(password)
cy.visit('/geonetwork/srv/eng/catalog.signin?debug') // this will point to a 404
cy.get('#inputUsername').type(username, { force: true })
cy.get('#inputPassword').type(password, { force: true })
cy.get('[name="gnSigninForm"]').submit()
if (redirect) cy.visit('/')
}
Expand Down
5 changes: 4 additions & 1 deletion apps/metadata-editor/src/app/router.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export class EditorRouterService {
}

getDatahubSearchRoute(): string {
return new URL(`${getGlobalConfig().DATAHUB_URL}/search`).toString()
return new URL(
`${getGlobalConfig().DATAHUB_URL}/search`,
window.location.toString()
).toString()
}
}
2 changes: 1 addition & 1 deletion libs/feature/catalog/src/lib/my-org/my-org.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class MyOrgService {
map(([user, allUsers, orgs]) => {
const orgName = user.organisation
const org = orgs.find((org) => org.name === orgName)
const logoUrl = org?.logoUrl?.href.toString()
const logoUrl = org?.logoUrl?.toString()
const recordCount = org?.recordCount
const userList = allUsers.filter(
(user) => user.organisation === orgName
Expand Down
Binary file modified support-services/docker-entrypoint-initdb.d/dump
Binary file not shown.

0 comments on commit eb6728e

Please sign in to comment.