Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another attempt at making E2E tests more reliable #953

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change supposed to be part of the PR? Not sure if it is necessary for the test or it came in by mistake.

Copy link
Collaborator Author

@jahow jahow Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes definitely, I added some more logging because I've noticed that sometimes the thesauri are not correctly present when running the e2e tests, and that would cause one of the very common failures. Having more logging will help investigating if these failures show up again.

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."
Loading