Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v1.73] Replace default cypress env variables #376

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugin/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default defineConfig({
videosFolder: 'cypress/videos',

env: {
OC_CLUSTER_USER: 'jenkins', // default value for jenkins
OC_IDP: 'my_htpasswd_provider', // default value for jenkins, can vary based on cluster setup
USERNAME: 'jenkins', // default value for jenkins
AUTH_PROVIDER: 'my_htpasswd_provider', // default value for jenkins, can vary based on cluster setup
'cypress-react-selector': {
root: '#root'
},
Expand Down
6 changes: 3 additions & 3 deletions plugin/cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Before you start using Cypress suite, you might need export some environment var

```bash
export CYPRESS_BASE_URL=<value> # defaults to http://localhost:9000
export CYPRESS_OC_CLUSTER_USER=<value> # defaults to jenkins, opt. kubeadmin
export CYPRESS_OC_CLUSTER_PASS=<value> # no defaults
export CYPRESS_OC_IDP=<value> # defaults to my_htpasswd_provider
export CYPRESS_USERNAME=<value> # defaults to jenkins, opt. kubeadmin
export CYPRESS_PASSWD=<value> # no defaults
export CYPRESS_AUTH_PROVIDER=<value> # defaults to my_htpasswd_provider
```


Expand Down
12 changes: 6 additions & 6 deletions plugin/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ import { isLocalhost } from './utils';
declare global {
namespace Cypress {
interface Chainable {
login(OC_CLUSTER_USER: string, OC_CLUSTER_PASS: string, OC_IDP: string): Chainable<void>;
login(USERNAME: string, PASSWD: string, AUTH_PROVIDER: string): Chainable<void>;
}
}
}

Cypress.Commands.add('login', (OC_CLUSTER_USER, OC_CLUSTER_PASS, OC_IDP) => {
Cypress.Commands.add('login', (USERNAME, PASSWD, AUTH_PROVIDER) => {
// Openshift Console from localhost does not have login page
if (!isLocalhost()) {
const user = OC_CLUSTER_USER || Cypress.env('OC_CLUSTER_USER');
const password = OC_CLUSTER_PASS || Cypress.env('OC_CLUSTER_PASS');
const idp = OC_IDP || Cypress.env('OC_IDP');
const user = USERNAME || Cypress.env('USERNAME');
const password = PASSWD || Cypress.env('PASSWD');
const idp = AUTH_PROVIDER || Cypress.env('AUTH_PROVIDER');

cy.visit('/').then(() => {
cy.log('OC_IDP: ', typeof idp, JSON.stringify(idp));
cy.log('AUTH_PROVIDER: ', typeof idp, JSON.stringify(idp));
if (idp != undefined) {
cy.get('.pf-c-button').contains(idp).click();
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/cypress/support/step_definitions/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Given } from '@badeball/cypress-cucumber-preprocessor';
import { isLocalhost } from '../utils';

Given('user is logged as administrator in OCP Console', () => {
const user = Cypress.env('OC_CLUSTER_USER');
const user = Cypress.env('USERNAME');
// the two lines below can be done better, we don't need to check UI, in future we can hit API to check if user is logged in
cy.visit('/');

Expand Down