Skip to content

Commit 0928724

Browse files
authored
Merge pull request #5439 from JetBrains/ktl-4236-gammar-links
fix(KTL-4236): Grammar: Links to documentation were broken
2 parents 8a3b7af + ae4f570 commit 0928724

File tree

6 files changed

+30
-63
lines changed

6 files changed

+30
-63
lines changed

blocks/grammar/markdown.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ function rebaseRelativeUrl(href: string) {
2525
// Not a valid absolute URL, treat as relative path
2626
}
2727

28+
if (href.startsWith('#')) return href;
29+
2830
// Construct absolute URL using old grammar documentation as base
2931
url = new URL(href, `${OLD_GRAMMAR_HOST}${OLD_GRAMMAR_PATH}`);
3032

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
"generate-redirects": "node scripts/generate-redirect-pages.js",
139139
"lint": "next lint",
140140
"test": "playwright test test",
141-
"test:ci": "playwright test test/production",
141+
"test:ci": "playwright test test/production test/e2e/grammar/",
142142
"test:e2e": "playwright test test/e2e",
143143
"test:e2e:ci": "CI=true playwright test test/e2e",
144144
"test:e2e:headed": "playwright test test/e2e --headed",
Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
import { expect, test } from '@playwright/test';
2-
import { GrammarPage } from '../page/grammar-page';
3-
import { checkScreenshot } from '../utils';
4-
import { MICRO_ANIMATION_TIMEOUT_LONG } from './visual-constants';
2+
import { GrammarPage } from './page';
3+
import { checkScreenshot } from '../../utils';
4+
import { MICRO_ANIMATION_TIMEOUT_LONG } from '../visual-constants';
55

6-
test.describe('Grammar page', () => {
6+
test.describe('Grammar: support', () => {
7+
test('Should redirect from .html to clean URL', async ({ page }) => {
8+
await page.goto('/docs/reference/grammar.html');
9+
10+
await expect(page).toHaveURL('/grammar/');
11+
12+
const redirected = new GrammarPage(page);
13+
await expect(redirected.layout).toBeVisible();
14+
});
15+
16+
test('Should redirect from nested URL', async ({ page }) => {
17+
await page.goto('/docs/reference/grammar/');
18+
19+
await expect(page).toHaveURL('/grammar/');
20+
21+
const redirected = new GrammarPage(page);
22+
await expect(redirected.layout).toBeVisible();
23+
});
24+
})
25+
26+
test.describe('Grammar: content', () => {
727
let grammar: GrammarPage;
828

929
test.beforeEach(async ({ page }) => {
@@ -82,7 +102,7 @@ test.describe('Grammar page', () => {
82102
const docsLink = grammar.layout.locator('a[href*="packages.html"]').first();
83103
await expect(docsLink).toBeVisible();
84104
const docsHref = await docsLink.getAttribute('href');
85-
expect(docsHref).toMatch(/^\/docs\/.*packages\.html/);
105+
expect(docsHref).toMatch('/docs/reference/packages.html');
86106
});
87107

88108
test('Should render links with Inline Attribute List (target="_blank")', async () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Locator, Page } from '@playwright/test';
2-
import { BasePage } from './base-page';
2+
import { BasePage } from '../../page/base-page';
33

44
export const GRAMMAR_URL = '/grammar/';
55

test/production/grammar.spec.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

utils/mdToHtml.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export function Markdown(props: MarkdownProps) {
2323
options={{
2424
...props.options,
2525
overrides: {
26+
...overriddenClassNamesForTags,
2627
...props.options?.overrides,
27-
...overriddenClassNamesForTags
2828
}
2929
}}
3030
/>;

0 commit comments

Comments
 (0)