How to create a function on reordering the project views using Cypress automation

14 Views Asked by At

enter image description here

How can I reorder the project views using drag and drop in Cypress?

Actually on hover the list name it will display the icon to drag and drop and it will reorder based on it please help

enter image description here

In the added image the locator "ag-icon ag-icon-grip" will only display when mouseover.

I tried below function to drag and drop

ProjectviewDragAndDrop2() {
    cy.get('ag-icon ag-icon-grip').eq(5).invoke('css', 'visibility', 'visible').trigger('mouseover');
    cy.get('ag-icon ag-icon-grip').eq(5).scrollIntoView().then($element => {
      // Trigger mouse down event to start the drag
      cy.wrap($element).trigger('mousedown', { button: 0 });
    });
    cy.get('ag-icon ag-icon-grip').eq(6).invoke('css', 'visibility', 'visible').trigger('mouseover');

    // Get the target element and scroll it into view
    cy.get('ag-icon ag-icon-grip').eq(6).scrollIntoView().then($targetElement => {
      // Trigger mouse move event to move to the target element
      cy.wrap($targetElement).trigger('mousemove', { force: true });
  
    })} 
0

There are 0 best solutions below