Skip to content

Commit

Permalink
Merge pull request #3875 from JetBrains/ktl-1227-add-e2e-test
Browse files Browse the repository at this point in the history
test(KTL-1227): test for redirect to KMP landing page
  • Loading branch information
zoobestik authored Nov 14, 2023
2 parents 881e0dd + 85935f5 commit 0d6fdb1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
36 changes: 36 additions & 0 deletions test/e2e/landings.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
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 0d6fdb1

Please sign in to comment.