Skip to content

Commit

Permalink
Merge pull request #953 from geonetwork/fix-e2e-test-flaky
Browse files Browse the repository at this point in the history
Another attempt at making E2E tests more reliable
  • Loading branch information
jahow authored Jul 31, 2024
2 parents 83f4887 + e898909 commit 4e4ab1a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
27 changes: 9 additions & 18 deletions apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('dataset pages', () => {

describe('GENERAL : display & functions', () => {
describe('no-link-error block', () => {
it("shouldn't be there until metadata is fully loaded", () => {
it("shouldn't be there if there are links", () => {
cy.visit('/dataset/a3774ef6-809d-4dd1-984f-9254f49cbd0a')
cy.get('[data-test=dataset-has-no-link-block]').should('not.exist')
})
Expand Down Expand Up @@ -597,24 +597,15 @@ describe('dataset pages', () => {
})

describe('When there is no link', () => {
it('display the error datasetHasNoLink error block', () => {
cy.login()

cy.intercept(
'GET',
'/geonetwork/srv/api/userfeedback?metadataUuid=a3774ef6-809d-4dd1-984f-9254f49cbd0a',
(req) => {
// Test if the error block is not shown before the metadata is fully loaded
cy.get('[data-test="dataset-has-no-link-block"]').should(
'not.exist'
)
}
).as('getData')

beforeEach(() => {
cy.visit('/dataset/a3774ef6-809d-4dd1-984f-9254f49cbd0a')

cy.wait('@getData')

})
it('do not display the no-link-error warning initially, only after loading', () => {
// wait for metadata info to show up
cy.get('gn-ui-metadata-info').should('exist')
// first, the block is not visible
cy.get('[data-test="dataset-has-no-link-block"]').should('not.exist')
// then the block shows up
cy.get('[data-test="dataset-has-no-link-block"]').should('exist')
})
})
Expand Down
26 changes: 12 additions & 14 deletions apps/datahub-e2e/src/e2e/datasets.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('datasets', () => {

// aliases
cy.get('gn-ui-results-list-item').find('a').as('results')
cy.get('@results').first().as('firstResult')
cy.get('@results').eq(1).as('sampleResult')
cy.get('@results')
.then(($results) => $results.length)
.as('resultsCount')
Expand Down Expand Up @@ -54,12 +54,12 @@ describe('datasets', () => {
describe('display of dataset previews', () => {
it('should display a logo for first and a placeholder for second result', () => {
cy.get('@sortBy').selectDropdownOption('desc,createDate') // this makes the order reliable
cy.get('@firstResult')
cy.get('@sampleResult')
.find('gn-ui-thumbnail')
.children('div')
.invoke('attr', 'data-cy-is-placeholder')
.should('equal', 'false')
cy.get('@firstResult')
cy.get('@sampleResult')
.find('gn-ui-thumbnail')
.find('img')
.invoke('attr', 'src')
Expand All @@ -68,45 +68,45 @@ describe('datasets', () => {
'https://geocat-dev.dev.bgdi.ch/geonetwork/srv/api/records/9e1ea778-d0ce-4b49-90b7-37bc0e448300/attachments/test.png'
)
cy.get('@results')
.eq(1)
.first()
.find('gn-ui-thumbnail')
.children('div')
.invoke('attr', 'data-cy-is-placeholder')
.should('equal', 'true')
})
it('should display the title', () => {
cy.get('@firstResult')
cy.get('@sampleResult')
.find('[data-cy="recordTitle"]')
.should('be.visible')
})
it('should display the summary', () => {
cy.get('@firstResult')
cy.get('@sampleResult')
.find('[data-cy="recordAbstract"]')
.should('be.visible')
})
it('should display the organization', () => {
cy.get('@firstResult').find('[data-cy="recordOrg"]').should('be.visible')
cy.get('@sampleResult').find('[data-cy="recordOrg"]').should('be.visible')
})
it('should display the star and like count', () => {
cy.get('@firstResult').find('[data-cy="recordFav"]').should('be.visible')
cy.get('@sampleResult').find('[data-cy="recordFav"]').should('be.visible')
})
})

describe('interactions with dataset', () => {
beforeEach(() => {
cy.get('@firstResult')
cy.get('@sampleResult')
.find('gn-ui-favorite-star')
.eq(0)
.as('favoriteStar')
})
it('should open the dataset page in the same application on click', () => {
cy.get('@firstResult').click()
cy.get('@sampleResult').click()
cy.url().should('match', /^http:\/\/localhost:[0-9]+\/dataset\/.+/)
})
describe('not logged in', () => {
it('should show a popover with login link when hovering the favorite star', () => {
cy.get('@favoriteStar').trigger('mouseenter')
cy.get('[id="tippy-1"]')
cy.get('[id="tippy-2"]')
.find('a')
.invoke('attr', 'href')
.should('include', 'catalog.signin')
Expand Down Expand Up @@ -437,8 +437,6 @@ describe('datasets', () => {

describe('multiple filters', () => {
beforeEach(() => {
cy.get('datahub-search-filters').scrollIntoView()

// filter by org
cy.get('@filters').eq(0).click()
getFilterOptions()
Expand Down Expand Up @@ -559,7 +557,7 @@ describe('datasets', () => {
it('should display quality widget', () => {
cy.get('@sortBy').selectDropdownOption('desc,createDate')
cy.get('gn-ui-progress-bar')
.eq(0)
.eq(1)
.should('have.attr', 'ng-reflect-value', 87)
})

Expand Down
Binary file modified support-services/docker-entrypoint-initdb.d/dump
Binary file not shown.
9 changes: 9 additions & 0 deletions support-services/docker-entrypoint.d/04-upload-thesauri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ do
echo ""
done

curl "http://$host/geonetwork/srv/fre/thesaurus?_content_type=json" \
-H 'Accept: application/json, text/plain, */*' \
-H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json, text/plain, */*' \
-H "Cookie: JSESSIONID=$jsessionid; XSRF-TOKEN=$xsrf_token" \
-H "X-XSRF-TOKEN: $xsrf_token"

echo ""
echo "Thesauri uploaded to GeoNetwork."

0 comments on commit 4e4ab1a

Please sign in to comment.