All practice tasks

Coding (Platform)

Race Safe Project Search

Angular · Medium · Async State

A support agent uses the Projects page to find the project named in a customer ticket. Each change to the search field requests matching projects from the supplied API. If the agent types "api" and then "web", the slower response for "api" can currently replace the results for "web", making the page show projects that no longer match the field. The screen, API fixture and result rows are provided; your change belongs in the component that coordinates requests and visible search state.

Task

Deliver a search screen that keeps the results for the user’s latest query even when an older request finishes later, and clearly shows whether that latest search is loading, empty or failed.

Contract

  • Starting data: initialRows is the supplied project list. Do not mutate it. id identifies a project; title is its visible name; archived hides it from the active list. seats is the available seat count; version identifies the last server version of that project.
  • User action: The user changes the Search projects text. The initial screen starts with an empty query.
  • Provided search API: api.list(query, {signal}) returns a Promise of project rows. Pass the trimmed query and an AbortSignal. A successful result is the next project list. A failure is an error, not an empty successful result.
  • Timing guarantees: API operations may resolve or reject in any order, even after cancellation. The fixture controls completion order; no real network is used.

Acceptance criteria

  • Start the initial empty-query search and a new search whenever the query changes.
  • Clear the previous error and show Loading while the current request is pending.
  • Cancel the superseded request.
  • Only the latest request may replace the rows or show an error.
  • Latest request succeeds: display its active rows and stop loading; an empty list shows No projects.
  • Latest request fails: show Search failed and stop loading.
  • An older success or error must not change the current screen.
  • At component destruction, cancel outstanding work.
  • Ignore later results; do not update a closed or disposed screen.

Constraints

  • At most 200 rows; IDs are unique ASCII strings and seats are non-negative integers. Input props must not be mutated.
  • Keep the Search projects label, data-id row identity and accessible status messages.
  • Use the injected fake API, not hard-coded results. Abort obsolete work and guard against promises settling after abort.
  • No outbound network, paid API or browser permission is needed. New files are not submitted by the embedded widget.

Editable files

  • src/ProjectApp.ts — Repair the component state, lifecycle and API coordination.
  • src/project-app.html — Angular template with typed component bindings.
  • src/helpers.js — Optional pure helpers; not a replacement for framework lifecycle handling.
  • tests/candidate.test.js — Add DOM-level regression tests using fixture(t), deferred() and assert.

What this task practices

Race Safe Project Search is a coding (platform) interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as medium difficulty. It focuses on Technical Reasoning, Testing, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.