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 19, 2021
1 parent 6cbae9d commit 29d17e3
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 119 deletions.
5 changes: 4 additions & 1 deletion eve/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,9 @@ stages:
application:
context: 'ui'
dockerfile: eve/workers/pod-integration-tests/ui/app.Dockerfile
shell-ui:
context: 'shell-ui'
dockerfile: shell-ui/Dockerfile
steps:
- Git: *git_pull
- ShellCommand:
Expand All @@ -1189,7 +1192,7 @@ stages:
name: Install Cypress and its dependencies
workdir: build/ui
command: |
PKGS="cypress cypress-cucumber-preprocessor cypress-wait-until"
PKGS="cypress cypress-cucumber-preprocessor cypress-wait-until @testing-library/cypress"
for pkg in $PKGS; do
npm install --no-save --no-package-lock $pkg@$(node -p \
-e "require('./package-lock.json').dependencies['$pkg'].version" \
Expand Down
32 changes: 30 additions & 2 deletions eve/workers/pod-integration-tests/ui/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ kind: Pod
metadata:
name: "metalk8s-integration-tests-ui"
spec:
initContainers:
- name: shell-ui
image: {{ images['shell-ui'] }}
resources:
requests:
cpu: 250m
memory: 200Mi
limits:
cpu: 350m
memory: 300Mi
command: ["/bin/sh"]
args:
- -c
- |
cp -r /usr/share/nginx/html/ /tmp/shell-ui-files
volumeMounts:
- name: shell-ui-files
mountPath: /tmp/shell-ui-files
containers:
- name: worker
image: {{ images['worker'] }}
Expand All @@ -18,6 +36,7 @@ spec:
volumeMounts:
- name: worker-workspace
mountPath: /home/eve/workspace

- name: application
image: {{ images['application'] }}
resources:
Expand All @@ -27,12 +46,21 @@ spec:
limits:
cpu: 350m
memory: 300Mi
command: ["nginx"]
args: ["-g", "daemon off;"]
command: ["/bin/sh"]
args:
- -c
- |
cp -r /tmp/shell-ui-files/ /usr/share/nginx/html/
nginx -g daemon off
ports:
- containerPort: 80
name: http
protocol: TCP
volumeMounts:
- name: shell-ui-files
mountPath: /tmp/shell-ui-files
volumes:
- name: worker-workspace
emptyDir: {}
- name: shell-ui-files
emptyDir: {}
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 @@ -75,6 +75,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 29d17e3

Please sign in to comment.