Skip to content

Commit

Permalink
[Backport release_3_7] [end2end]fix DOM search in cypress test (#4107)
Browse files Browse the repository at this point in the history
* [end2end] remove homepage project description hover cypress test

* [end2end] playwrigth project description test

---------

Co-authored-by: rmartin <[email protected]>
  • Loading branch information
3liz-bot and nworr authored Jan 30, 2024
1 parent 3326387 commit 21dafa6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 56 deletions.
56 changes: 0 additions & 56 deletions tests/end2end/cypress/integration/projects_homepage-ghaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,62 +3,6 @@ describe('Projects homepage', function () {
cy.visit('/index.php/view/')
})

it('should display project metadata (cold cache)', function () {
cy.get('.liz-project-title:contains("Test tags: nature, flower")')
.prev('.liz-project')
.children('.liz-project-desc').as('all-metadata')

cy.get('@all-metadata').should('not.be.visible')
cy.get('@all-metadata').parent('.liz-project').trigger('mouseover')
cy.get('@all-metadata').should('be.visible')

cy.get('@all-metadata').find('.title').should('contain.text','Test tags: nature, flower')
cy.get('@all-metadata').find('.abstract').should('contain.text','This is an abstract')
cy.get('@all-metadata').find('.keywordList').should('contain.text','nature, flower')
cy.get('@all-metadata').find('.proj').should('contain.text','EPSG:4326')
cy.get('@all-metadata').find('.bbox').should('contain.text','-1.2459627329192546, -1.0, 1.2459627329192546, 1.0')

cy.get('@all-metadata').parent('.liz-project').trigger('mouseout')
cy.get('@all-metadata').should('not.be.visible')

cy.get('.liz-project-title:contains("Tests tags: nature, tree")')
.prev('.liz-project')
.children('.liz-project-desc').as('all-metadata-tree')

cy.get('@all-metadata-tree').should('not.be.visible')
cy.get('@all-metadata-tree').parent('.liz-project').trigger('mouseover')
cy.get('@all-metadata-tree').should('be.visible')

cy.get('@all-metadata-tree').find('.title').should('contain.text','Tests tags: nature, tree')
cy.get('@all-metadata-tree').find('.abstract').should('contain.text','Tags: nature, tree')
cy.get('@all-metadata-tree').find('.keywordList').should('contain.text','nature, tree')
cy.get('@all-metadata-tree').find('.proj').should('contain.text','EPSG:4326')
cy.get('@all-metadata-tree').find('.bbox').should('contain.text','-1.2459627329192546, -1.0, 1.2459627329192546, 1.0')

cy.get('@all-metadata-tree').parent('.liz-project').trigger('mouseout')
cy.get('@all-metadata-tree').should('not.be.visible')
})

// Assert metadata are still visible when backend is hot
it('should display project metadata (hot cache)', function () {
cy.get('.liz-project-title:contains("Test tags: nature, flower")')
.prev('.liz-project')
.children('.liz-project-desc').as('all-metadata')

cy.get('@all-metadata').should('not.be.visible')
cy.get('@all-metadata').parent('.liz-project').trigger('mouseover')
cy.get('@all-metadata').should('be.visible')

cy.get('@all-metadata').find('.title').should('contain.text', 'Test tags: nature, flower')
cy.get('@all-metadata').find('.abstract').should('contain.text', 'This is an abstract')
cy.get('@all-metadata').find('.keywordList').should('contain.text', 'nature, flower')
cy.get('@all-metadata').find('.proj').should('contain.text', 'EPSG:4326')
cy.get('@all-metadata').find('.bbox').should('contain.text', '-1.2459627329192546, -1.0, 1.2459627329192546, 1.0')

cy.get('@all-metadata').parent('.liz-project').trigger('mouseout')
cy.get('@all-metadata').should('not.be.visible')
})

it('should search in title', function () {
// Check that toggle search button is in the title search state
cy.get('#toggle-search').should('contain.text', 'T')
Expand Down
66 changes: 66 additions & 0 deletions tests/end2end/playwright/project-homepage.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { test, expect } from '@playwright/test';

test.describe('Projects homepage', function () {

test.beforeEach(async ({ page }) => {
const url = '/index.php/view/';
await page.goto(url, { waitUntil: 'networkidle' });
});

test('should display project metadata (cold cache)', async function ({ page }) {



const allmetadata = page.locator('.liz-project-desc').filter({ hasText: 'Test tags: nature, flower' });
await expect(allmetadata).not.toBeVisible();

await page.getByRole('link').filter({ has: allmetadata }).hover();
await expect(allmetadata).toBeVisible();
await expect(allmetadata.locator('.title')).toContainText('Test tags: nature, flower');
await expect(allmetadata.locator('.abstract')).toContainText('This is an abstract');
await expect(allmetadata.locator('.keywordList')).toContainText('nature, flower');
await expect(allmetadata.locator('.proj')).toContainText('EPSG:4326');
await expect(allmetadata.locator('.bbox')).toContainText('-1.2459627329192546, -1.0, 1.2459627329192546, 1.0');

// hover on header
await page.locator('#headermenu').hover();
await expect(allmetadata).not.toBeVisible();

// another project
const allmetadataTree = page.locator('.liz-project-desc').filter({ hasText: 'Tests tags: nature, tree' });
await expect(allmetadataTree).not.toBeVisible();

await page.getByRole('link').filter({ has: allmetadataTree }).hover();
await expect(allmetadataTree).toBeVisible();
await expect(allmetadataTree.locator('.title')).toContainText('Tests tags: nature, tree');
await expect(allmetadataTree.locator('.abstract')).toContainText('Tags: nature, tree');
await expect(allmetadataTree.locator('.keywordList')).toContainText('nature, tree');
await expect(allmetadataTree.locator('.proj')).toContainText('EPSG:4326');
await expect(allmetadataTree.locator('.bbox')).toContainText('-1.2459627329192546, -1.0, 1.2459627329192546, 1.0');

// hover on header
await page.locator('#headermenu').hover();
await expect(allmetadataTree).not.toBeVisible();

});

test('should display project metadata (hot cache)', async function ({ page }) {


const allmetadata = page.locator('.liz-project-desc').filter({ hasText: 'Test tags: nature, flower' });
await expect(allmetadata).not.toBeVisible();

await page.getByRole('link').filter({ has: allmetadata }).hover();
await expect(allmetadata).toBeVisible();
await expect(allmetadata.locator('.title')).toContainText('Test tags: nature, flower');
await expect(allmetadata.locator('.abstract')).toContainText('This is an abstract');
await expect(allmetadata.locator('.keywordList')).toContainText('nature, flower');
await expect(allmetadata.locator('.proj')).toContainText('EPSG:4326');
await expect(allmetadata.locator('.bbox')).toContainText('-1.2459627329192546, -1.0, 1.2459627329192546, 1.0');

// hover on header
await page.locator('#headermenu').hover();
await expect(allmetadata).not.toBeVisible();

});
});

0 comments on commit 21dafa6

Please sign in to comment.