Skip to content

Commit f189337

Browse files
fix: cypress lint fixes
1 parent f3caefd commit f189337

5 files changed

Lines changed: 67 additions & 82 deletions

File tree

web/cypress/support/commands/auth-commands.ts

Lines changed: 66 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -175,51 +175,47 @@ function performLogin(
175175
): void {
176176
cy.visit(Cypress.config('baseUrl'));
177177
cy.log('Session - after visiting');
178-
cy.window().then(
179-
(
180-
win: any, // eslint-disable-line @typescript-eslint/no-explicit-any
181-
) => {
182-
// Check if auth is disabled (for a local development environment)
183-
if (win.SERVER_FLAGS?.authDisabled) {
184-
cy.task('log', ' skipping login, console is running with auth disabled');
185-
return;
186-
}
187-
cy.exec(
188-
`oc get node --selector=hypershift.openshift.io/managed --kubeconfig ${Cypress.env(
189-
'KUBECONFIG_PATH',
190-
)}`,
191-
).then((result) => {
192-
cy.log(result.stdout);
193-
cy.task('log', result.stdout);
194-
if (result.stdout.includes('Ready')) {
195-
cy.log(`Attempting login via cy.origin to: ${oauthurl}`);
196-
cy.task('log', `Attempting login via cy.origin to: ${oauthurl}`);
197-
cy.origin(oauthurl, { args: { username, password } }, ({ username, password }) => {
178+
cy.window().then((win: any) => {
179+
// Check if auth is disabled (for a local development environment)
180+
if (win.SERVER_FLAGS?.authDisabled) {
181+
cy.task('log', ' skipping login, console is running with auth disabled');
182+
return;
183+
}
184+
cy.exec(
185+
`oc get node --selector=hypershift.openshift.io/managed --kubeconfig ${Cypress.env(
186+
'KUBECONFIG_PATH',
187+
)}`,
188+
).then((result) => {
189+
cy.log(result.stdout);
190+
cy.task('log', result.stdout);
191+
if (result.stdout.includes('Ready')) {
192+
cy.log(`Attempting login via cy.origin to: ${oauthurl}`);
193+
cy.task('log', `Attempting login via cy.origin to: ${oauthurl}`);
194+
cy.origin(oauthurl, { args: { username, password } }, ({ username, password }) => {
195+
cy.get('#inputUsername').type(username);
196+
cy.get('#inputPassword').type(password);
197+
cy.get('button[type=submit]').click();
198+
});
199+
} else {
200+
cy.task('log', ` Logging in as ${username} using fallback on ${oauthurl}`);
201+
cy.origin(
202+
oauthurl,
203+
{ args: { provider, username, password } },
204+
({ provider, username, password }) => {
205+
cy.get('[data-test-id="login"]').should('be.visible');
206+
cy.get('body').then(($body) => {
207+
if ($body.text().includes(provider)) {
208+
cy.contains(provider).should('be.visible').click();
209+
}
210+
});
198211
cy.get('#inputUsername').type(username);
199212
cy.get('#inputPassword').type(password);
200213
cy.get('button[type=submit]').click();
201-
});
202-
} else {
203-
cy.task('log', ` Logging in as ${username} using fallback on ${oauthurl}`);
204-
cy.origin(
205-
oauthurl,
206-
{ args: { provider, username, password } },
207-
({ provider, username, password }) => {
208-
cy.get('[data-test-id="login"]').should('be.visible');
209-
cy.get('body').then(($body) => {
210-
if ($body.text().includes(provider)) {
211-
cy.contains(provider).should('be.visible').click();
212-
}
213-
});
214-
cy.get('#inputUsername').type(username);
215-
cy.get('#inputPassword').type(password);
216-
cy.get('button[type=submit]').click();
217-
},
218-
);
219-
}
220-
});
221-
},
222-
);
214+
},
215+
);
216+
}
217+
});
218+
});
223219
}
224220

225221
Cypress.Commands.add('validateLogin', () => {
@@ -283,29 +279,25 @@ Cypress.Commands.add('uiLogin', (provider: string, username: string, password: s
283279
cy.log('Commands uiLogin');
284280
cy.clearCookie('openshift-session-token');
285281
cy.visit('/');
286-
cy.window().then(
287-
(
288-
win: any, // eslint-disable-line @typescript-eslint/no-explicit-any
289-
) => {
290-
if (win.SERVER_FLAGS?.authDisabled) {
291-
cy.task('log', 'Skipping login, console is running with auth disabled');
292-
return;
282+
cy.window().then((win: any) => {
283+
if (win.SERVER_FLAGS?.authDisabled) {
284+
cy.task('log', 'Skipping login, console is running with auth disabled');
285+
return;
286+
}
287+
cy.get('h1').should('have.text', 'Login');
288+
cy.get('body').then(($body) => {
289+
if ($body.text().includes(provider)) {
290+
cy.contains(provider).should('be.visible').click();
291+
} else if ($body.find('li.idp').length > 0) {
292+
//Using the last idp if doesn't provider idp name
293+
cy.get('li.idp').last().click();
293294
}
294-
cy.get('h1').should('have.text', 'Login');
295-
cy.get('body').then(($body) => {
296-
if ($body.text().includes(provider)) {
297-
cy.contains(provider).should('be.visible').click();
298-
} else if ($body.find('li.idp').length > 0) {
299-
//Using the last idp if doesn't provider idp name
300-
cy.get('li.idp').last().click();
301-
}
302-
});
303-
cy.get('#inputUsername').type(username);
304-
cy.get('#inputPassword').type(password);
305-
cy.get('button[type=submit]').click();
306-
cy.byTestID('username', { timeout: 120000 }).should('be.visible');
307-
},
308-
);
295+
});
296+
cy.get('#inputUsername').type(username);
297+
cy.get('#inputPassword').type(password);
298+
cy.get('button[type=submit]').click();
299+
cy.byTestID('username', { timeout: 120000 }).should('be.visible');
300+
});
309301
cy.switchPerspective('Administrator');
310302
});
311303

@@ -362,20 +354,16 @@ Cypress.Commands.add('relogin', (provider: string, username: string, password: s
362354
});
363355

364356
Cypress.Commands.add('uiLogout', () => {
365-
cy.window().then(
366-
(
367-
win: any, // eslint-disable-line @typescript-eslint/no-explicit-any
368-
) => {
369-
if (win.SERVER_FLAGS?.authDisabled) {
370-
cy.log('Skipping logout, console is running with auth disabled');
371-
return;
372-
}
373-
cy.log('Log out UI');
374-
cy.byTestID('username').click();
375-
cy.wait(3000);
376-
cy.byTestID('log-out').click({ force: true });
377-
},
378-
);
357+
cy.window().then((win: any) => {
358+
if (win.SERVER_FLAGS?.authDisabled) {
359+
cy.log('Skipping logout, console is running with auth disabled');
360+
return;
361+
}
362+
cy.log('Log out UI');
363+
cy.byTestID('username').click();
364+
cy.wait(3000);
365+
cy.byTestID('log-out').click({ force: true });
366+
});
379367
});
380368

381369
Cypress.Commands.add('cliLogin', (username?, password?, hostapi?) => {

web/cypress/support/commands/operator-commands.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-use-before-define */
21
import 'cypress-wait-until';
32
import { operatorAuthUtils } from './auth-commands';
43
import { cooInstallUtils } from './coo-install-commands';

web/cypress/support/commands/perses-commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare global {
4343
Cypress.Commands.add('setupPersesRBACandExtraDashboards', () => {
4444
if (
4545
`${Cypress.env('LOGIN_USERNAME1')}` !== 'kubeadmin' &&
46-
`${Cypress.env('LOGIN_USERNAME2')}` !== undefined
46+
Cypress.env('LOGIN_USERNAME2') !== undefined
4747
) {
4848
cy.exec('./cypress/fixtures/coo/coo140_perses/rbac/rbac_perses_e2e_ci_users.sh', {
4949
env: {

web/cypress/support/commands/virtualization-commands.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-use-before-define */
21
import 'cypress-wait-until';
32
import { operatorHubPage } from '../../views/operator-hub-page';
43
import { nav } from '../../views/nav';

web/cypress/support/selectors.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-use-before-define */
21
import Loggable = Cypress.Loggable;
32
import Timeoutable = Cypress.Timeoutable;
43
import Withinable = Cypress.Withinable;

0 commit comments

Comments
 (0)