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

     1  describe('timezone', () => {
     2    describe('selector', () => {
     3      it('disabled if local time = UTC', () => {
     4        const diff = new Date().getTimezoneOffset();
     5        cy.visit('/');
     6  
     7        cy.findByTestId('time-dropdown-button').click();
     8  
     9        if (diff === 0) {
    10          cy.get('#select-timezone').should('be.disabled');
    11        } else {
    12          cy.get('#select-timezone').should('not.be.disabled');
    13        }
    14      });
    15  
    16      it('has correct values', () => {
    17        cy.visit('/');
    18  
    19        cy.findByTestId('time-dropdown-button').click();
    20  
    21        cy.get('#select-timezone')
    22          .select(0, { force: true })
    23          .should('have.value', String(new Date().getTimezoneOffset()));
    24  
    25        cy.get('#select-timezone')
    26          .select(1, { force: true })
    27          .should('have.value', '0');
    28      });
    29  
    30      it('changes what "until"-input renders on setting UTC/local time', () => {
    31        cy.visit('/');
    32        cy.findByTestId('time-dropdown-button').click();
    33        cy.get('#datepicker-until')
    34          .invoke('val')
    35          .then((value) => {
    36            const diff = new Date().getTimezoneOffset();
    37            cy.get('#select-timezone').select(1, { force: true });
    38  
    39            if (diff !== 0) {
    40              cy.get('#datepicker-until').should('not.have.value', value);
    41            } else {
    42              cy.get('#datepicker-until').should('have.value', value);
    43            }
    44  
    45            cy.get('#select-timezone').select(0, { force: true });
    46  
    47            cy.get('#datepicker-until').should('have.value', value);
    48          });
    49      });
    50    });
    51  });