Skip to content

Commit

Permalink
ui: Review tests following to solutions navbar integration
Browse files Browse the repository at this point in the history
Refs: #3104
  • Loading branch information
JBWatenbergScality committed Feb 16, 2021
1 parent e1f2d8b commit d8bb0f7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 116 deletions.
4 changes: 2 additions & 2 deletions ui/cypress/fixtures/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url_prometheus": "/api/prometheus",
"url_grafana": "/grafana",
"url_oidc_provider": "/oidc",
"url_redirect": "/oauth2/callback",
"url_redirect": "/",
"url_doc": "/docs",
"url_alertmanager": "/api/alertmanager"
}
}
14 changes: 8 additions & 6 deletions ui/cypress/integration/e2e/common/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Given('I am logged in', () => {
cy.location('pathname').should('eq', '/oidc/auth');

//click "Login with email" button when DEX "alwaysShowLoginScreen" is true
cy.get('.theme-form-row button').click();
cy.findByText(/Log in with Email/i).click();

const email = Cypress.env('email');
const userName = Cypress.env('username');
Expand All @@ -24,7 +24,7 @@ Given('I am logged in', () => {
cy.get('button').click();

//Check if the login is successfull and we going back to the UI
cy.location('pathname').should('eq', '/oauth2/callback');
cy.location('pathname').should('eq', '/');
cy.server();
cy.route('POST', '/api/salt/login').as('saltAuthentication');
const timeOut = {
Expand All @@ -33,16 +33,18 @@ Given('I am logged in', () => {
};
cy.wait('@saltAuthentication', timeOut);

cy.get('[data-cy="user_dropdown"] .trigger > .sc-trigger-text').should(
cy.findByRole('navigation').should(
'contain',
userName,
);
});

Then('I log out', () => {
cy.get('[data-cy="user_dropdown"] .trigger > .sc-trigger-text').click();
cy.get('[data-cy="logout_button"]').click();

const userName = Cypress.env('username');
cy.findByRole('navigation').within(() => {
cy.findByText(userName).click();
cy.findByText(/log out/i).click();
})
//Check if we are redirected to the DEX login page
cy.location('pathname').should('eq', '/oidc/auth');
});
108 changes: 0 additions & 108 deletions ui/cypress/integration/navbar.spec.js

This file was deleted.

2 changes: 2 additions & 0 deletions ui/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
// -- This is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
import 'cypress-wait-until';
import '@testing-library/cypress/add-commands'


import {
EMPTY_QUERY_RANGE_RESULT,
Expand Down
10 changes: 10 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@babel/plugin-proposal-optional-chaining": "^7.2.0",
"@babel/preset-flow": "^7.0.0",
"@redux-saga/testing-utils": "^1.0.2",
"@testing-library/cypress": "^7.0.3",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",
"@testing-library/react-hooks": "^3.4.2",
Expand Down

0 comments on commit d8bb0f7

Please sign in to comment.