From 9fdfb6619d7f89d908342a7b7245d36fdf2262e5 Mon Sep 17 00:00:00 2001 From: Tobias Kohr Date: Fri, 20 Sep 2024 18:03:27 +0200 Subject: [PATCH] test(e2e): add e2e tests --- .../src/e2e/dashboard.cy.ts | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts index 654849977..7105e28ae 100644 --- a/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts +++ b/apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts @@ -214,17 +214,35 @@ describe('dashboard', () => { }) }) describe('navigation', () => { + function checkDashboardFiltered() { + cy.get('gn-ui-autocomplete').type('Mat') + cy.get('mat-option').first().click() + cy.get('gn-ui-interactive-table') + .find('[data-cy="table-row"]') + .should('have.length', '1') + } beforeEach(() => { cy.login('admin', 'admin', false) cy.visit('/catalog/search') }) describe('search input', () => { it('should filter the dashboard based on the search input', () => { + checkDashboardFiltered() + }) + // TODO remove skip when handleItemSelection of autocomplete is handled correctly + it.skip('should navigate to list of all records and filter the dashboard based on the search input when on different page', () => { + cy.visit('/my-space/my-records') + checkDashboardFiltered() + }) + it('should clear the search input when navigating to my records', () => { cy.get('gn-ui-autocomplete').type('Mat') - cy.get('mat-option').first().click() - cy.get('gn-ui-interactive-table') - .find('[data-cy="table-row"]') - .should('have.length', '1') + cy.get('md-editor-dashboard-menu').find('a').eq(5).click() + cy.get('gn-ui-autocomplete').should('have.value', '') + }) + it('should clear the search input when navigating to my drafts', () => { + cy.get('gn-ui-autocomplete').type('Mat') + cy.get('md-editor-dashboard-menu').find('a').eq(6).click() + cy.get('gn-ui-autocomplete').should('have.value', '') }) }) describe('my records', () => { @@ -236,6 +254,31 @@ describe('dashboard', () => { .next() .should('contain', 'admin admin') }) + it('should display the correct amount of records', () => { + cy.get('md-editor-dashboard-menu').find('a').eq(5).click() + cy.get('gn-ui-results-table') + .find('[data-cy="table-row"]') + .should('have.length', '10') + }) + it('should sort the records by title', () => { + cy.get('md-editor-dashboard-menu').find('a').eq(5).click() + cy.get('gn-ui-results-table') + .find('[data-cy="table-row"]') + .first() + .invoke('text') + .then((firstRecord) => { + console.log(firstRecord) + cy.get('gn-ui-results-table') + .find('.table-header-cell') + .eq(1) + .click() + cy.get('gn-ui-results-table') + .find('[data-cy="table-row"]') + .first() + .invoke('text') + .should('not.eq', firstRecord) + }) + }) }) }) })