Skip to content

Commit 16113fd

Browse files
authored
don't check the productMap for translations (#25589)
* don't check the productMap for translations * fix breaking test
1 parent d2f07b8 commit 16113fd

2 files changed

Lines changed: 17 additions & 26 deletions

File tree

lib/page.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,23 @@ class Page {
9797
// Get array of versions that the page is available in for fast lookup
9898
this.applicableVersions = getApplicableVersions(this.versions, this.fullPath)
9999

100-
// a page should only be available in versions that its parent product is available in
101-
const versionsParentProductIsNotAvailableIn = this.applicableVersions
102-
// only the homepage will not have this.parentProduct
103-
.filter(
104-
(availableVersion) =>
105-
this.parentProduct && !this.parentProduct.versions.includes(availableVersion)
106-
)
107-
108-
if (versionsParentProductIsNotAvailableIn.length) {
109-
throw new Error(
110-
`\`versions\` frontmatter in ${this.fullPath} contains ${versionsParentProductIsNotAvailableIn}, which ${this.parentProduct.id} product is not available in!`
111-
)
100+
// Only check the parent product ID for English because if a top-level
101+
// product is edited in English, it will fail for translations until
102+
// the next translation pipeline PR gets a chance to catch up.
103+
if (this.languageCode === 'en') {
104+
// a page should only be available in versions that its parent product is available in
105+
const versionsParentProductIsNotAvailableIn = this.applicableVersions
106+
// only the homepage will not have this.parentProduct
107+
.filter(
108+
(availableVersion) =>
109+
this.parentProduct && !this.parentProduct.versions.includes(availableVersion)
110+
)
111+
112+
if (versionsParentProductIsNotAvailableIn.length) {
113+
throw new Error(
114+
`\`versions\` frontmatter in ${this.fullPath} contains ${versionsParentProductIsNotAvailableIn}, which ${this.parentProduct.id} product is not available in!`
115+
)
116+
}
112117
}
113118

114119
// derive array of Permalink objects

tests/unit/page.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -781,20 +781,6 @@ describe('catches errors thrown in Page class', () => {
781781
expect(getPage).rejects.toThrowError(/`versions` frontmatter.*? product is not available in/)
782782
})
783783

784-
test('non-English page with a version in frontmatter that its parent product is not available in', async () => {
785-
async function getPage() {
786-
return await Page.init({
787-
relativePath: 'admin/some-category/some-article-with-mismatched-versions-frontmatter.md',
788-
basePath: path.join(__dirname, '../fixtures/products'),
789-
languageCode: 'es',
790-
})
791-
}
792-
793-
await expect(getPage).rejects.toThrowError(
794-
/`versions` frontmatter.*? product is not available in/
795-
)
796-
})
797-
798784
describe('versionining optional attributes', () => {
799785
test("re-rendering set appropriate 'product', 'permissions', 'learningTracks'", async () => {
800786
const page = await Page.init({

0 commit comments

Comments
 (0)