From 85935f50562d0241cd335ea320dfbd1c3787b37c Mon Sep 17 00:00:00 2001 From: zoobestik Date: Wed, 1 Nov 2023 15:59:59 +0100 Subject: [PATCH] test(KTL-1227): test for redirect to KMP landing page --- test/e2e/landings.spec.ts | 36 ++++++++++++++++++++++++++++++++++++ test/utils.ts | 9 +++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 test/e2e/landings.spec.ts diff --git a/test/e2e/landings.spec.ts b/test/e2e/landings.spec.ts new file mode 100644 index 00000000000..d879f1855cb --- /dev/null +++ b/test/e2e/landings.spec.ts @@ -0,0 +1,36 @@ +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/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, }, ]); };