diff --git a/client/src/templates/Challenges/classic/action-row.tsx b/client/src/templates/Challenges/classic/action-row.tsx
index b253cfb3778..34893d4ceb8 100644
--- a/client/src/templates/Challenges/classic/action-row.tsx
+++ b/client/src/templates/Challenges/classic/action-row.tsx
@@ -6,6 +6,7 @@ import EditorTabs from './editor-tabs';
interface ActionRowProps {
hasNotes: boolean;
+ hasPreview: boolean;
isProjectBasedChallenge: boolean;
showConsole: boolean;
showNotes: boolean;
@@ -16,6 +17,7 @@ interface ActionRowProps {
}
const ActionRow = ({
+ hasPreview,
hasNotes,
togglePane,
showNotes,
@@ -77,21 +79,25 @@ const ActionRow = ({
{t('learn.editor-tabs.notes')}
)}
-
-
+ {hasPreview && (
+ <>
+
+
+ >
+ )}
diff --git a/client/src/templates/Challenges/classic/desktop-layout.tsx b/client/src/templates/Challenges/classic/desktop-layout.tsx
index 87791babe4b..d9c59474d63 100644
--- a/client/src/templates/Challenges/classic/desktop-layout.tsx
+++ b/client/src/templates/Challenges/classic/desktop-layout.tsx
@@ -194,6 +194,7 @@ const DesktopLayout = (props: DesktopLayoutProps): JSX.Element => {
{(projectBasedChallenge || isMultifileCertProject) && (
{
const reflexLayout = store.get(REFLEX_LAYOUT) as ReflexLayout;
@@ -508,12 +509,14 @@ function ShowClassic({
-
+ {showPreview && (
+
+ )}
diff --git a/e2e/action-row.spec.ts b/e2e/action-row.spec.ts
index faa86aaf9bc..906eb3b20d4 100644
--- a/e2e/action-row.spec.ts
+++ b/e2e/action-row.spec.ts
@@ -125,3 +125,13 @@ test('Clicking Preview Portal button opens the preview in a new tab', async ({
await newPage.close();
});
+
+test('Preview Buttons should not appear when preview is disabled', async ({
+ page
+}) => {
+ await page.goto(
+ '/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/step-1'
+ );
+ const previewButton = page.getByTestId('preview-pane-button');
+ await expect(previewButton).toHaveCount(0);
+});
diff --git a/e2e/project-preview-modal.spec.ts b/e2e/project-preview-modal.spec.ts
index c0a7fd2fe3a..9e66cf3f3f7 100644
--- a/e2e/project-preview-modal.spec.ts
+++ b/e2e/project-preview-modal.spec.ts
@@ -59,3 +59,27 @@ test.describe('Exit Project Preview Modal E2E Test Suite', () => {
await expect(dialog).not.toBeVisible();
});
});
+
+test.describe('Project Preview Modal Conditional Rendering', () => {
+ test('Does not render on second step of a project', async ({ page }) => {
+ await page.goto(
+ '/learn/2022/responsive-web-design/learn-html-by-building-a-cat-photo-app/step-2'
+ );
+ const dialog = page.getByRole('dialog', {
+ name: translations.learn['project-preview-title']
+ });
+ await expect(dialog).toHaveCount(0);
+ });
+
+ test('Does not render on first step of a project without a preview', async ({
+ page
+ }) => {
+ await page.goto(
+ '/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/step-1'
+ );
+ const dialog = page.getByRole('dialog', {
+ name: translations.learn['project-preview-title']
+ });
+ await expect(dialog).toHaveCount(0);
+ });
+});