From 1fc96681106bb35c3eb30415a7a0aed96f25b6ff Mon Sep 17 00:00:00 2001 From: Wolf Date: Tue, 29 Sep 2026 20:05:04 +0200 Subject: [PATCH] Read Gem boards through the job board's GraphQL API Co-Authored-By: Claude Sonnet 5.5 --- plugins/atshosts/gem.py | 152 ++++++++++++++++++++++ tests/fixtures/ats/gem-detail-1.json | 1 + tests/fixtures/ats/gem-detail-2.json | 1 + tests/fixtures/ats/gem.json | 1 + tests/test_ats_gem.py | 180 +++++++++++++++++++++++++++ 5 files changed, 335 insertions(+) create mode 100644 plugins/atshosts/gem.py create mode 100644 tests/fixtures/ats/gem-detail-1.json create mode 100644 tests/fixtures/ats/gem-detail-2.json create mode 100644 tests/fixtures/ats/gem.json create mode 100644 tests/test_ats_gem.py diff --git a/plugins/atshosts/gem.py b/plugins/atshosts/gem.py new file mode 100644 index 0000000..e57db05 --- /dev/null +++ b/plugins/atshosts/gem.py @@ -0,0 +1,152 @@ +"""Gem: `gem:` for jobs.gem.com/, one GraphQL POST for the +whole board and one more for a role's text and date. The board is the path +after `jobs.gem.com/`, and it is case-sensitive (`Productboard` is an empty +board where `productboard` is not). + +The two queries below were read out of Gem's page scripts +(`static.gem.com/scripts/jobBoards.*.js` and `ExternalJobBoardList.*.js`) on +2026-09-29 and run against Productboard's and sennder's boards; the schema is +Gem's own and not documented, so a new bundle can rename a field. Each query is +one constant, and an answer that lacks the shape read here fails with an error +that says which part is missing rather than reading as an empty board. The +endpoint answered with no Origin and no Referer header, so none is sent. An +unknown board answers 200 with an empty list, like a board with no role open. + +The listing has no description and no date; both are on the role's page. +""" + +from __future__ import annotations + +import html +import json +import re +from collections.abc import Callable +from typing import Any + +from desk.sources import strip_html + +from ._shared import Get, Page, Row, only, parse_dt + +NAME = "gem" +LABEL = "Gem" +KEEP_CASE = True +PATTERNS = (r"jobs\.gem\.com/([A-Za-z0-9_-]+)",) + +_HOST = "jobs.gem.com" +_API = f"https://{_HOST}/api/public/graphql" + +#: A board is one path segment of letters, digits, `-` and `_`. It travels as a +#: GraphQL variable and never into a host name, so the host stays Gem's. +_BOARD = re.compile(r"[A-Za-z0-9_-]+") + +#: Every role of a board in one answer, with no paging and no total. +LIST_QUERY = ( + "query JobBoardList($boardId: String!) { oatsExternalJobPostings(boardId: $boardId) " + "{ jobPostings { id extId title locations { id name city isoCountry isRemote extId } " + "job { id department { id name extId } locationType employmentType } } } }") + +#: One role's description and the date it was first published. +DETAIL_QUERY = ( + "query ExternalJobPosting($boardId: String!, $extId: String!) " + "{ oatsExternalJobPosting(boardId: $boardId, extId: $extId) " + "{ id title descriptionHtml extId firstPublishedTsSec " + "locations { id extId name city isoCountry isRemote } " + "job { id locationType employmentType requisitionId teamDisplayName " + "department { id extId name } } compensationHtml } }") + +#: `job.locationType` -> `store._remote`'s words. +_REMOTE = {"IN_OFFICE": "onsite", "HYBRID": "hybrid", "REMOTE": "remote"} + + +def slug_ok(slug: str) -> bool: + return bool(_BOARD.fullmatch(slug)) + + +def allowed(slug: str) -> Callable[[str], bool]: + return only(_HOST) + + +def careers_url(slug: str) -> str: + return f"https://{_HOST}/{slug}" + + +def robots_page(slug: str) -> str: + return careers_url(slug) + + +def _ask(get: Get, operation: str, query: str, variables: dict[str, str], + path: str) -> Any: + """One GraphQL call, and the part of its answer at `data.`. An + `errors` list or a `data` without the key is Gem's schema having moved (or + a refused query), and is raised as such; a `null` at the key is returned.""" + answer = json.loads(get(_API, method="POST", payload={ + "operationName": operation, "variables": variables, "query": query})) + if not isinstance(answer, dict): + raise ValueError(f"not a Gem answer: {type(answer).__name__}") + if answer.get("errors"): + first = answer["errors"][0] + message = first.get("message") if isinstance(first, dict) else first + raise ValueError(f"Gem's {operation} query was refused: {message}") + data = answer.get("data") + if not isinstance(data, dict) or path not in data: + raise ValueError(f"Gem's {operation} answer has no {path}; the query may be out of date") + return data[path] + + +def page(get: Get, slug: str, cursor: Any) -> Page: + """The one page there is: `data.oatsExternalJobPostings.jobPostings`.""" + board = _ask(get, "JobBoardList", LIST_QUERY, {"boardId": slug}, "oatsExternalJobPostings") + postings = board.get("jobPostings") if isinstance(board, dict) else None + if not isinstance(postings, list): + raise ValueError("Gem's JobBoardList answer has no jobPostings list; " + "the query may be out of date") + return postings, [{"id": p.get("extId") or p.get("id") or ""} for p in postings], None, None + + +def rows(postings: list[dict[str, Any]], slug: str) -> list[Row]: + """A role has `extId` (a number from a synced Greenhouse, else an opaque + string; the role's page is `jobs.gem.com//`), `title`, + `locations` (`name`, `city`, `isoCountry` as ISO alpha-3, `isRemote`) and + `job` (`department`, `locationType`, `employmentType`). No pay is stated + in the list.""" + out = [] + for p in postings: + title = (p.get("title") or "").strip() + ext_id = str(p.get("extId") or "") + if not title or not ext_id: + continue + locations = p.get("locations") or [] + places: list[str] = [] + for loc in locations: + place = str(loc.get("city") or loc.get("name") or "").strip() + if place and place not in places: + places.append(place) + job = p.get("job") or {} + remote = _REMOTE.get(str(job.get("locationType") or "").upper()) + if remote is None and locations and all(loc.get("isRemote") for loc in locations): + remote = "remote" + out.append({ + "source_id": ext_id, + "title": title, + "location": "; ".join(places), + "url": f"{careers_url(slug)}/{ext_id}", + "posted": None, # only the role's own query has a date + "department": str((job.get("department") or {}).get("name") or "").strip(), + "description": "", + "remote": remote, + "salary_text": "", + }) + return out + + +def detail(get: Get, slug: str, row: Row) -> dict[str, Any]: + """`oatsExternalJobPosting` of the role: `descriptionHtml` and + `firstPublishedTsSec` (epoch seconds). `compensationHtml` was null on the + roles read and is left alone.""" + role = _ask(get, "ExternalJobPosting", DETAIL_QUERY, + {"boardId": slug, "extId": row["source_id"]}, "oatsExternalJobPosting") + if not isinstance(role, dict): + raise ValueError(f"Gem has no role {row['source_id']} on {slug}") + text = html.unescape(strip_html(role.get("descriptionHtml") or "")) + return {"description": " ".join(text.split()), + "posted": parse_dt(role.get("firstPublishedTsSec"))} diff --git a/tests/fixtures/ats/gem-detail-1.json b/tests/fixtures/ats/gem-detail-1.json new file mode 100644 index 0000000..9589805 --- /dev/null +++ b/tests/fixtures/ats/gem-detail-1.json @@ -0,0 +1 @@ +{"data":{"oatsExternalJobPosting":{"id":"T2F0c0pvYlBvc3Q6MTA0NDAzNA==","title":"Staff AI Product Engineer (Prague/Brno/Remote EU)","descriptionHtml":"
Only the best engineers are being built here.
At Productboard, we are defining AI-first Product Engineering. Not as a one-time achievement, but as a baseline we raise every time we reach it. We remove every bottleneck as it surfaces and rebuild how product teams work from first principles, not just adding AI to existing workflows.
AI tools are everywhere now. Agents can write code. That\u2019s today\u2019s baseline.What we're building is the environment where the baseline makes you better: focused on outcomes, writing specs that agents build from, leveling up with every feature you ship.
We are defining what AI-native product development becomes. We're all in.

What you will build

You'd lead the architectural work that makes our codebase AI-native. Specifically:
  • Agent-native architecture standards. Clear API contracts, semantic naming, well-defined module boundaries. The patterns that keep AI effective as our systems grow.
  • A context infrastructure layer. Repo-versioned guidance that AI tools load automatically \u2014 improving the output of Cursor, Claude Code, and Codex simultaneously.
  • Self-healing workflows for incidents. Agents that triage alerts, pull logs, surface relevant history, suggest remediation. Humans intervene where judgment matters.
  • Agent workflows that go beyond chat. Multi-step reasoning, tool use, autonomous task execution with human-gated checkpoints \u2014 for product features, not internal demos.
  • Systematic optimization of AI code review. Earlier detection of correctness, security, and maintainability issues, with the noise filtered out before it reaches a human reviewer.

The opportunity

The first shift in our teams has already happened: agents write code. That\u2019s the baseline everywhere. Now we\u2019re building an AI-first Product Engineering organization where learning matters as much as shipping.
Only a few companies build a product that makes them better. What we\u2019re building next is a single place where work lives. Specs, plans, and full product context live in Productboard. There\u2019s a seamless loop between Spark, our AI agent, and the coding agents. Engineers can steer from anywhere and focus on directing the work instead of typing it all out.
Our own teams run on Productboard and Spark, so the feedback loop isn't a survey next quarter. It's the next conversation you overhear.
Imagine you ship a feature before lunch and by the afternoon, half the floor is working with it. Not in a demo, not on a roadmap slide: in our real work, minutes after you merged.
We feel the gaps our customers feel, and we close them first. Every feature goes straight to real product teams solving real problems, starting with ours.
We are looking for a Staff AI Engineer who wants to build this from the inside.

Why this matters for your career

Engineers own more. Not just the code: the outcome it drives.
You won't just use AI tools. You will shape the architecture that makes agents effective, define the workflows that make them reliable, and build the evaluation systems that make them trustworthy.
This is where you become a pure product engineer. Someone who owns the problem, the trade-offs, and the result, not just the implementation. Every maker has an orchestra. The craft is knowing what it should play. And we never outsource our thinking.
The skills you build here (designing codebases agents can work in confidently, writing specs that carry your judgment into every build, building evaluations that catch what AI misses) will define senior engineering for the next decade. What you learn here doesn't just make you faster today. It makes you more valuable for years to come.

What you will do

We're hiring a Staff AI Engineer to own the architectural layer that makes this real, working alongside our engineers, PMs, and designers shipping AI-first product features end-to-end. You'd ship code, set technical direction, and shape decisions about what's worth building. Your north star here will be: get from idea to validated learning twice as fast.

How we work

We've moved away from process and toward judgment. The shift looks like this:
  • One named driver per initiative. End-to-end ownership of the outcome, the path, the decisions, and the learnings. No approval chains. The driver decides; leadership unblocks.
  • One-page pre-reads as the unit of decision. Big work starts with a brief covering the problem, expected outcome, risks, and effort. Leadership reads it and decides. No 30-slide decks. No two-week alignment cycles.
  • Continuous delivery, no quarterly planning. Roadmap committed one month out. Beyond that, AI moves too fast for longer cycles to mean anything. We ship to internal first, then beta, then GA. Validation comes from real usage.
  • PMs and designers ship to production. Not just specs and Figma. They prototype with AI tools and ship alongside engineers. PMs own what gets built and when. Engineers own how.
If you've been a founding engineer or founder, this should feel familiar. If you've been waiting for a place that operates like that at scale, this is one.

About you

  • 6-10+ years of production software engineering experience
  • Strong backend skills in Python, Kotlin, or Java, with experience evolving service-level logic and infrastructure
  • Hands-on LLM experience in real products: prompt design, context management, evaluation, real understanding of trade-offs (hallucinations, latency, cost, reliability)
  • Comfort with distributed systems and event-driven architectures (queues, async processing, service-to-service communication)
  • Daily use of AI coding tools as a core part of your workflow \u2014 pushing them, refining prompts, knowing where they break
  • Strong fit: Former founding engineer or founder. A 0-to-1 engineer who turns business insights into prototypes to validate ideas quickly. Someone who's built agentic systems in production, or done deep work with multi-step LLM workflows (tool use, memory, orchestration).

Our tech stack

  • AI layer: Python, Pydantic AI, Braintrust
  • Frontend: TypeScript, React, Relay, GraphQL
  • Backend: Kotlin, Ruby (legacy services we're modernizing), with new services built in Kotlin
  • Storage: PostgreSQL, MongoDB, Elastic, Redis
  • Data pipeline: Python, Keboola, Looker, Snowflake
  • Infrastructure: AWS, Cloudflare, Kubernetes, Terraform

Our Compensation

Salary range: 2,295,000\u20133,305,000 CZK annually
  • Where most of our L4s sit:
    • Q1 (2.3M\u20132.55M) \u00b7 33%
    • Q2 (2.55M\u20132.8M) \u00b7 27%
    • Q3 (2.8M\u20133.05M) \u00b7 33%
    • Q4 (3.05M\u20133.3M) \u00b7 7%

Our benefits include

  • Stock options
  • MacBook + 34\u2033 monitor
  • Work from home stipend to support your home office setup
  • 5 weeks of vacation + 9 sick days
  • Flexible working hours and home office
  • Budget for online courses, books, and conferences
  • 2 weeks of fully paid parental leave
  • Fertility & Family-Building Support with Carrot
  • Mental Wellness Program with Soulmio to support your well-being and self-care
  • 1 Volunteer Day per year to support causes close to your heart, plus donation matching from Productboard
  • Free snacks, drinks, and yummy catered lunches from White Circus at the office every day
  • Free MultiSport card
  • On-site bouldering wall, boxing bag, and workout mats
  • Team events, such as happy hours, off-sites, and retreats
  • Free year-round access to Prague Zoo

Relocation Opportunities

If joining us means making a move, we're here to help make that transition easier.
Candidates must have the legal right to work in the EU. While we are unable to provide visa sponsorship for this role, we're happy to support relocation to Prague for candidates already authorized to work in the EU.
Relocation Support
We offer a one-time relocation bonus ranging from $6,000 to $13,000 USD, depending on your personal situation, whether you're moving on your own or with a partner or family.
This bonus is intended to help offset moving expenses and support your transition into your new city. While it may not cover every cost, it provides meaningful financial support as you get settled.
If you're thinking about relocating and want to explore what this could look like for you, we'd be happy to have that conversation.

About Productboard

Productboard is the leading intelligent product management platform, used by 6,000+ companies including Salesforce, SAP, Autodesk, and Kroger. Headquartered in San Francisco, with engineering hubs in Prague and Brno. Backed by Index Ventures, Kleiner Perkins, Sequoia Capital, Bessemer, Tiger Global, and Dragoneer.
We've spent the last decade building the foundation for how product teams work. We're now in our 0-to-1 moment again, building Productboard Spark \u2014 the AI-first, agentic experience that turns raw feedback and signals into clear problems, strong specs, and faster execution. Spark is what powers everything you'd be working on.
Are you building with us?
If the work above is what you want to spend the next chapter of your career on, apply below!
Equal Opportunity
Productboard is an equal opportunity employer. We are committed to an inclusive hiring process and consider all qualified applicants without discrimination based on characteristics protected by applicable law. If you require an accommodation during the hiring process, please contact peopleops@productboard.com.
By applying you agree to Productboard's Global Candidate Privacy Policy
","extId":"8080046002","firstPublishedTsSec":1753349342,"locations":[{"id":"38771","extId":"4029634002","name":"Prague (Hybrid)","city":"Prague","isoCountry":"CZE","isRemote":false}],"job":{"id":"T2F0c0pvYjo2MDYxMDY=","locationType":"HYBRID","employmentType":"FULL_TIME","requisitionId":"E-003","teamDisplayName":"Productboard","department":{"id":"37338","extId":"4065161002","name":"Product Engineering"}},"compensationHtml":null}}} \ No newline at end of file diff --git a/tests/fixtures/ats/gem-detail-2.json b/tests/fixtures/ats/gem-detail-2.json new file mode 100644 index 0000000..d1fc4b4 --- /dev/null +++ b/tests/fixtures/ats/gem-detail-2.json @@ -0,0 +1 @@ +{"data":{"oatsExternalJobPosting":{"id":"T2F0c0pvYlBvc3Q6NzU5NjA4Mg==","title":"Staff Fullstack DevX Engineer (Prague/Brno/Remote EU)","descriptionHtml":"
Only the best engineers are being built here.
At Productboard, we are defining AI-first Product Engineering. Not as a one-time achievement, but as a baseline we raise every time we reach it. We remove every bottleneck as it surfaces and rebuild how product teams work from first principles, not just adding AI to existing workflows.
AI tools are everywhere now. Agents can write code. That\u2019s today\u2019s baseline.What we're building is the environment where the baseline makes you better: focused on outcomes, writing specs that agents build from, leveling up with every feature you ship.
We are defining what AI-native product development becomes. We're all in.

What you will build

You'd lead the architectural work that makes our codebase AI-native. Specifically:
  • Agent-native architecture standards. Clear API contracts, semantic naming, well-defined module boundaries. The patterns that keep AI effective as our systems grow.
  • A context infrastructure layer. Repo-versioned guidance that AI tools load automatically \u2014 improving the output of Cursor, Claude Code, and Codex simultaneously.
  • Self-healing workflows for incidents. Agents that triage alerts, pull logs, surface relevant history, suggest remediation. Humans intervene where judgment matters.
  • Agent workflows that go beyond chat. Multi-step reasoning, tool use, autonomous task execution with human-gated checkpoints \u2014 for product features, not internal demos.
  • Systematic optimization of AI code review. Earlier detection of correctness, security, and maintainability issues, with the noise filtered out before it reaches a human reviewer.

The opportunity

The first shift in our teams has already happened: agents write code. That\u2019s the baseline everywhere. Now we\u2019re building an AI-first Product Engineering organization where learning matters as much as shipping.
Only a few companies build a product that makes them better. What we\u2019re building next is a single place where work lives. Specs, plans, and full product context live in Productboard. There\u2019s a seamless loop between Spark, our AI agent, and the coding agents. Engineers can steer from anywhere and focus on directing the work instead of typing it all out.
Our own teams run on Productboard and Spark, so the feedback loop isn't a survey next quarter. It's the next conversation you overhear.
Imagine you ship a feature before lunch and by the afternoon, half the floor is working with it. Not in a demo, not on a roadmap slide: in our real work, minutes after you merged.
We feel the gaps our customers feel, and we close them first. Every feature goes straight to real product teams solving real problems, starting with ours.
We are looking for a Staff Full-stack DevX Engineer who wants to build this from the inside.

Why this matters for your career

Engineers own more. Not just the code: the outcome it drives.
You won't just use AI tools. You will shape the architecture that makes agents effective, define the workflows that make them reliable, and build the evaluation systems that make them trustworthy.
This is where you become a pure product engineer. Someone who owns the problem, the trade-offs, and the result, not just the implementation. Every maker has an orchestra. The craft is knowing what it should play. And we never outsource our thinking.
The skills you build here (designing codebases agents can work in confidently, writing specs that carry your judgment into every build, building evaluations that catch what AI misses) will define senior engineering for the next decade. What you learn here doesn't just make you faster today. It makes you more valuable for years to come.

What you will do

  • Build and evolve Kotlin services and frameworks that streamline the inner loop (APIs, build/test tooling, automation, paved paths).
  • Maintain and improve our internal developer tool written in Golang.
  • Accelerate CI/CD: improve caching/parallelism, increase test reliability, and shorten feedback cycles.
  • Partner across teams to standardise workflows, enable self-serve integrations, and reduce cross-team friction.
  • Instrument and improve: define DX metrics (lead time, build time, flakiness), run experiments, and iterate based on data.
  • Improve reliability and safety with sensible defaults\u2014observability, guardrails, and secure-by-default patterns.
  • Make our codebase AI-ready: define clear module boundaries, improve API contracts, add semantic context, and build the structured documentation that makes AI agents more effective across every repo.
  • Design and implement agent workflows that go beyond chat: multi-step reasoning, tool use, autonomous task execution, and human-gated checkpoints.
  • Run experiments, validate with real users, and iterate based on evidence. We measure learning velocity, not just output
  • Collaborate closely with product managers and designers to shape what we build, not just how we build it. We expect a product mindset, not just technical execution.
  • Act as a knowledge multiplier, sharing what you learn across and beyond your team to raise the bar for everyone.

About you

  • 6-10+ years of professional engineering experience.
  • Experience with Kotlin/Java in production (JVM performance, testing, dependency management).
  • Solid grasp of cloud-native engineering (containers, Kubernetes; AWS/IaC a plus).
  • Pragmatic approach to developer platforms, internal tooling, and CI/CD at scale.
  • Nice to have: exposure to Go and interest in multi-language ecosystems.
  • Previous experience with working on developer or internal tooling.
  • Contributing to open source.
  • Strong communication skills and collaborative mindset.
  • Curiosity, adaptability, and a proactive, startup-friendly attitude.
  • Bring product thinking to engineering work. You can articulate why something matters for users, not just how it works technically.
  • Embrace AI as a daily tool in your own workflow. You use AI coding assistants, iterate on prompts, and constantly look for ways to move faster.
  • Are curious about what agent native architecture looks like: how to structure codebases, APIs, and documentation so AI agents can operate effectively at scale.

Our tech stack

  • Python for ML code
  • Celery and Kubernetes for pipeline orchestration
  • AWS, Docker, Helm, Kafka, Git, and CI/CD for real time services
  • LangGraph for agent orchestration, Braintrust for observability and evaluation
  • GraphQL, Postgres, Datadog, Sentry, and Looker
  • Business tools: Slack, Jira, Google suite, Zoom, Notion
  • Full Tech Stack

Our Compensation

Salary range: 2,295,000\u20133,305,000 CZK annually
  • Where most of our L4s sit:
    • Q1 (2.3M\u20132.55M) \u00b7 33%
    • Q2 (2.55M\u20132.8M) \u00b7 27%
    • Q3 (2.8M\u20133.05M) \u00b7 33%
    • Q4 (3.05M\u20133.3M) \u00b7 7%

Our benefits include

  • Stock options
  • MacBook + 34\u2033 monitor
  • Work from home stipend to support your home office setup
  • 5 weeks of vacation + 9 sick days
  • Flexible working hours and home office
  • Budget for online courses, books, and conferences
  • 2 weeks of fully paid parental leave
  • Fertility & Family-Building Support with Carrot
  • Mental Wellness Program with Soulmio to support your well-being and self-care
  • 1 Volunteer Day per year to support causes close to your heart, plus donation matching from Productboard
  • Free snacks, drinks, and yummy catered lunches from White Circus at the office every day
  • Free MultiSport card
  • On-site bouldering wall, boxing bag, and workout mats
  • Team events, such as happy hours, off-sites, and retreats
  • Free year-round access to Prague Zoo

Relocation Opportunities

If joining us means making a move, we're here to help make that transition easier.
Candidates must have the legal right to work in the EU. While we are unable to provide visa sponsorship for this role, we're happy to support relocation to Prague for candidates already authorized to work in the EU.
Relocation Support
We offer a one-time relocation bonus ranging from $6,000 to $13,000 USD, depending on your personal situation, whether you're moving on your own or with a partner or family.
This bonus is intended to help offset moving expenses and support your transition into your new city. While it may not cover every cost, it provides meaningful financial support as you get settled.
If you're thinking about relocating and want to explore what this could look like for you, we'd be happy to have that conversation.

About Productboard

Productboard is the leading intelligent product management platform, used by 6,000+ companies including Salesforce, SAP, Autodesk, and Kroger. Headquartered in San Francisco, with engineering hubs in Prague and Brno. Backed by Index Ventures, Kleiner Perkins, Sequoia Capital, Bessemer, Tiger Global, and Dragoneer.
We've spent the last decade building the foundation for how product teams work. We're now in our 0-to-1 moment again, building Productboard Spark \u2014 the AI-first, agentic experience that turns raw feedback and signals into clear problems, strong specs, and faster execution. Spark is what powers everything you'd be working on.
Are you building with us?
If the work above is what you want to spend the next chapter of your career on, apply below!
Equal Opportunity
Productboard is an equal opportunity employer. We are committed to an inclusive hiring process and consider all qualified applicants without discrimination based on characteristics protected by applicable law. If you require an accommodation during the hiring process, please contact peopleops@productboard.com.
By applying you agree to Productboard's Global Candidate Privacy Policy
","extId":"am9icG9zdDq5-IOakBvxHzWhMPnTzoPp","firstPublishedTsSec":1787574069,"locations":[{"id":"38771","extId":"4029634002","name":"Prague (Hybrid)","city":"Prague","isoCountry":"CZE","isRemote":false},{"id":"38772","extId":"4030754002","name":"Remote Europe","city":"Remote Europe","isoCountry":"CZE","isRemote":true},{"id":"38781","extId":"4051723002","name":"Brno (Hybrid)","city":"Brno","isoCountry":"CZE","isRemote":false}],"job":{"id":"T2F0c0pvYjo2NjA4ODU3","locationType":"HYBRID","employmentType":"FULL_TIME","requisitionId":"27-037","teamDisplayName":"Productboard","department":{"id":"37338","extId":"4065161002","name":"Product Engineering"}},"compensationHtml":null}}} \ No newline at end of file diff --git a/tests/fixtures/ats/gem.json b/tests/fixtures/ats/gem.json new file mode 100644 index 0000000..b7347cb --- /dev/null +++ b/tests/fixtures/ats/gem.json @@ -0,0 +1 @@ +{"data":{"oatsExternalJobPostings":{"jobPostings":[{"id":"T2F0c0pvYlBvc3Q6MTA0NDAzNA==","extId":"8080046002","title":"Staff AI Product Engineer (Prague/Brno/Remote EU)","locations":[{"id":"38771","name":"Prague (Hybrid)","city":"Prague","isoCountry":"CZE","isRemote":false,"extId":"4029634002"}],"job":{"id":"T2F0c0pvYjo2MDYxMDY=","department":{"id":"37338","name":"Product Engineering","extId":"4065161002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6NTY0ODcxMw==","extId":"am9icG9zdDpS7XehojHQK_NnncgSKWoQ","title":"Staff Full-stack Product Engineer (Prague/Brno/Remote EU)","locations":[{"id":"38771","name":"Prague (Hybrid)","city":"Prague","isoCountry":"CZE","isRemote":false,"extId":"4029634002"}],"job":{"id":"T2F0c0pvYjo2NjEyMTk=","department":{"id":"37338","name":"Product Engineering","extId":"4065161002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6NTY0ODcxNg==","extId":"am9icG9zdDqWC1V_RM7U6ORvTd1Iu64r","title":"Staff Backend Product Engineer (Prague/Brno/Remote EU)","locations":[{"id":"38771","name":"Prague (Hybrid)","city":"Prague","isoCountry":"CZE","isRemote":false,"extId":"4029634002"},{"id":"38772","name":"Remote Europe","city":"Remote Europe","isoCountry":"CZE","isRemote":true,"extId":"4030754002"},{"id":"38781","name":"Brno (Hybrid)","city":"Brno","isoCountry":"CZE","isRemote":false,"extId":"4051723002"}],"job":{"id":"T2F0c0pvYjoyMDg5NTcx","department":{"id":"37338","name":"Product Engineering","extId":"4065161002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6NzU2OTA5MQ==","extId":"am9icG9zdDpfq1dHcevndHGSzK_aYE1g","title":"Marketing Systems Operations Lead","locations":[{"id":"38780","name":"San Francisco","city":"San Francisco","isoCountry":"USA","isRemote":false,"extId":"4030598002"}],"job":{"id":"T2F0c0pvYjo2NTkyMzYy","department":{"id":"37379","name":"GTM Ops","extId":"4068217002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6NzU5NjA4Mg==","extId":"am9icG9zdDq5-IOakBvxHzWhMPnTzoPp","title":"Staff Fullstack DevX Engineer (Prague/Brno/Remote EU)","locations":[{"id":"38771","name":"Prague (Hybrid)","city":"Prague","isoCountry":"CZE","isRemote":false,"extId":"4029634002"},{"id":"38772","name":"Remote Europe","city":"Remote Europe","isoCountry":"CZE","isRemote":true,"extId":"4030754002"},{"id":"38781","name":"Brno (Hybrid)","city":"Brno","isoCountry":"CZE","isRemote":false,"extId":"4051723002"}],"job":{"id":"T2F0c0pvYjo2NjA4ODU3","department":{"id":"37338","name":"Product Engineering","extId":"4065161002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6NzYwMjE1NA==","extId":"am9icG9zdDoaMPkCxlUbsYDApcWCdyCP","title":"Staff Frontend Product Engineer (Prague/Brno/Remote EU)","locations":[{"id":"38771","name":"Prague (Hybrid)","city":"Prague","isoCountry":"CZE","isRemote":false,"extId":"4029634002"}],"job":{"id":"T2F0c0pvYjo2NjA4ODU4","department":{"id":"37338","name":"Product Engineering","extId":"4065161002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6NzYwMzc4Mg==","extId":"am9icG9zdDpGGIKW-IlxhJ2EnwVAtLRB","title":"Staff Full-stack Product Engineer, Growth (Prague/Brno/Remote EU) ","locations":[{"id":"38771","name":"Prague (Hybrid)","city":"Prague","isoCountry":"CZE","isRemote":false,"extId":"4029634002"}],"job":{"id":"T2F0c0pvYjo2NjEyMTk=","department":{"id":"37338","name":"Product Engineering","extId":"4065161002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6NzcyNzc0Ng==","extId":"am9icG9zdDq9ZHg3x3sdBTy6feA4MZ9f","title":"Digital Marketing Manager","locations":[{"id":"38780","name":"San Francisco","city":"San Francisco","isoCountry":"USA","isRemote":false,"extId":"4030598002"}],"job":{"id":"T2F0c0pvYjo2NjkyOTAw","department":{"id":"37358","name":"Digital Marketing","extId":"4076635002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6Nzk0NDYyMA==","extId":"am9icG9zdDp906RvIzQmjA9funJO3zB1","title":"AI Data Engineer","locations":[{"id":"38771","name":"Prague (Hybrid)","city":"Prague","isoCountry":"CZE","isRemote":false,"extId":"4029634002"},{"id":"38781","name":"Brno (Hybrid)","city":"Brno","isoCountry":"CZE","isRemote":false,"extId":"4051723002"}],"job":{"id":"T2F0c0pvYjo2ODE0MzAz","department":{"id":"37352","name":"Data","extId":"4076631002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6ODAzMTI0MQ==","extId":"am9icG9zdDqzuJaiLLHinwNQLMZuqlux","title":"Digital Marketing Specialist ","locations":[{"id":"38780","name":"San Francisco","city":"San Francisco","isoCountry":"USA","isRemote":false,"extId":"4030598002"}],"job":{"id":"T2F0c0pvYjo2NjkyOTAw","department":{"id":"37358","name":"Digital Marketing","extId":"4076635002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}},{"id":"T2F0c0pvYlBvc3Q6ODA1NTY3NQ==","extId":"am9icG9zdDrYRR2Ri8264a07xF_f9eI3","title":"AI Customer Success Engineer ","locations":[{"id":"38780","name":"San Francisco","city":"San Francisco","isoCountry":"USA","isRemote":false,"extId":"4030598002"}],"job":{"id":"T2F0c0pvYjo2ODc3MjM2","department":{"id":"37347","name":"Customer Success","extId":"4071103002"},"locationType":"HYBRID","employmentType":"FULL_TIME"}}]}}} \ No newline at end of file diff --git a/tests/test_ats_gem.py b/tests/test_ats_gem.py new file mode 100644 index 0000000..d42e617 --- /dev/null +++ b/tests/test_ats_gem.py @@ -0,0 +1,180 @@ +"""The Gem host module against Productboard's saved listing and two saved role +answers. No network.""" + +from __future__ import annotations + +import json +import sys +from datetime import UTC, datetime +from pathlib import Path +from typing import Any + +import httpx +import pytest + +ROOT = Path(__file__).resolve().parents[1] +if str(ROOT) not in sys.path: + sys.path.insert(0, str(ROOT)) + +from app.jobs import discover # noqa: E402 +from plugins import ats, atshosts # noqa: E402 +from plugins.atshosts import gem # noqa: E402 + +FIXTURES = ROOT / "tests" / "fixtures" / "ats" +API = "https://jobs.gem.com/api/public/graphql" + + +def _read(name: str) -> bytes: + return (FIXTURES / name).read_bytes() + + +def _get_of(answers: dict[str, bytes | Exception], asked: list[dict[str, Any]]) -> Any: + """A `get` that answers a GraphQL call by its operation name.""" + def get(url: str, *, method: str = "GET", payload: Any = None, + headers: dict[str, str] | None = None) -> bytes: + assert url == API and method == "POST" + asked.append(payload | {"headers": headers}) + answer = answers[payload["operationName"]] + if isinstance(answer, Exception): + raise answer + return answer + return get + + +def _listing() -> dict[str, bytes | Exception]: + return {"JobBoardList": _read("gem.json")} + + +def test_a_listing_becomes_rows() -> None: + asked: list[dict[str, Any]] = [] + decoded, results, total, cursor = gem.page(_get_of(_listing(), asked), "productboard", None) + assert asked == [{"operationName": "JobBoardList", "variables": {"boardId": "productboard"}, + "query": gem.LIST_QUERY, "headers": None}] + assert (total, cursor) == (None, None) and len(results) == 11 + rows = gem.rows(decoded, "productboard") + assert len(rows) == 11 + first, backend = rows[0], rows[2] + assert first["source_id"] == "8080046002" # numeric, from a synced Greenhouse + assert first["title"] == "Staff AI Product Engineer (Prague/Brno/Remote EU)" + assert first["url"] == "https://jobs.gem.com/productboard/8080046002" + assert first["department"] == "Product Engineering" and first["remote"] == "hybrid" + assert first["location"] == "Prague" + assert (first["posted"], first["description"], first["salary_text"]) == (None, "", "") + assert backend["source_id"] == "am9icG9zdDqWC1V_RM7U6ORvTd1Iu64r" # opaque + assert backend["location"] == "Prague; Remote Europe; Brno" + assert len({r["source_id"] for r in rows}) == 11 + + +@pytest.mark.parametrize(("kind", "flags", "remote"), [ + ("IN_OFFICE", [False], "onsite"), ("HYBRID", [True], "hybrid"), ("REMOTE", [False], "remote"), + (None, [True, True], "remote"), (None, [True, False], None), (None, [], None), + ("SOMETHING_NEW", [False], None)]) +def test_remote_is_the_location_type_then_the_locations( + kind: str | None, flags: list[bool], remote: str | None) -> None: + posting = {"extId": "1", "title": "Role", "job": {"locationType": kind}, + "locations": [{"city": "X", "isRemote": f} for f in flags]} + assert gem.rows([posting], "acme")[0]["remote"] == remote + + +def test_a_posting_without_a_title_or_an_ext_id_is_left_out() -> None: + assert gem.rows([{"extId": "1", "title": " "}, {"extId": "", "title": "Role"}], "acme") == [] + + +def test_the_board_is_read_through_the_app_without_origin_or_referer() -> None: + seen: list[httpx.Request] = [] + + def handler(request: httpx.Request) -> httpx.Response: + seen.append(request) + return httpx.Response(200, content=_read("gem.json")) + + with httpx.Client(transport=httpx.MockTransport(handler)) as client: + rows, complete = ats._fetch_rows(client, "gem:productboard") + assert len(rows) == 11 and complete + (request,) = seen + assert str(request.url) == API and request.method == "POST" + assert json.loads(request.content)["variables"] == {"boardId": "productboard"} + assert "origin" not in request.headers and "referer" not in request.headers + assert request.headers["content-type"] == "application/json" + + +def test_an_empty_board_is_complete_at_zero() -> None: + body = b'{"data":{"oatsExternalJobPostings":{"jobPostings":[]}}}' + with httpx.Client(transport=httpx.MockTransport( + lambda request: httpx.Response(200, content=body))) as client: + assert ats._fetch_rows(client, "gem:nobody") == ([], True) + + +@pytest.mark.parametrize(("body", "message"), [ + (b'{"errors":[{"message":"Cannot query field \\"extId\\""}]}', "refused: Cannot query field"), + (b'{"data":{"somethingElse":{}}}', "no oatsExternalJobPostings"), + (b'{"data":null}', "no oatsExternalJobPostings"), + (b'{"data":{"oatsExternalJobPostings":{"postings":[]}}}', "no jobPostings list"), + (b'{"data":{"oatsExternalJobPostings":null}}', "no jobPostings list"), + (b'[]', "not a Gem answer"), +]) +def test_an_answer_of_another_shape_fails_with_a_clear_error(body: bytes, message: str) -> None: + with pytest.raises(ValueError, match=message): + gem.page(_get_of({"JobBoardList": body}, []), "productboard", None) + + +def test_detail_reads_the_text_and_the_date() -> None: + row = {"source_id": "am9icG9zdDq5-IOakBvxHzWhMPnTzoPp"} + asked: list[dict[str, Any]] = [] + found = gem.detail(_get_of({"ExternalJobPosting": _read("gem-detail-2.json")}, asked), + "productboard", row) + assert asked[0]["operationName"] == "ExternalJobPosting" + assert asked[0]["variables"] == {"boardId": "productboard", "extId": row["source_id"]} + assert asked[0]["query"] == gem.DETAIL_QUERY + assert set(found) <= set(ats.DETAIL_FIELDS) + assert found["posted"] == datetime.fromtimestamp(1787574069, tz=UTC) + assert found["description"].startswith("Only the best engineers are being built here.") + assert "<" not in found["description"] and "&" not in found["description"] + + +def test_detail_of_a_role_that_is_not_there_raises() -> None: + body = b'{"data":{"oatsExternalJobPosting":null}}' + with pytest.raises(ValueError, match="no role gone on acme"): + gem.detail(_get_of({"ExternalJobPosting": body}, []), "acme", {"source_id": "gone"}) + + +def test_detail_reads_the_numeric_role_too() -> None: + found = gem.detail(_get_of({"ExternalJobPosting": _read("gem-detail-1.json")}, []), + "productboard", {"source_id": "8080046002"}) + assert found["posted"] == datetime.fromtimestamp(1753349342, tz=UTC) + assert found["description"] + + +def test_the_slug_the_urls_and_the_allow_list() -> None: + assert gem.KEEP_CASE + for slug in ("productboard", "Productboard", "senndertechnologies-gmbh", "a_b", "1"): + assert gem.slug_ok(slug) + assert gem.careers_url("Productboard") == "https://jobs.gem.com/Productboard" + assert gem.robots_page("productboard") == "https://jobs.gem.com/productboard" + allow = gem.allowed("productboard") + assert allow("jobs.gem.com") and allow("JOBS.gem.com") + assert not allow("gem.com") and not allow("productboard.gem.com") + assert not allow("jobs.gem.com.evil.example") and not allow("localhost") + assert atshosts.HOSTS["gem"] is gem and ats.HOSTS["gem"] == "Gem" + + +@pytest.mark.parametrize("slug", [ + "", "a@b", "a#b", "a?b", "..", ".", "a/b", "a%2fb", "a:443", "a b", " a", "a\n", "a\r\n", + "a.b", "127.0.0.1", "[::1]", "localhost.", "a\\b", "a\"b"]) +def test_a_hostile_slug_is_refused(slug: str) -> None: + assert not gem.slug_ok(slug) + assert not ats.is_known_target(f"gem:{slug}") + + +def test_a_local_word_as_a_slug_still_reaches_gems_host_only() -> None: + assert ats.is_known_target("gem:localhost") + allow = gem.allowed("localhost") + assert allow("jobs.gem.com") and not allow("localhost") + + +def test_discovery_finds_the_board_keeping_its_case() -> None: + page = ('Jobs' + 'x' + 'y') + assert [(h, s) for h, s, _ in discover.boards_in(page)] == [ + ("gem", "Productboard"), ("gem", "sennder-gmbh")] + assert "gem" not in {h for h, _ in discover._UNREADABLE if h not in atshosts.HOSTS}