Skip to content

Commit c616284

Browse files
committed
fix(e2e): update URL assertions to use baseURL in E2E tests
- Refactor URL assertions in `main-page-buttons.spec.ts` and `solutions-tab.spec.ts` to dynamically use `${baseURL}`. - Ensure consistency across tests with `baseURL` and remove hardcoded URLs where applicable.
1 parent 664a40c commit c616284

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

test/production/main-page-buttons.spec.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ test.describe('Main page buttons', () => {
66
await page.goto('/');
77
});
88

9-
test('Hero section Get started button', async ({ page }) => {
9+
test('Hero section Get started button', async ({ page, baseURL }) => {
1010
const getStartedButton = page.getByTestId('hero-block').getByRole('link', { name: 'Get started' });
1111
await expect(getStartedButton).toBeVisible();
1212
await getStartedButton.click();
13-
await expect(page.url()).toContain('/docs/getting-started.html');
13+
expect(page.url()).toContain(`${baseURL}/docs/getting-started.html`);
1414
const pageTitle = page.locator('h1').first();
1515
await expect(pageTitle).toContainText('Get started with Kotlin');
1616
});
@@ -22,32 +22,32 @@ test.describe('Main page buttons', () => {
2222
await jetBrainsLink.click();
2323
const newPage = await newPagePromise;
2424
await newPage.waitForLoadState();
25-
await expect(newPage.url()).toContain('https://www.jetbrains.com/');
25+
expect(newPage.url()).toContain('https://www.jetbrains.com/');
2626
});
2727

2828
test('Kotlin blog button', async ({ page }) => {
2929
const blogButton = page.getByRole('link', { name: 'Kotlin blog' }).and(page.locator(testSelector('button')));
3030
await expect(blogButton).toBeVisible();
3131
await blogButton.click();
32-
await expect(page.url()).toContain('https://blog.jetbrains.com/kotlin/');
32+
expect(page.url()).toContain('https://blog.jetbrains.com/kotlin/');
3333
const pageTitle = page.locator('h1').first();
3434
await expect(pageTitle).toContainText('Kotlin');
3535
});
3636

37-
test('Why Kotlin Get started button', async ({ page }) => {
37+
test('Why Kotlin Get started button', async ({ page, baseURL }) => {
3838
const whyKotlinButton = page.getByTestId('why-kotlin-block').getByRole('link', { name: 'Get started' });
3939
await expect(whyKotlinButton).toBeVisible();
4040
await whyKotlinButton.click();
41-
await expect(page.url()).toContain('/docs/getting-started.html');
41+
expect(page.url()).toContain(`${baseURL}/docs/getting-started.html`);
4242
const pageTitle = page.locator('h1').first();
4343
await expect(pageTitle).toContainText('Get started with Kotlin');
4444
});
4545

46-
test('Learn about Kotlin Multiplatform button', async ({ page }) => {
46+
test('Learn about Kotlin Multiplatform button', async ({ page, baseURL }) => {
4747
const multiplatformButton = page.getByTestId('highlighted-cases-section').getByRole('link', { name: 'Learn about Kotlin Multiplatform' });
4848
await expect(multiplatformButton).toBeVisible();
4949
await multiplatformButton.click();
50-
await expect(page.url()).toContain('https://kotlinlang.org/multiplatform/');
50+
expect(page.url()).toContain(`${baseURL}/multiplatform/`);
5151
const pageTitle = page.locator('h1').first();
5252
await expect(pageTitle).toContainText('Kotlin Multiplatform');
5353
});
@@ -56,16 +56,16 @@ test.describe('Main page buttons', () => {
5656
const jetbrainsAIButton = page.getByTestId('highlighted-cases-section').getByRole('link', { name: 'Learn about JetBrains AI' });
5757
await expect(jetbrainsAIButton).toBeVisible();
5858
await jetbrainsAIButton.click();
59-
await expect(page.url()).toContain('https://www.jetbrains.com/ai/');
59+
expect(page.url()).toContain('https://www.jetbrains.com/ai/');
6060
const pageTitle = page.locator('h1').first();
6161
await expect(pageTitle).toContainText('JetBrains AI');
6262
});
6363

64-
test('Build AI apps with Kotlin button', async ({ page }) => {
64+
test('Build AI apps with Kotlin button', async ({ page, baseURL }) => {
6565
const buildAIAppsButton = page.getByTestId('highlighted-cases-section').getByRole('link', { name: 'Build AI apps with Kotlin' });
6666
await expect(buildAIAppsButton).toBeVisible();
6767
await buildAIAppsButton.click();
68-
await expect(page.url()).toContain('/docs/kotlin-ai-apps-development-overview.html');
68+
expect(page.url()).toContain(`${baseURL}/docs/kotlin-ai-apps-development-overview.html`);
6969
const pageTitle = page.locator('h1').first();
7070
await expect(pageTitle).toContainText('Kotlin for AI-powered app development');
7171
});
@@ -74,33 +74,33 @@ test.describe('Main page buttons', () => {
7474
const getStartedKoogButton = page.getByTestId('highlighted-cases-section').getByTestId('kotlin-plus-ai-block').getByRole('link', { name: 'Get started' });
7575
await expect(getStartedKoogButton).toBeVisible();
7676
await getStartedKoogButton.click();
77-
await expect(page.url()).toContain('/docs.koog.ai/');
77+
expect(page.url()).toContain('/docs.koog.ai/');
7878
await expect(page.getByText('Koog on GitHub').first()).toBeVisible();
7979
});
8080

81-
test('Join the community button', async ({ page }) => {
81+
test('Join the community button', async ({ page, baseURL }) => {
8282
const joinCommunityButton = page.getByTestId('highlighted-cases-section').getByRole('link', { name: 'Join the community' });
8383
await expect(joinCommunityButton).toBeVisible();
8484
await joinCommunityButton.click();
8585
await page.waitForTimeout(2000);
86-
await expect(page.url()).toContain('/community/');
86+
expect(page.url()).toContain(`${baseURL}/community/`);
8787
await expect(page.getByText('Get involved in the community')).toBeVisible();
8888
});
8989

9090
test('Learn more button in Kotlin Foundation section', async ({ page }) => {
9191
const learnMoreButton = page.getByTestId('highlighted-cases-section').getByRole('link', { name: 'Learn more' });
9292
await expect(learnMoreButton).toBeVisible();
9393
await learnMoreButton.click();
94-
await expect(page.url()).toContain('https://kotlinfoundation.org/');
94+
expect(page.url()).toContain('https://kotlinfoundation.org/');
9595
const pageTitle = page.locator('h1').first();
9696
await expect(pageTitle).toContainText('Protect, promote and advance the development of the Kotlin programming language');
9797
});
9898

99-
test('Last Get started button', async ({ page }) => {
99+
test('Last Get started button', async ({ page, baseURL }) => {
100100
const getStartedButton = page.getByTestId('highlighted-cases-section').getByRole('link', { name: 'Get started' }).last();
101101
await expect(getStartedButton).toBeVisible();
102102
await getStartedButton.click();
103-
await expect(page.url()).toContain('/docs/getting-started.html');
103+
expect(page.url()).toContain(`${baseURL}/docs/getting-started.html`);
104104
const pageTitle = page.locator('h1').first();
105105
await expect(pageTitle).toContainText('Get started with Kotlin');
106106
});

test/production/solutions-tab.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,33 @@ test.describe('Solutions tab', () => {
1010
await solutionsButton.click();
1111
});
1212

13-
test('Click on "Multiplatform" button should open the related page', async ({ page }) => {
13+
test('Click on "Multiplatform" button should open the related page', async ({ page, baseURL }) => {
1414
const multiplatformButton = page.locator(testSelector("header")).getByText('Multiplatform').first();
1515
await expect(multiplatformButton).toBeVisible();
1616
await multiplatformButton.click();
17-
await expect(page.url()).toContain('https://kotlinlang.org/multiplatform/');
17+
expect(page.url()).toContain(`${baseURL}/multiplatform/`);
1818
});
1919

20-
test('Click on "Server-side" button should open the related page', async ({ page }) => {
20+
test('Click on "Server-side" button should open the related page', async ({ page, baseURL }) => {
2121
const serverSideButton = page.locator(testSelector("header")).getByText('Server-side').first();
2222
await expect(serverSideButton).toBeVisible();
2323
await serverSideButton.click();
24-
await expect(page.url()).toContain('/server-side/');
24+
expect(page.url()).toContain(`${baseURL}/server-side/`);
2525
});
2626

27-
test('Click on "Data science" button should open the related page', async ({ page }) => {
27+
test('Click on "Data science" button should open the related page', async ({ page, baseURL }) => {
2828
const dataScienceButton = page.locator(testSelector("header")).getByText('Data science');
2929
await expect(dataScienceButton).toBeVisible();
3030
await dataScienceButton.click();
3131
// We need a timeout here because of redirect to another URL.
3232
await page.waitForTimeout(2000);
33-
await expect(page.url()).toContain('/docs/data-analysis-overview.html');
33+
expect(page.url()).toContain(`${baseURL}/docs/data-analysis-overview.html`);
3434
});
3535

36-
test('Click on "Android" button should open the related page', async ({ page }) => {
36+
test('Click on "Android" button should open the related page', async ({ page, baseURL }) => {
3737
const androidButton = page.locator(testSelector("header")).getByText('Android').first();
3838
await expect(androidButton).toBeVisible();
3939
await androidButton.click();
40-
await expect(page.url()).toContain('/docs/android-overview.html');
40+
expect(page.url()).toContain(`${baseURL}/docs/android-overview.html`);
4141
});
4242
});

0 commit comments

Comments
 (0)