Skip to content

Commit

Permalink
Fix failing snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelfangjw committed Jun 16, 2021
1 parent c2481dc commit bd9cf8c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/commons/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const googleApiKey = process.env.REACT_APP_GOOGLE_API_KEY;
const googleAppId = process.env.REACT_APP_GOOGLE_APP_ID;
const githubClientId = process.env.REACT_APP_GITHUB_CLIENT_ID || '';
const githubOAuthProxyUrl = process.env.REACT_APP_GITHUB_OAUTH_PROXY_URL || '';
const interactiveSicpData =
const interactiveSicpDataUrl =
process.env.REACT_APP_INTERACTIVE_SICP_DATA_URL || 'https://source-academy.github.io/sicp/'; // data for interactive-sicp (images and json files)

const authProviders: Map<string, { name: string; endpoint: string; isDefault: boolean }> =
Expand Down Expand Up @@ -127,7 +127,7 @@ const Constants = {
sharedbBackendUrl,
disablePeriods,
cadetLoggerInterval,
interactiveSicpData
interactiveSicpDataUrl
};

export default Constants;
12 changes: 5 additions & 7 deletions src/features/sicp/parser/ParseJson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@ const handleImage = (obj: JsonType, refs: React.MutableRefObject<{}>) => {
if (obj['src']) {
return (
<div className={'sicp-figure'}>
{obj['src'] && (
<img
src={Constants.interactiveSicpData + obj['src']}
alt={obj['id']}
width={obj['scale']}
/>
)}
<img
src={Constants.interactiveSicpDataUrl + obj['src']}
alt={obj['id']}
width={obj['scale']}
/>
</div>
);
} else if (obj['snippet']) {
Expand Down
2 changes: 1 addition & 1 deletion src/features/sicp/parser/__tests__/ParseJson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jest.mock('src/commons/utils/Constants', () => ({
Links: {
sourceDocs: ''
},
interactiveSicpUrl: 'source-academy.github.io/sicp/'
interactiveSicpDataUrl: 'https://source-academy.github.io/sicp/'
}));

const mockData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ exports[`Parse exercise EXERCISE without solution successful 1`] = `
exports[`Parse figures FIGURE with image and scale successful 1`] = `
"<div className=\\"sicp-figure\\">
<div className=\\"sicp-figure\\">
<img src=\\"source-academy.github.io/sicp/sicp.png\\" alt=\\"id\\" width=\\"50%\\" />
<img src=\\"https://source-academy.github.io/sicp/sicp.png\\" alt=\\"id\\" width=\\"50%\\" />
</div>
<h5>
name
Expand All @@ -144,7 +144,7 @@ exports[`Parse figures FIGURE with image and scale successful 1`] = `
exports[`Parse figures FIGURE with image successful 1`] = `
"<div className=\\"sicp-figure\\">
<div className=\\"sicp-figure\\">
<img src=\\"source-academy.github.io/sicp/sicp.png\\" alt=\\"id\\" width={[undefined]} />
<img src=\\"https://source-academy.github.io/sicp/sicp.png\\" alt=\\"id\\" width={[undefined]} />
</div>
<h5>
name
Expand Down
2 changes: 1 addition & 1 deletion src/pages/sicp/Sicp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SicpIndexPage from './subcomponents/SicpIndexPage';

type SicpProps = RouteComponentProps<{}>;

const baseUrl = Constants.interactiveSicpData + '/json/';
const baseUrl = Constants.interactiveSicpDataUrl + '/json/';
const extension = '.json';

// Context to determine which code snippet is active
Expand Down

0 comments on commit bd9cf8c

Please sign in to comment.