Skip to content

Commit

Permalink
fix(#3247): Try to remove the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tenthe committed Sep 24, 2024
1 parent d468c39 commit 38a6e4b
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions ui/cypress/tests/datalake/timeRangeSelectors.smoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,62 +44,62 @@ describe('Test Time Range Selectors in Data Explorer', () => {
before('Setup Tests', () => {
cy.initStreamPipesTest();
DataLakeUtils.loadDataIntoDataLake('datalake/sample.csv', false);
DataLakeUtils.goToDatalake();
DataLakeUtils.createAndEditDataView();
});

it('Perform Test', () => {
periods.forEach(period => {
cy.log('Testing period: ' + period.selector);
DataLakeUtils.openTimeSelectorMenu();
// Choosing time period and saving initial start and end dates
cy.dataCy(`time-selector-quick-${period.selector}`).click();
const expectedEndDate = new Date();
DataLakeUtils.openTimeSelectorMenu();
// check if dates can differ from the selected dates
const expectedStartDate = getExpectedStartDate(
expectedEndDate,
period.start,
);
cy.dataCy(dateRangeFrom).should(
'have.text',
getLocalizedDateString(expectedStartDate),
);
cy.dataCy(dateRangeTo).should(
'have.text',
getLocalizedDateString(expectedEndDate),
);
DataLakeUtils.goToDatalake();
DataLakeUtils.createAndEditDataView();

const period = periods[0];
// periods.forEach(period => {
cy.log('Testing period: ' + period.selector);
DataLakeUtils.openTimeSelectorMenu();
// Choosing time period and saving initial start and end dates
cy.dataCy(`time-selector-quick-${period.selector}`).click();
const expectedEndDate = new Date();
DataLakeUtils.openTimeSelectorMenu();
// check if dates can differ from the selected dates
const expectedStartDate = getExpectedStartDate(
expectedEndDate,
period.start,
);
cy.dataCy(dateRangeFrom).should(
'have.text',
getLocalizedDateString(expectedStartDate),
);
cy.dataCy(dateRangeTo).should(
'have.text',
getLocalizedDateString(expectedEndDate),
);

cy.dataCy(timeRangeFrom)
.invoke('val')
.then(actualTime => {
const expectedDate =
getLocalizedTimeString(expectedStartDate);
expect(
isTimeWithinTolerance(
actualTime as string,
expectedDate,
10,
),
).to.be.true;
});
cy.dataCy(timeRangeTo)
.invoke('val')
.then(actualTime => {
const expectedDate =
getLocalizedTimeString(expectedEndDate);
expect(
isTimeWithinTolerance(
actualTime as string,
expectedDate,
10,
),
).to.be.true;
});
cy.dataCy(timeRangeFrom)
.invoke('val')
.then(actualTime => {
const expectedDate = getLocalizedTimeString(expectedStartDate);
expect(
isTimeWithinTolerance(
actualTime as string,
expectedDate,
10,
),
).to.be.true;
});
cy.dataCy(timeRangeTo)
.invoke('val')
.then(actualTime => {
const expectedDate = getLocalizedTimeString(expectedEndDate);
expect(
isTimeWithinTolerance(
actualTime as string,
expectedDate,
10,
),
).to.be.true;
});

DataLakeUtils.applyCustomTimeSelection();
});
DataLakeUtils.applyCustomTimeSelection();
});
// });
});

function getExpectedStartDate(endDate: Date, startFn: (Date) => Date): Date {
Expand Down

0 comments on commit 38a6e4b

Please sign in to comment.