Skip to content

Commit

Permalink
chore(redirects): remove retiredLocale parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed May 17, 2024
1 parent 163aa9e commit a624e6f
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 203 deletions.
11 changes: 1 addition & 10 deletions client/src/document/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { LocalizedContentNote } from "./molecules/localized-content-note";
import { OfflineStatusBar } from "../ui/molecules/offline-status-bar";
import { TOC } from "./organisms/toc";
import { RenderSideBar } from "./organisms/sidebar";
import { RetiredLocaleNote } from "./molecules/retired-locale-note";
import { MainContentContainer } from "../ui/atoms/page-content";
import { Loading } from "../ui/atoms/loading";
import { ArticleFooter } from "./organisms/article-footer";
Expand Down Expand Up @@ -213,8 +212,6 @@ export function Document(props /* TODO: define a TS interface for this */) {
return null;
}

const retiredLocale = searchParams.get("retiredLocale");

return (
<>
<div className="sticky-header-container">
Expand All @@ -223,16 +220,10 @@ export function Document(props /* TODO: define a TS interface for this */) {
</div>
{/* only include this if we are not server-side rendering */}
{!isServer && <OfflineStatusBar />}
{doc.isTranslated ? (
{doc.isTranslated && (
<div className="container">
<LocalizedContentNote isActive={doc.isActive} locale={locale} />
</div>
) : (
retiredLocale && (
<div className="container">
<RetiredLocaleNote locale={retiredLocale} />
</div>
)
)}
<div className="main-wrapper">
<div className="sidebar-container">
Expand Down
26 changes: 0 additions & 26 deletions client/src/document/molecules/retired-locale-note/index.tsx

This file was deleted.

6 changes: 2 additions & 4 deletions libs/fundamental-redirects/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ const LOCALE_PATTERNS = [
)})(/(?<suffix>.*)|$)`,
"i"
),
({ locale, suffix }) => {
({ suffix }) => {
const join = suffix && suffix.includes("?") ? "&" : "?";
return `/${DEFAULT_LOCALE}/${
(suffix || "") + join
}retiredLocale=${RETIRED_LOCALES.get(locale.toLowerCase())}`;
return `/${DEFAULT_LOCALE}/${(suffix || "") + join}`;
}
),
];
Expand Down
55 changes: 0 additions & 55 deletions testing/integration/headless/test_redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,58 +108,3 @@ def test_firefox_source_docs_redirects(url, base_url):
def test_misc_redirects(url, base_url):
url["base_url"] = base_url
assert_valid_url(**url)


@pytest.mark.parametrize(
"retired_locale",
(
"ar",
"bg",
"bn",
"ca",
"el",
"fa",
"fi",
"he",
"hi-IN",
"hu",
"id",
"it",
"kab",
"ms",
"my",
"nl",
"pt-PT",
"sv-SE",
"th",
"tr",
"uk",
"vi",
),
)
@pytest.mark.parametrize(
"slug",
[
"",
"/",
"/docs/Web",
"/docs/Web/",
"/search",
"/search/",
"/search?q=video",
"/search/?q=video",
"/settings",
],
)
def test_retired_locale_redirects(base_url, slug, retired_locale):
"""Ensure that requests for retired locales properly redirect."""
resp = request("get", f"{base_url}/{retired_locale}{slug}")
assert resp.status_code == 302
slug_parts = slug.split("?")
expected_slug = slug_parts[0].lstrip("/")
expected_qs = f"?retiredLocale={retired_locale}"
if len(slug_parts) > 1:
expected_qs += f"&{slug_parts[1]}"
assert (
resp.headers["Location"] == f"/en-US/{expected_slug}{expected_qs}"
), f"{resp.headers['Location']} is not /en-US/{expected_slug}{expected_qs}"
12 changes: 5 additions & 7 deletions testing/tests/headless.index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,28 +229,26 @@ test.describe("changing language", () => {
test.describe("viewing retired locales", () => {
test("redirect retired locale to English (document)", async ({ page }) => {
await page.goto(testURL("/ar/docs/Web/Foo"));
expect(page.url()).toBe(testURL("/en-US/docs/Web/Foo/?retiredLocale=ar"));
expect(page.url()).toBe(testURL("/en-US/docs/Web/Foo"));
expect(await page.innerText("h1")).toBe("<foo>: A test tag");
});

test("redirect retired locale to English (index.json)", async ({ page }) => {
await page.goto(testURL("/ar/docs/Web/Foo/index.json"));
expect(page.url()).toBe(
testURL("/en-US/docs/Web/Foo/index.json?retiredLocale=ar")
);
expect(page.url()).toBe(testURL("/en-US/docs/Web/Foo/index.json"));
expect(await page.isVisible("text=<foo>: A test tag")).toBeTruthy();
});

test("redirect retired locale to English (search with query string)", async ({
page,
}) => {
await page.goto(testURL("/ar/search?q=video"));
expect(page.url()).toBe(testURL("/en-US/search/?q=video&retiredLocale=ar"));
expect(page.url()).toBe(testURL("/en-US/search/?q=video"));
expect(await page.isVisible("text=Search results for: video")).toBeTruthy();
});

test("say the locale was retired", async ({ page }) => {
await page.goto(testURL("/en-US/docs/Web/Foo/?retiredLocale=ar"));
await page.goto(testURL("/en-US/docs/Web/Foo/"));
expect(
await page.isVisible("text=The page you requested has been retired")
).toBeTruthy();
Expand All @@ -264,7 +262,7 @@ test.describe("viewing retired locales", () => {
test("not say the locale was retired if viewing a translated page", async ({
page,
}) => {
await page.goto(testURL("/fr/docs/Web/Foo/?retiredLocale=sv-SE"));
await page.goto(testURL("/fr/docs/Web/Foo/"));
expect(
await page.isVisible("text=The page you requested has been retired")
).toBeFalsy();
Expand Down
Loading

0 comments on commit a624e6f

Please sign in to comment.