Unverified Commit 72e66943 authored by Sam Foo's avatar Sam Foo Committed by GitHub
Browse files

Merge pull request #565 from GuessWhoSamFoo/e2e-flake

Fix flaky namespace dropdown test
parents 85de2351 241e34e8
Showing with 32 additions and 2 deletions
+32 -2
describe('Namespace', () => {
beforeEach(() => {
cy.visit('/');
cy.visit('/', {
onBeforeLoad: spyOnAddEventListener
}).then(waitForAppStart);
});
it('namespaces navigation', () => {
......@@ -15,8 +17,36 @@ describe('Namespace', () => {
it('namespace dropdown', () => {
cy.get('input[role="combobox"]').click();
cy.get('[class="ng-option-label ng-star-inserted"]').contains('octant-cypress').parent().click();
cy.get('span[class="ng-option-label ng-star-inserted"]')
.contains('octant-cypress')
.parent()
.click()
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();
});
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment