it_solutions_test/scripts/smoke.mjs
Илья Братских bd22447bd3 Add a GraphQL digital card that migrates and seeds itself on startup.
The NestJS API serves the public profile through Apollo Sandbox and loads only the relations selected by the query.
2026-11-02 05:30:54 +03:00

42 lines
1.0 KiB
JavaScript

const url = process.env.GRAPHQL_URL ?? 'http://127.0.0.1:3000/graphql';
const query = `query {
profile {
name
description
skills { name }
experience { company position }
projects { name url }
}
}`;
const response = await fetch(url, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ query }),
});
const body = await response.json();
if (!response.ok || body.errors) {
console.error(JSON.stringify(body, null, 2));
process.exit(1);
}
const profile = body.data.profile;
const linked = profile.projects.some(
(project) => typeof project.url === 'string' && project.url.includes('github.com'),
);
if (
profile.name !== 'Илья Братских' ||
profile.skills.length === 0 ||
profile.experience.length === 0 ||
!linked
) {
console.error(JSON.stringify(profile, null, 2));
process.exit(1);
}
console.log(
`OK ${profile.name}: ${profile.skills.length} skills, ${profile.experience.length} jobs, ${profile.projects.length} projects`,
);