Prechádzať zdrojové kódy

fix test error and nit

CYRIL AJIEH 3 rokov pred
rodič
commit
36eed735ae

+ 7 - 8
integration-tests/support/login.ts

@@ -1,6 +1,3 @@
-import { submitButton } from '../views/form';
-import { masthead } from '../views/masthead';
-
 declare global {
   namespace Cypress {
     interface Chainable {
@@ -11,11 +8,12 @@ declare global {
 }
 
 const KUBEADMIN_USERNAME = 'kubeadmin';
-
-// any command added below, must be added to global Cypress interface above
+const loginUsername = Cypress.env('BRIDGE_KUBEADMIN_PASSWORD')
+  ? 'user-dropdown'
+  : 'username';
 
 // This will add 'cy.login(...)'
-// ex: cy.login('my-idp', 'my-user', 'my-password')
+// ex: cy.login('my-user', 'my-password')
 Cypress.Commands.add('login', (username: string, password: string) => {
   // Check if auth is disabled (for a local development environment).
   cy.visit('/'); // visits baseUrl which is set in plugins/index.js
@@ -31,8 +29,9 @@ Cypress.Commands.add('login', (username: string, password: string) => {
     cy.get('#inputPassword').type(
       password || Cypress.env('BRIDGE_KUBEADMIN_PASSWORD'),
     );
-    cy.get(submitButton).click();
-    masthead.username.shouldBeVisible();
+    cy.get('button[type=submit]').click();
+
+    cy.get(`[data-test="${loginUsername}"]`).should('be.visible');
   });
 });
 

+ 2 - 3
integration-tests/tests/example-page.cy.ts

@@ -58,6 +58,7 @@ if (!Cypress.env('OPENSHIFT_CI') || Cypress.env('PLUGIN_TEMPLATE_PULL_SPEC')) {
 
     afterEach(() => {
       checkErrors();
+      cy.logout();
     });
 
     after(() => {
@@ -69,12 +70,10 @@ if (!Cypress.env('OPENSHIFT_CI') || Cypress.env('PLUGIN_TEMPLATE_PULL_SPEC')) {
       }
     });
 
-    it('Verify the url', () => {
-      cy.url().should('include', '/example');
-    });
     it('Verify the example page title', () => {
       cy.get('[data-quickstart-id="qs-nav-home"]').click();
       cy.get('[data-test="nav"]').contains('Plugin Example').click();
+      cy.url().should('include', '/example');
       cy.get('[data-test="example-page-title"]').should(
         'contain',
         'Hello, Plugin!',

+ 0 - 1
integration-tests/views/form.ts

@@ -1 +0,0 @@
-export const submitButton = 'button[type=submit]';

+ 0 - 23
integration-tests/views/masthead.ts

@@ -1,23 +0,0 @@
-export const masthead = {
-  username: {
-    shouldBeVisible: () =>
-      cy
-        .get(
-          `[data-test=${Cypress.env(
-            'BRIDGE_KUBEADMIN_PASSWORD',
-          )} ? 'user-dropdown' : 'username'`,
-        )
-        .should('be.visible'),
-    shouldHaveText: (text: string) =>
-      cy
-        .get(
-          `[data-test=${Cypress.env(
-            'BRIDGE_KUBEADMIN_PASSWORD',
-          )} ? 'user-dropdown' : 'username'`,
-        )
-        .should('have.text', text),
-  },
-  clickMastheadLink: (path: string) => {
-    return cy.get(`[data-test=${path}`).click();
-  },
-};