mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat: versioned endpoints on client (#63441)
This commit is contained in:
committed by
GitHub
parent
88fa4039b9
commit
c801dcdbcb
@@ -119,4 +119,24 @@ describe('Layout selector', () => {
|
||||
const componentObj = getComponentNameAndProps(Certification, challengePath);
|
||||
expect(componentObj.name).toEqual('CertificationLayout');
|
||||
});
|
||||
|
||||
test('Status paths should return raw element without layout', () => {
|
||||
const TestComponent = () => <div>Test</div>;
|
||||
const statusPath = '/status/version';
|
||||
|
||||
const result = layoutSelector({
|
||||
element: { type: TestComponent, props: {}, key: '' },
|
||||
props: {
|
||||
data: {},
|
||||
location: {
|
||||
pathname: statusPath
|
||||
},
|
||||
params: { '*': '' },
|
||||
path: ''
|
||||
}
|
||||
});
|
||||
|
||||
// The result should be the element directly, not wrapped in a layout
|
||||
expect(result.type).toBe(TestComponent);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,6 +27,11 @@ export default function layoutSelector({
|
||||
|
||||
const isChallenge = !!props.pageContext?.challengeMeta || isDailyChallenge;
|
||||
|
||||
// Return raw element for status endpoints without any layout
|
||||
if (/^\/status\//.test(pathname)) {
|
||||
return element;
|
||||
}
|
||||
|
||||
if (element.type === FourOhFourPage) {
|
||||
return (
|
||||
<DefaultLayout pathname={pathname} showFooter={true}>
|
||||
|
||||
Reference in New Issue
Block a user