Skip to content

Commit

Permalink
boCartRulesPage : Fixed filter for date
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Feb 7, 2025
1 parent d285c8f commit eca084f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ export default {
const date = this.getBaseDate(dateTime);

// Get day, month and year
const mm = (`0${date.getMonth() + 1}`).slice(-2); // Current month
const dd = (`0${date.getDate()}`).slice(-2); // Current day
const mm = (`0${date.getMonth() + 1}`).slice(-2); // Current month
const yyyy = date.getFullYear(); // Year

switch (format) {
case 'dd/mm/yyyy':
return `${dd}/${mm}/${yyyy}`;

case 'mm/dd/yyyy':
return `${mm}/${dd}/${yyyy}`;

Expand Down
19 changes: 18 additions & 1 deletion src/versions/develop/pages/BO/catalog/discounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,24 @@ class BOCartRulesPage extends BOBasePage implements BOCartRulesPageInterface {

switch (filterType) {
case 'input':
await this.setValue(page, this.filterColumn(filterBy), value);
if (['date_from', 'date_to'].includes(filterBy)) {
let filterByColumn: string = filterBy;
filterByColumn = filterBy === 'date_from' ? 'date_to[0]' : filterByColumn;
filterByColumn = filterByColumn === 'date_to' ? 'date_to[1]' : filterByColumn;

await page.evaluate((args: {inputSelector: string, inputValue: string}) => {
const inputElement = document.querySelector(args.inputSelector);

if (inputElement) {
(inputElement as HTMLInputElement).value = args.inputValue;
}
}, {
inputSelector: this.filterColumn(filterByColumn),
inputValue: value,
});
} else {
await this.setValue(page, this.filterColumn(filterBy), value);
}
await this.clickAndWaitForURL(page, this.filterSearchButton);
break;

Expand Down

0 comments on commit eca084f

Please sign in to comment.