Check for content before selecting namespace
describe('Namespace', () => {
beforeEach(() => {
- cy.visit('/', {
- onBeforeLoad: spyOnAddEventListener
- }).then(waitForAppStart);
+ cy.visit('/');
});
it('namespaces navigation', () => {
@@ -15,6 +13,8 @@ describe('Namespace', () => {
});
it('namespace dropdown', () => {
+ cy.get('h2').contains(/Overview/).should('be.visible');
+
cy.get('input[role="combobox"]').click();
cy.get('span[class="ng-option-label ng-star-inserted"]')
@@ -25,28 +25,3 @@ describe('Namespace', () => {
cy.location('hash').should('include', '/' + 'octant-cypress');
});
});
-
-let appHasStarted
-function spyOnAddEventListener (win) {
- const addListener = win.EventTarget.prototype.addEventListener
- win.EventTarget.prototype.addEventListener = function (name) {
- console.log('Event listener added:', name)
- if (name === 'test') {
- // that means the web application has started
- appHasStarted = true
- win.EventTarget.prototype.addEventListener = addListener
- }
- return addListener.apply(this, arguments)
- }
-}
-function waitForAppStart() {
- return new Cypress.Promise((resolve, reject) => {
- const isReady = () => {
- if (appHasStarted) {
- return resolve();
- }
- setTimeout(isReady, 0);
- }
- isReady();
- });
-};
