Skip to content
Snippets Groups Projects
user-journeys-logged-in.cy.ts 4.29 KiB
Newer Older
tzanmix's avatar
tzanmix committed
describe('logged user journeys', () => {
    beforeEach(() => {
        //cy.visit("http://localhost:4200/");
        cy.visit(window.location.origin);        
tzanmix's avatar
tzanmix committed
        
    });
    afterEach(() => {
      //log user out after each test
      cy.get('#navbarDropdown2').click();
      cy.get(':nth-child(2) > .dropdown > .dropdown-menu > :nth-child(8)').click();
      cy.location("pathname").should("equal", "/");
    });
tzanmix's avatar
tzanmix committed
    it('logs in through services', () => {
tzanmix's avatar
tzanmix committed
      cy.loginPath(':nth-child(2) > .container > .row > :nth-child(2) > a > .btn', '/services');
      //back on services marketplace after login
      cy.location("pathname").should("equal", "/services/services_marketplace");
      //check every 'Manage Services' dropdown item
      cy.get(':nth-child(2) > #navbarDropdown').click();
      let i=0; 
      cy.get('.show .dropdown-item').each(($el) => {
        i++;
        cy.wrap($el).click(); // Click the link
        cy.get(':nth-child(1) > .cdk-column-actions > .btn').first().click();
    
        //does the dialog open?
        cy.get('mat-dialog-container').should('exist');
        cy.go('back');
        cy.get(':nth-child(2) > #navbarDropdown').click();
tzanmix's avatar
tzanmix committed
        if(i>1) {
          return false;
tzanmix's avatar
tzanmix committed
      });
      //access the service specs dropdown
      cy.get('#navbarDropdown1').click();
      let j=0;
      for(let i=1; i<=2; i++) {
        cy.get(`.dropdown-submenu > .dropdown-menu > :nth-child(${i}) `).click();
        cy.location("pathname").should("not.equal", "/services/services_marketplace");
        cy.go('back');
        cy.get(':nth-child(2) > #navbarDropdown').click();
tzanmix's avatar
tzanmix committed
        cy.get('#navbarDropdown1').click();
      }
      //check the rest dropdown items
      cy.get(':nth-child(4) > .dropdown-item').click();
      cy.get('mat-dialog-container').should('exist');
      cy.go('back');
      cy.get(':nth-child(2) > #navbarDropdown').click();
      
      //'Manage Entities' dropdown
      cy.manageEntities(':nth-child(3) > #navbarDropdown', '.jumbotron-heading > .btn', 2, 2);
      
tzanmix's avatar
tzanmix committed
    });
tzanmix's avatar
tzanmix committed
    it('logs in through resources', () => {
      cy.loginPath(':nth-child(3) > .container > .row > .order-md-1 > a > .btn', '/resources');
      cy.location("pathname").should("equal", "/resources/resource_catalogs");
      cy.get('.text-md-right > .btn').click();
      cy.get('mat-dialog-container').should('exist');
      cy.go('back');
      cy.get('#navbarDropdown').click();
      cy.get('.show > :nth-child(2) > .dropdown-item').click();
      cy.location("pathname").should("equal", "/resources/resource_categories");
      cy.get('.text-md-right > .btn').click();
      cy.location("pathname").should("equal", "/resources/resource_categories_update");
      cy.go('back');

      cy.get('#navbarDropdown').click();
      cy.get('#navbarDropdown1').click();
      for(let i=1; i<=2; i++) {
        cy.get(`.dropdown-submenu > .dropdown-menu > :nth-child(${i}) `).click();
        cy.location("pathname").should("not.equal", "/resources/resource_categories");
        cy.go('back');
        cy.get('#navbarDropdown').click();
        cy.get('#navbarDropdown1').click();
      }

      //resource inventory
      cy.get(':nth-child(5) > .dropdown-item').click();
      cy.location("pathname").should("equal", "/resources/resource_inventory");
      cy.get('#navbarDropdown').click();

      //resource pools
      cy.get(':nth-child(7) > .dropdown-item').click();
      cy.location("pathname").should("equal", "/resources/resource_pools");
      cy.get('#navbarDropdown').click();

      //resource reservations
      cy.get(':nth-child(8) > .dropdown-item').click();
      cy.location("pathname").should("equal", "/resources/resource_reservations");

tzanmix's avatar
tzanmix committed
    });
    it('logs in through testing', () => {
      cy.loginPath(':nth-child(5) > .container > .row > .order-md-1 > a > .btn', '/testing');

      cy.manageEntities(':nth-child(1) > #navbarDropdown', '.text-md-right > .btn', 3, 2);
      cy.manageEntities(':nth-child(2) > #navbarDropdown', '.jumbotron-heading > .btn', 2, 2);
tzanmix's avatar
tzanmix committed
    });
    it('logs in through products', () => {
      cy.loginPath(':nth-child(6) > .container > .row > :nth-child(2) > a > .btn', '/products');
      cy.manageEntities(':nth-child(2) > #navbarDropdown', '.text-md-right > .btn', 2, 4);
      cy.manageEntities(':nth-child(3) > #navbarDropdown', '.jumbotron-heading > .btn', 2, 2);
tzanmix's avatar
tzanmix committed
    });
tzanmix's avatar
tzanmix committed
})