diff --git a/test/e2e/landings.spec.ts b/test/e2e/landings.spec.ts new file mode 100644 index 00000000000..6f61bad2208 --- /dev/null +++ b/test/e2e/landings.spec.ts @@ -0,0 +1,39 @@ +import { test, expect } from '@playwright/test'; +import { closeCookiesConsentBanner, isStaging } from '../utils'; + +test.describe.configure({ mode: 'parallel' }); + +test.describe('/lp/ pages list', async () => { + test.beforeEach(async ({ context, baseURL }) => { + await closeCookiesConsentBanner(context, baseURL); + }); + + test(`Check /lp/multiplatform default redirects`, async ({ page, baseURL }) => { + test.skip(isStaging(baseURL), 'for host with reverse-proxy only'); + + const targetUrl = 'https://www.jetbrains.com/kotlin-multiplatform/'; + + await page.goto('/lp/multiplatform'); + expect(page.url).toEqual(targetUrl); + + await page.goto('/lp/multiplatform/'); + expect(page.url).toEqual(targetUrl); + + await page.goto('/lp/multiplatform/any'); + expect(page.url).toEqual(targetUrl); + }); + + test(`Check /lp/multiplatform case-studies redirect`, async ({ page, baseURL }) => { + test.skip(isStaging(baseURL), 'for host with reverse-proxy only'); + const targetUrl = 'https://www.jetbrains.com/help/kotlin-multiplatform-dev/case-studies.html'; + + await page.goto('/lp/multiplatform/case-studies'); + expect(page.url).toEqual(targetUrl); + + await page.goto('/lp/multiplatform/case-studies'); + expect(page.url).toEqual(targetUrl); + + await page.goto('/lp/multiplatform/case-studies/philips'); + expect(page.url).toEqual(targetUrl); + }); +}); diff --git a/test/utils.ts b/test/utils.ts index 22feafd087f..e091650f6da 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -2,17 +2,22 @@ import { BrowserContext } from '@playwright/test'; export const testSelector = (name) => `[data-test="${name}"]`; +export function isStaging(baseURL: string): boolean { + const { hostname } = new URL(baseURL); + return hostname !== 'kotlinlang.org'; +} + export const closeCookiesConsentBanner = async (context: BrowserContext, baseURL: string) => { await context.addCookies([ { name: 'jb_cookies_consent_closed', value: 'true', - url: baseURL + url: baseURL, }, { name: 'adConsent', value: 'false', - url: baseURL + url: baseURL, }, ]); };