Files
grafana/e2e/various-suite/bookmarks.spec.ts
T
Hugo Häggmark 74487726fc e2e: improves flakiness and speed (#103533)
* e2e: improves flakiness

* Chore: refactor flaky test

* e2e: more refactor

* e2e: do not keep successfull test run videos

* e2e: do not log selectors

* chore: updates after pr feedback

* chore: updates after pr feedback

* chore: adds retries to flaky e2e test

* e2e: skip flaky tests

* e2e: skip flaky tests

* e2e: revert back to timeout

* chore: removes all the skips
2025-04-16 05:21:06 +01:00

76 lines
3.0 KiB
TypeScript

import { e2e } from '../utils';
import { fromBaseUrl } from '../utils/support/url';
describe('Pin nav items', () => {
beforeEach(() => {
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
});
afterEach(() => {
e2e.flows.setDefaultUserPreferences();
});
it('should pin the selected menu item and add it as a Bookmarks menu item child', () => {
cy.visit(fromBaseUrl('/'), {
onBeforeLoad: (win) => {
win.localStorage.setItem('grafana.navigation.docked', 'true'); // Make sure the menu is docked
},
});
e2e.components.NavMenu.Menu()
.should('be.visible')
.within(() => {
cy.get('ul[aria-label="Navigation"]').should('be.visible').as('navList');
// Check if the Bookmark section is visible
cy.get('@navList').children().eq(1).should('be.visible').as('bookmarksItem');
cy.get('@bookmarksItem').should('contain.text', 'Bookmarks');
// Check if the Adminstration section is visible
cy.get('@navList').children().last().should('be.visible').as('adminItem');
cy.get('@adminItem').should('contain.text', 'Administration');
cy.get('@adminItem').within(() => {
cy.get('button[aria-label="Add to Bookmarks"]').should('exist').click({ force: true });
});
// Check if the Administration menu item is visible in the Bookmarks section
cy.get('@bookmarksItem').within(() => {
// Expand the Bookmarks section
cy.get('button[aria-label="Expand section: Bookmarks"]').should('exist').click({ force: true });
cy.get('a').should('contain.text', 'Administration').should('be.visible');
});
});
});
it('should unpin the item and remove it from the Bookmarks section', () => {
// Set Administration as a pinned item and reload the page
e2e.flows.setUserPreferences({ navbar: { bookmarkUrls: ['/admin'] } });
cy.visit(fromBaseUrl('/'), {
onBeforeLoad: (win) => {
win.localStorage.setItem('grafana.navigation.docked', 'true'); // Make sure the menu is docked
},
});
e2e.components.NavMenu.Menu()
.should('be.visible')
.within(() => {
cy.get('ul[aria-label="Navigation"]').should('be.visible').as('navList');
// Check if the Bookmark section is visible
cy.get('@navList').children().eq(1).should('be.visible').as('bookmarksItem');
cy.get('@bookmarksItem').should('contain.text', 'Bookmarks');
cy.get('@bookmarksItem').within(() => {
// Expand the Bookmarks section
cy.get('button[aria-label="Expand section: Bookmarks"]').should('exist').click({ force: true });
cy.get('a').should('contain.text', 'Administration').should('be.visible');
cy.get('button[aria-label="Remove from Bookmarks"]').should('exist').click({ force: true });
});
cy.get('@bookmarksItem', { timeout: 60000 }).within(() => {
cy.get('a').should('have.length', 1).should('not.contain.text', 'Administration');
});
});
});
});