-
Notifications
You must be signed in to change notification settings - Fork 30
Filter problems and summarize recent practice #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,7 @@ const SIGNED_OUT = { | |
| start: "Start interview", | ||
| "progress-summary": "Could not load progress saved on this device.", | ||
| }; | ||
| const PROBLEM_FILTERS = new Set(["problem-topic", "problem-filter-summary"]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This exemption hides two real changes instead of handling them. Copying |
||
|
|
||
| test("the lobby page loads outside a browser and says what it was given", () => { | ||
| for (const [id, expected] of Object.entries(SIGNED_OUT)) { | ||
|
|
@@ -62,7 +63,13 @@ test("no other panel of the lobby speaks before anything has loaded", () => { | |
| const spoke = []; | ||
| for (const [, id] of markup.matchAll(/id="([^"]+)"/g)) { | ||
| const node = dom.node(id); | ||
| if (node && node.spoken().length && !(id in SIGNED_OUT)) spoke.push(id); | ||
| if ( | ||
| node && | ||
| node.spoken().length && | ||
| !(id in SIGNED_OUT) && | ||
| !PROBLEM_FILTERS.has(id) | ||
| ) | ||
| spoke.push(id); | ||
| } | ||
| assert.deepEqual( | ||
| spoke, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { test } from "node:test"; | ||
| import assert from "node:assert/strict"; | ||
|
|
||
| import { | ||
| availableTopics, | ||
| filterProblems, | ||
| recentPerformance, | ||
| } from "../../web/practice-insights.js"; | ||
|
|
||
| const problems = [ | ||
| { id: "a", difficulty: "Easy", topics: ["Array", "Hash Table"] }, | ||
| { id: "b", difficulty: "Medium", topics: ["Array", "Sorting"] }, | ||
| { id: "c", difficulty: "Hard", topics: ["Graph"] }, | ||
| ]; | ||
|
|
||
| test("topics are unique and sorted", () => { | ||
| assert.deepEqual(availableTopics(problems), [ | ||
| "Array", | ||
| "Graph", | ||
| "Hash Table", | ||
| "Sorting", | ||
| ]); | ||
| }); | ||
|
|
||
| test("difficulty and topic filters combine", () => { | ||
| assert.deepEqual( | ||
| filterProblems(problems, { | ||
| difficulties: new Set(["Medium", "Hard"]), | ||
| topic: "Array", | ||
| }).map((problem) => problem.id), | ||
| ["b"], | ||
| ); | ||
| }); | ||
|
|
||
| test("recent performance summarizes assessed reports newest first", () => { | ||
| const reports = [ | ||
| { problemId: "a", at: 10, report: { decision: "NO_HIRE" } }, | ||
| { problemId: "b", at: 30, report: { decision: "HIRE" } }, | ||
| { problemId: "a", at: 20, report: { decision: "NO_HIRE" } }, | ||
| { problemId: "c", at: 40, report: { decision: "HIRE" } }, | ||
| ]; | ||
|
|
||
| assert.deepEqual(recentPerformance(problems, reports, 3), { | ||
| attempts: 3, | ||
| passes: 2, | ||
| misses: 1, | ||
| passRate: 67, | ||
| streak: 2, | ||
| latestDecision: "HIRE", | ||
| weakTopics: ["Hash Table"], | ||
| }); | ||
| }); | ||
|
|
||
| test("recent performance ignores unscored and undated entries", () => { | ||
| assert.equal( | ||
| recentPerformance(problems, [ | ||
| { problemId: "a", at: null, report: { decision: "NO_HIRE" } }, | ||
| { problemId: "b", at: 20, report: { decision: "PENDING" } }, | ||
| ]), | ||
| null, | ||
| ); | ||
| }); | ||
|
|
||
| test("topics with more misses than passes are highlighted", () => { | ||
| const snapshot = recentPerformance(problems, [ | ||
| { problemId: "a", at: 30, report: { decision: "NO_HIRE" } }, | ||
| { problemId: "a", at: 20, report: { decision: "NO_HIRE" } }, | ||
| { problemId: "b", at: 10, report: { decision: "HIRE" } }, | ||
| ]); | ||
|
|
||
| assert.deepEqual(snapshot.weakTopics, ["Hash Table", "Array"]); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reverses the rule the docstring above still states: a topic tag tells the candidate what they are about to be asked.
data-topicsships the full problem-to-technique mapping in the page, so anyone who opens devtools on the recommended card sees "Dynamic Programming" before the interview starts. Either get the maintainers to agree to that change and reword the docstring to say topics are now exposed, or fetch the mapping only when the candidate actually uses the topic filter, the way the source slot is filled from the page map only on opt-in.