Skip to content

Commit

Permalink
test(KTL-1227): test for redirect to KMP landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
zoobestik committed Nov 13, 2023
1 parent daab425 commit 73a4625
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
39 changes: 39 additions & 0 deletions test/e2e/landings.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
9 changes: 7 additions & 2 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
]);
};

0 comments on commit 73a4625

Please sign in to comment.