Skip to content

Commit

Permalink
Merge pull request #2503 from codecrafters-io/revert-2496-stage-1-exp…
Browse files Browse the repository at this point in the history
…eriments

Revert "Experiment: Stage 1 - Hide Test Runner Card Before User Has Submitted Again"
  • Loading branch information
andy1li authored Dec 26, 2024
2 parents 2cbbe24 + 59fb768 commit 299487f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,22 @@
@isComplete={{this.uncommentCodeStepIsComplete}}
/>
{{else if (eq stepList.expandedStep.id "submit-code")}}
<CoursePage::CourseStageStep::FirstStageTutorialCard::SubmitCodeStep
@isComplete={{this.submitCodeStepIsComplete}}
@shouldHideTestRunnerCardRelatedCopy={{@shouldHideTestRunnerCardRelatedCopy}}
/>
<CoursePage::CourseStageStep::FirstStageTutorialCard::SubmitCodeStep @isComplete={{this.submitCodeStepIsComplete}} />
{{/if}}
</ExpandableStepList>

{{#if @shouldHideTestRunnerCardRelatedCopy}}
{{#if this.shouldShowLinkToForum}}
<div class="prose dark:prose-invert prose-sm prose-compact mt-6">
<p>Need help?</p>
<ul>
<li>
<a
href="https://forum.codecrafters.io/new-topic?category=Challenges&tags=challenge%3A{{this.currentCourse.slug}}&title=%5B{{this.currentCourse.shortName}}%5D%20How%20to%20pass%20the%20first%20stage%3F&body=Checklist%3A%0A%0A1.%20%E2%9C%85%20or%20%E2%9D%8C%3A%20I%27ve%20uncommented%20the%20code.%0A2.%20%E2%9C%85%20or%20%E2%9D%8C%3A%20I%27ve%20saved%20the%20changes.%0A3.%20%E2%9C%85%20or%20%E2%9D%8C%3A%20I%27ve%20run%20the%20git%20commands%3A%0A%0A%60%60%60%0Agit%20commit%20-am%20%22%5Bseeking%20help%20on%20forum%5D%22%0Agit%20push%20origin%20master%0A%60%60%60%0A%0A---%0A%0AHere%E2%80%99s%20a%20screenshot%20showing%20the%20output%20from%20running%20the%20Git%20commands%3A%0A%0A%5BAttach%20screenshot%20here%5D%0A%0A%5BShare%20other%20details%20here%5D"
target="_blank"
rel="noopener noreferrer"
>
Post your issue</a>
on the forum — Andy usually replies within 6 hours.
</li>
</ul>
</div>
{{/if}}
{{else}}
{{! After step 2, step 3 already contains a note on Tests Failed, so we can hide this !}}
{{#unless this.uncommentCodeStepIsComplete}}
<div class="prose dark:prose-invert prose-sm prose-compact mt-5">
<p>
{{svg-jar "information-circle" class="w-5 h-5 mb-1 inline-flex text-sky-500"}}
<b>Note:</b>
After your first Git push, you should see
<code
class="font-semibold text-red-700 dark:text-red-300 bg-red-100 dark:bg-red-900/30 border border-red-200 dark:border-red-800/40"
>Tests failed</code>
in the bar below this card. This is expected! Complete the steps above to pass the tests.
</p>
</div>
{{/unless}}
{{/if}}
{{! After step 2, step 3 already contains a note on Tests Failed, so we can hide this !}}
{{#unless this.uncommentCodeStepIsComplete}}
<div class="prose dark:prose-invert prose-sm prose-compact mt-5">
<p>
{{svg-jar "information-circle" class="w-5 h-5 mb-1 inline-flex text-sky-500"}}
<b>Note:</b>
After your first Git push, you should see
<code class="font-semibold text-red-700 dark:text-red-300 bg-red-100 dark:bg-red-900/30 border border-red-200 dark:border-red-800/40">Tests
failed</code>
in the bar below this card. This is expected! Complete the steps above to pass the tests.
</p>
</div>
{{/unless}}
</:content>
</CoursePage::InstructionsCard>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import CoursePageStateService from 'codecrafters-frontend/services/course-page-s
import FeatureFlagsService from 'codecrafters-frontend/services/feature-flags';
import Store from '@ember-data/store';
import type CourseStageModel from 'codecrafters-frontend/models/course-stage';
import type CourseStageStep from 'codecrafters-frontend/utils/course-page-step-list/course-stage-step';
import type RepositoryModel from 'codecrafters-frontend/models/repository';
import type { Step } from 'codecrafters-frontend/components/expandable-step-list';
import { action } from '@ember/object';
Expand All @@ -15,8 +14,6 @@ interface Signature {
Args: {
repository: RepositoryModel;
courseStage: CourseStageModel;
currentStep: CourseStageStep;
shouldHideTestRunnerCardRelatedCopy: boolean;
};
}

Expand Down Expand Up @@ -73,10 +70,6 @@ export default class FirstStageTutorialCardComponent extends Component<Signature
@service declare featureFlags: FeatureFlagsService;
@service declare store: Store;

get currentCourse() {
return this.args.courseStage.course;
}

get navigateToFileStepIsComplete() {
return this.navigateToFileStepWasMarkedAsComplete || this.uncommentCodeStepIsComplete;
}
Expand All @@ -85,12 +78,6 @@ export default class FirstStageTutorialCardComponent extends Component<Signature
return this.coursePageState.manuallyCompletedStepIdsInFirstStageInstructions.includes('navigate-to-file');
}

get shouldShowLinkToForum() {
const currentStep = this.args.currentStep;

return currentStep.testsStatus !== 'passed' && currentStep.status !== 'complete';
}

get steps() {
return [
new NavigateToFileStep(this.args.repository, this.navigateToFileStepIsComplete),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

<div class="prose dark:prose-invert">
<p class={{if @isComplete "line-through"}}>
Once you run the commands above, our system will automatically test your code.
Once you run the commands above, the
<code class="font-semibold text-red-700 bg-red-100 border border-red-200">Tests failed</code>
message below this card will change to
<code class="font-semibold text-green-700 bg-green-100 border border-green-200">Tests passed</code>.
</p>

{{#if @isComplete}}
Expand All @@ -20,12 +23,10 @@
</div>

{{#unless @isComplete}}
{{#unless @shouldHideTestRunnerCardRelatedCopy}}
<p class="prose dark:prose-invert prose-sm mt-3">
<b>Note:</b>
If you're still seeing "Tests failed" after completing the steps above,
<a href="#" {{on "click" this.handleViewLogsButtonClick}}>view logs</a>
to troubleshoot.
</p>
{{/unless}}
<p class="prose dark:prose-invert prose-sm mt-3">
<b>Note:</b>
If you're still seeing "Tests failed" after completing the steps above,
<a href="#" {{on "click" this.handleViewLogsButtonClick}}>view logs</a>
to troubleshoot.
</p>
{{/unless}}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ interface Signature {

Args: {
isComplete: boolean;
shouldHideTestRunnerCardRelatedCopy: boolean;
};
}

Expand Down
23 changes: 2 additions & 21 deletions app/controllers/course/stage/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ import { tracked } from '@glimmer/tracking';
import type AuthenticatorService from 'codecrafters-frontend/services/authenticator';
import type CoursePageStateService from 'codecrafters-frontend/services/course-page-state';
import type CourseStageModel from 'codecrafters-frontend/models/course-stage';
import type FeatureFlagsService from 'codecrafters-frontend/services/feature-flags';
import type RepositoryModel from 'codecrafters-frontend/models/repository';
import type CourseStageStep from 'codecrafters-frontend/utils/course-page-step-list/course-stage-step';
import { action } from '@ember/object';
import type RouterService from '@ember/routing/router-service';
import { next } from '@ember/runloop';
import { task } from 'ember-concurrency';
import type Store from '@ember-data/store';

export default class CourseStageInstructionsController extends Controller {
@service declare authenticator: AuthenticatorService;
@service declare coursePageState: CoursePageStateService;
@service declare featureFlags: FeatureFlagsService;
@service declare router: RouterService;
@service declare store: Store;

Expand Down Expand Up @@ -48,10 +47,6 @@ export default class CourseStageInstructionsController extends Controller {
return this.model.courseStage.prerequisiteInstructionsMarkdownFor(this.model.activeRepository);
}

get shouldHideTestRunnerCardBeforeStage1Submission() {
return this.featureFlags.cannotSeeTestRunnerCardBeforeStage1Submission;
}

get shouldShowFeedbackPrompt() {
return !this.currentStep.courseStage.isFirst && this.currentStep.status === 'complete';
}
Expand All @@ -61,21 +56,7 @@ export default class CourseStageInstructionsController extends Controller {
}

get shouldShowTestRunnerCard() {
if (!this.isCurrentStage) {
return false;
}

if (this.currentStep.status === 'complete') {
return false;
}

if (this.model.courseStage.isFirst) {
// For stage 1, we hide the test runner card until the user's submission.
return !(this.model.activeRepository.submissionsCount <= 1 && this.shouldHideTestRunnerCardBeforeStage1Submission);
} else {
// For other stages, we always show the test runner card
return true;
}
return this.isCurrentStage && this.currentStep.status !== 'complete';
}

get shouldShowUpgradePrompt() {
Expand Down
4 changes: 2 additions & 2 deletions app/services/feature-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default class FeatureFlagsService extends Service {
return this.currentUser?.isStaff || this.getFeatureFlagValue('can-see-short-instructions-for-stage-2') === 'test';
}

get cannotSeeTestRunnerCardBeforeStage1Submission() {
return this.currentUser?.isStaff || this.getFeatureFlagValue('cannot-see-test-runner-card-before-stage1-submission') === 'test';
get canSeeTweaksForStage1() {
return this.currentUser?.isStaff || this.getFeatureFlagValue('can-see-tweaks-for-stage-1') === 'test';
}

get currentUser() {
Expand Down
8 changes: 1 addition & 7 deletions app/templates/course/stage/instructions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@
{{/if}}

{{#if @model.courseStage.isFirst}}
<CoursePage::CourseStageStep::FirstStageTutorialCard
@repository={{@model.activeRepository}}
@courseStage={{@model.courseStage}}
@currentStep={{this.currentStep}}
@shouldHideTestRunnerCardRelatedCopy={{this.shouldHideTestRunnerCardBeforeStage1Submission}}
class="mb-6"
/>
<CoursePage::CourseStageStep::FirstStageTutorialCard @repository={{@model.activeRepository}} @courseStage={{@model.courseStage}} class="mb-6" />
{{/if}}

{{#if @model.courseStage.isSecond}}
Expand Down

0 comments on commit 299487f

Please sign in to comment.