-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display departure times and search time in CET, regardless of w…
…hich timezone the users is located in (#234) * Added functionality to display departure times and the time in the search time selectore in CTE, regardless of which time zone the user is located in. * Added functinonality to set the correct searchTimeParam when navigating from detailed view back to search results. + some minor updates in the code. * Fixed bug in search time selector and setTimezoneIfNeeded(). * Fixed small blunder when using wrong function. * Add playwrigth tests. * Added mores tests.
- Loading branch information
1 parent
92c7edd
commit 333ab75
Showing
7 changed files
with
220 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
const JST = 'Asia/Tokyo'; | ||
const EET = 'Europe/Helsinki'; | ||
const CTU = 'Europe/Oslo'; | ||
const UTC = 'Europe/London'; | ||
const PST = 'America/Los_Angeles'; | ||
|
||
const fromTextbox = 'Kristiansund'; | ||
const fromOption = 'Kristiansund trafikkterminal'; | ||
const toTextbox = 'Molde'; | ||
const toOption = 'Molde trafikkterminal'; | ||
const searchTime = '15:30'; | ||
const expectedDeparture = '16:00 -'; | ||
|
||
test.describe('Trip search from different timezones - detailed view.', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(process.env.E2E_URL ?? 'http://localhost:3000'); | ||
}); | ||
|
||
test.use({ | ||
timezoneId: JST, | ||
}); | ||
test(JST + ' - (UTC +0900)', async ({ page }) => { | ||
await page.getByTestId('searchTimeSelector-departBy').click(); | ||
await page.getByTestId('searchTimeSelector-time').click(); | ||
await page.getByTestId('searchTimeSelector-time').fill(searchTime); | ||
await page.getByRole('textbox', { name: 'From' }).click(); | ||
await page.getByRole('textbox', { name: 'From' }).fill(fromTextbox); | ||
await page.getByRole('option', { name: fromOption }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).fill(toTextbox); | ||
await page | ||
.getByRole('option', { | ||
name: toOption, | ||
}) | ||
.click(); | ||
await page.getByTestId('tripPattern-0-0').click(); | ||
const elementText = await page | ||
.getByTestId('detailsHeader-duration') | ||
.textContent(); | ||
|
||
expect(elementText?.includes(expectedDeparture)); | ||
}); | ||
|
||
test.use({ | ||
timezoneId: EET, | ||
}); | ||
test(EET + ' - (UTC +0200)', async ({ page }) => { | ||
await page.getByTestId('searchTimeSelector-departBy').click(); | ||
await page.getByTestId('searchTimeSelector-time').click(); | ||
await page.getByTestId('searchTimeSelector-time').fill(searchTime); | ||
await page.getByRole('textbox', { name: 'From' }).click(); | ||
await page.getByRole('textbox', { name: 'From' }).fill(fromTextbox); | ||
await page.getByRole('option', { name: fromOption }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).fill(toTextbox); | ||
await page | ||
.getByRole('option', { | ||
name: toOption, | ||
}) | ||
.click(); | ||
await page.getByTestId('tripPattern-0-0').click(); | ||
const elementText = await page | ||
.getByTestId('detailsHeader-duration') | ||
.textContent(); | ||
|
||
expect(elementText?.includes(expectedDeparture)); | ||
}); | ||
|
||
test.use({ | ||
timezoneId: CTU, | ||
}); | ||
test(CTU + ' - (UTC +0100)', async ({ page }) => { | ||
await page.getByTestId('searchTimeSelector-departBy').click(); | ||
await page.getByTestId('searchTimeSelector-time').click(); | ||
await page.getByTestId('searchTimeSelector-time').fill(searchTime); | ||
await page.getByRole('textbox', { name: 'From' }).click(); | ||
await page.getByRole('textbox', { name: 'From' }).fill(fromTextbox); | ||
await page.getByRole('option', { name: fromOption }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).fill(toTextbox); | ||
await page | ||
.getByRole('option', { | ||
name: toOption, | ||
}) | ||
.click(); | ||
await page.getByTestId('tripPattern-0-0').click(); | ||
const elementText = await page | ||
.getByTestId('detailsHeader-duration') | ||
.textContent(); | ||
|
||
expect(elementText?.includes(expectedDeparture)); | ||
}); | ||
|
||
test.use({ | ||
timezoneId: UTC, | ||
}); | ||
test(UTC + ' - (UTC +0000)', async ({ page }) => { | ||
await page.getByTestId('searchTimeSelector-departBy').click(); | ||
await page.getByTestId('searchTimeSelector-time').click(); | ||
await page.getByTestId('searchTimeSelector-time').fill(searchTime); | ||
await page.getByRole('textbox', { name: 'From' }).click(); | ||
await page.getByRole('textbox', { name: 'From' }).fill(fromTextbox); | ||
await page.getByRole('option', { name: fromOption }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).fill(toTextbox); | ||
await page | ||
.getByRole('option', { | ||
name: toOption, | ||
}) | ||
.click(); | ||
await page.getByTestId('tripPattern-0-0').click(); | ||
const elementText = await page | ||
.getByTestId('detailsHeader-duration') | ||
.textContent(); | ||
|
||
expect(elementText?.includes(expectedDeparture)); | ||
}); | ||
|
||
test.use({ | ||
timezoneId: PST, | ||
}); | ||
test(PST + ' - (UTC -0800)', async ({ page }) => { | ||
await page.getByTestId('searchTimeSelector-departBy').click(); | ||
await page.getByTestId('searchTimeSelector-time').click(); | ||
await page.getByTestId('searchTimeSelector-time').fill(searchTime); | ||
await page.getByRole('textbox', { name: 'From' }).click(); | ||
await page.getByRole('textbox', { name: 'From' }).fill(fromTextbox); | ||
await page.getByRole('option', { name: fromOption }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).click(); | ||
await page.getByRole('textbox', { name: 'To' }).fill(toTextbox); | ||
await page | ||
.getByRole('option', { | ||
name: toOption, | ||
}) | ||
.click(); | ||
await page.getByTestId('tripPattern-0-0').click(); | ||
const elementText = await page | ||
.getByTestId('detailsHeader-duration') | ||
.textContent(); | ||
|
||
expect(elementText?.includes(expectedDeparture)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters