github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/cypress/integration/webapp/routes.ts (about)

     1  describe('QueryParams', () => {
     2    // on smaller screens component will be collapsed by default
     3    beforeEach(() => {
     4      cy.viewport(1440, 900);
     5    });
     6  
     7    // type a tag so that it's synced to the URL
     8    // IMPORTANT! don't access the url directly since it will render this test useless
     9    // since we are testing populating the queryParams and maintaining between routes
    10    it('maintains queryParams when changing route', () => {
    11      const myTag = 'myrandomtag{}';
    12      const validate = () => {
    13        cy.location().then((loc) => {
    14          const urlParams = new URLSearchParams(loc.search);
    15          expect(urlParams.get('query')).to.eq(myTag);
    16        });
    17      };
    18  
    19      cy.visit('/');
    20      cy.get(`[aria-label="query-input"] textarea`).clear().type(myTag);
    21      cy.get(`[aria-label="query-input"] button`).click();
    22      validate();
    23  
    24      cy.findByTestId('sidebar-continuous-comparison').click();
    25      validate();
    26  
    27      cy.findByTestId('sidebar-continuous-diff').click();
    28      validate();
    29  
    30      cy.findByTestId('sidebar-continuous-single').click();
    31      validate();
    32  
    33      cy.findByTestId('sidebar-explore-page').click();
    34      validate();
    35    });
    36  });