Mock moving
This commit is contained in:
parent
dfcdcc296f
commit
0ac77cdb15
13 changed files with 219 additions and 528 deletions
|
@ -1,8 +1,11 @@
|
|||
import { useQuery } from "@tanstack/react-query";
|
||||
import { silencedMock } from "@qltr/mocks/alerting-mock.js";
|
||||
import { failingMock } from "@qltr/mocks/results-mock.js";
|
||||
import { testsMock, mappingsMock } from "@qltr/mocks/catalog-mock.js";
|
||||
|
||||
const QUALITEER_URL = "https://qualiteer.elijahparker3.repl.co/api";
|
||||
|
||||
const useMock = false;
|
||||
const useMock = true;
|
||||
|
||||
const asMock = (data) => ({ data });
|
||||
|
||||
|
@ -11,188 +14,20 @@ const fetchApi = (subPath) => async () =>
|
|||
|
||||
export const useCatalogTests = () =>
|
||||
useMock
|
||||
? asMock([
|
||||
{
|
||||
id: 0,
|
||||
name: "single",
|
||||
class: "single.js",
|
||||
image: "node:latest",
|
||||
isPipeline: false,
|
||||
type: "api",
|
||||
description: "This is a single test",
|
||||
tags: ["cron_1hour", "reg_us", "env_ci", "proj_core", "skip_alt"],
|
||||
path: "tests/assets/suite/single.js",
|
||||
created: Date.now(),
|
||||
mergeRequest: "https://example.com",
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: "failing",
|
||||
class: "failing.js",
|
||||
image: "node:latest",
|
||||
isPipeline: false,
|
||||
type: "ui",
|
||||
description: "This is a failing test",
|
||||
tags: ["cron_1hour", "reg_us", "env_ci", "proj_core"],
|
||||
path: "tests/assets/suite/failing.js",
|
||||
created: Date.now(),
|
||||
mergeRequest: "https://example.com",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "primary",
|
||||
class: "primary.js",
|
||||
image: "node:latest",
|
||||
isPipeline: true,
|
||||
type: "api",
|
||||
description: "This is a primary test",
|
||||
tags: [
|
||||
"cron_1hour",
|
||||
"reg_us",
|
||||
"proj_core",
|
||||
"skip_alt",
|
||||
"pipeline_secondary1",
|
||||
],
|
||||
path: "tests/assets/suite/primary.js",
|
||||
created: Date.now(),
|
||||
mergeRequest: "https://example.com",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "secondary1",
|
||||
class: "secondary1.js",
|
||||
image: "node:latest",
|
||||
isPipeline: true,
|
||||
type: "api",
|
||||
description: "This is a secondary test",
|
||||
tags: [
|
||||
"cron_1hour",
|
||||
"reg_us",
|
||||
"proj_core",
|
||||
"compound_tertiary1",
|
||||
"compound_tertiary2",
|
||||
],
|
||||
path: "tests/assets/suite/secondary1.js",
|
||||
created: Date.now(),
|
||||
mergeRequest: "https://example.com",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: "secondary2",
|
||||
class: "secondary2.js",
|
||||
image: "node:latest",
|
||||
isPipeline: true,
|
||||
type: "api",
|
||||
description: "This is a secondary2 test",
|
||||
tags: ["cron_1hour", "reg_us", "proj_core", "compound_tertiary3"],
|
||||
path: "tests/assets/suite/secondary2.js",
|
||||
created: Date.now(),
|
||||
mergeRequest: "https://example.com",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "tertiary1",
|
||||
class: "tertiary1.js",
|
||||
image: "node:latest",
|
||||
isPipeline: true,
|
||||
type: "api",
|
||||
description: "This is a third test",
|
||||
tags: ["cron_1hour", "reg_us", "proj_core"],
|
||||
path: "tests/assets/suite/tertiary1.js",
|
||||
created: Date.now(),
|
||||
mergeRequest: "https://example.com",
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: "tertiary2",
|
||||
class: "tertiary2.js",
|
||||
image: "node:latest",
|
||||
isPipeline: true,
|
||||
type: "api",
|
||||
description: "This is a third2 test",
|
||||
tags: ["cron_1hour", "reg_us", "proj_core"],
|
||||
path: "tests/assets/suite/tertiary2.js",
|
||||
created: Date.now(),
|
||||
mergeRequest: "https://example.com",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: "tertiary3",
|
||||
class: "tertiary3.js",
|
||||
image: "node:latest",
|
||||
isPipeline: true,
|
||||
type: "api",
|
||||
description: "This is a third3 test",
|
||||
tags: ["cron_1hour", "reg_us", "proj_core"],
|
||||
path: "tests/assets/suite/tertiary3.js",
|
||||
created: Date.now(),
|
||||
mergeRequest: "https://example.com",
|
||||
},
|
||||
])
|
||||
? asMock(testsMock())
|
||||
: useQuery(["catalogTests"], fetchApi("/catalog/tests"));
|
||||
|
||||
export const usePipelineMappings = () =>
|
||||
useMock
|
||||
? asMock([
|
||||
[
|
||||
{ name: "primary", delay: 0 },
|
||||
{ name: "secondary1", delay: 1000 },
|
||||
{ name: "tertiary1", delay: 0 },
|
||||
],
|
||||
[
|
||||
{ name: "primary", delay: 0 },
|
||||
{ name: "secondary1", delay: 1000 },
|
||||
{ name: "tertiary2", delay: 8000 },
|
||||
],
|
||||
[
|
||||
{ name: "primary", delay: 0 },
|
||||
{ name: "secondary2", delay: 20000 },
|
||||
{ name: "tertiary3", delay: 3000 },
|
||||
],
|
||||
])
|
||||
? asMock(mappingsMock())
|
||||
: useQuery(["pipelineMappings"], fetchApi("/catalog/pipeline-mappings"));
|
||||
|
||||
export const useSilencedAlerts = () =>
|
||||
useMock
|
||||
? asMock([
|
||||
{
|
||||
name: `failing`,
|
||||
class: `failing.js`,
|
||||
method: "FAKEMETHOD",
|
||||
id: 0,
|
||||
silencedUntil: new Date().toJSON(),
|
||||
},
|
||||
])
|
||||
? asMock(silencedMock())
|
||||
: useQuery(["silenced"], fetchApi("/alerting/silenced"));
|
||||
|
||||
export const useCurrentlyFailing = () =>
|
||||
useMock
|
||||
? asMock([
|
||||
{
|
||||
name: "failing",
|
||||
class: "failing.js",
|
||||
timestamp: new Date().toJSON(),
|
||||
method: "FAKEMETHOD",
|
||||
cron: "1hour",
|
||||
type: "api",
|
||||
dailyFails: 12,
|
||||
screenshot: "https://picsum.photos/1920/1080",
|
||||
recentResults: [1, 0, 0, 1, 0],
|
||||
isPipeline: false,
|
||||
failedMessage: `Some Test FailureMessage`,
|
||||
},
|
||||
{
|
||||
name: "secondary1",
|
||||
class: "secondary1.js",
|
||||
timestamp: new Date().toJSON(),
|
||||
method: "FAKEMETHOD",
|
||||
cron: "1hour",
|
||||
type: "api",
|
||||
dailyFails: 1,
|
||||
screenshot: "https://picsum.photos/1920/1080",
|
||||
recentResults: [1, 0, 0, 1, 0],
|
||||
isPipeline: true,
|
||||
failedMessage: `Some Test FailureMessage from Secondary1`,
|
||||
},
|
||||
])
|
||||
? asMock(failingMock())
|
||||
: useQuery(["failing"], fetchApi("/results/failing"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue