Skip to content

Commit eea4e27

Browse files
author
André Luiz Abdalla Silveira
committed
fix(e2e): correct E2E test constants and date logic for issue listing
- Rename TEN_DAYS to ISO_DATE_LENGTH (10) for clarity - Add ONE_DAY constant for yesterday date calculation - Fix end date test to use yesterday instead of a future date - Fix table size option from '25' (non-existent) to '20' - Remove unused startValue variable in end-date test Closes #1784
1 parent 26cdbff commit eea4e27

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

dashboard/e2e/issue-listing.spec.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const DEFAULT_ACTION_TIMEOUT = 1000;
77
const SECONDS_IN_DAY = 86400;
88
const MILLISECONDS_IN_SECOND = 1000;
99
const THREE_DAYS = 3;
10-
const TEN_DAYS = 10;
10+
const ISO_DATE_LENGTH = 10;
1111
const TWO_DAYS = 2;
12+
const ONE_DAY = 1;
1213

1314
const daysToMilliseconds = (days: number): number =>
1415
days * SECONDS_IN_DAY * MILLISECONDS_IN_SECOND;
@@ -63,7 +64,7 @@ test.describe('Issue Listing Page Tests', () => {
6364
new Date(endValue).getTime() - daysToMilliseconds(THREE_DAYS),
6465
)
6566
.toISOString()
66-
.slice(0, TEN_DAYS);
67+
.slice(0, ISO_DATE_LENGTH);
6768

6869
await startInput.fill(newStart);
6970
await page.waitForTimeout(DEFAULT_ACTION_TIMEOUT);
@@ -75,15 +76,10 @@ test.describe('Issue Listing Page Tests', () => {
7576
const endInput = page.locator(ISSUE_LISTING_SELECTORS.endDateInput);
7677
await expect(endInput).toBeVisible();
7778

78-
const startValue = await page
79-
.locator(ISSUE_LISTING_SELECTORS.startDateInput)
80-
.inputValue();
81-
82-
const newEnd = new Date(
83-
new Date(startValue).getTime() + daysToMilliseconds(TEN_DAYS),
84-
)
79+
// Set a past end date (yesterday) — always valid and before today
80+
const newEnd = new Date(Date.now() - daysToMilliseconds(ONE_DAY))
8581
.toISOString()
86-
.slice(0, TEN_DAYS);
82+
.slice(0, ISO_DATE_LENGTH);
8783

8884
await endInput.fill(newEnd);
8985
await page.waitForTimeout(DEFAULT_ACTION_TIMEOUT);
@@ -102,7 +98,7 @@ test.describe('Issue Listing Page Tests', () => {
10298
new Date(startValue).getTime() - daysToMilliseconds(TWO_DAYS),
10399
)
104100
.toISOString()
105-
.slice(0, TEN_DAYS);
101+
.slice(0, ISO_DATE_LENGTH);
106102

107103
const urlBefore = page.url();
108104
await endInput.fill(invalidEnd);
@@ -124,12 +120,12 @@ test.describe('Issue Listing Page Tests', () => {
124120
).toBeVisible();
125121

126122
await page
127-
.locator(ISSUE_LISTING_SELECTORS.itemsPerPageOption('25'))
123+
.locator(ISSUE_LISTING_SELECTORS.itemsPerPageOption('20'))
128124
.click();
129125

130126
await page.waitForTimeout(DEFAULT_ACTION_TIMEOUT);
131127

132-
await expect(tableSizeSelector).toContainText('25');
128+
await expect(tableSizeSelector).toContainText('20');
133129
});
134130

135131
test('pagination navigation', async ({ page }) => {

0 commit comments

Comments
 (0)