Skip to content
Snippets Groups Projects

Add storybook and tests ICSHWI-9199

Merged John Sparger requested to merge add-storybook-and-tests-ICSHWI-9199 into develop
All threads resolved!
2 files
+ 16
13
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 15
13
@@ -21,7 +21,7 @@ export function mockAPI() {
cy.intercept("GET", /.*\/deployments\/\d+/, getDeployment).as("getDeployment")
cy.intercept("GET", /.*\/deployments\/jobs\/\d+/, getDeploymentJob).as("getDeploymentJob")
cy.intercept("GET", /.*\/deployments\/jobs\/\d+\/log/, auth(getDeploymentJobLog)).as("getDeploymentJobLog")
// commands
cy.intercept("GET", /.*\/deployments\/commands/, getCommandList).as("getCommandList")
@@ -33,11 +33,13 @@ export function mockAPI() {
}
function getParameters(req, pattern) {
const match = matchPath({
path: "/api/v1" + pattern,
exact: true,
strict: false
}, new URL(req.url).pathname);
const match = matchPath(
new URL(req.url).pathname,
{
path: "/api/v1" + pattern,
exact: true,
strict: false
});
return match?.params;
}
@@ -58,7 +60,7 @@ function isLoggedIn(req) {
}
function auth(routeHandler) {
return function(req) {
return function (req) {
if (isLoggedIn(req)) {
routeHandler(req);
}
@@ -84,7 +86,7 @@ function userInfo(req) {
}
function renew(req) {
req.reply({token: "FADEDEAD"});
req.reply({ token: "FADEDEAD" });
}
function listIOCs(req) {
@@ -96,7 +98,7 @@ function getIOC(req) {
const params = getParameters(req, "/iocs/:id")
const data = require("./fixtures/IOCDetails.json")
const d = data.find(x => x.id === parseInt(params.id));
const response = d ? d : {statusCode: 404};
const response = d ? d : { statusCode: 404 };
req.reply(response);
}
@@ -104,7 +106,7 @@ function getDeployment(req) {
const params = getParameters(req, "/deployments/:id")
const data = require("./fixtures/DeploymentInfoDetails.json");
const d = data.find(x => x.id === parseInt(params.id));
const response = d ? d : {statusCode: 404};
const response = d ? d : { statusCode: 404 };
req.reply(response);
}
@@ -112,7 +114,7 @@ function getDeploymentJob(req) {
const params = getParameters(req, "/deployments/jobs/:id");
const data = require("./fixtures/AwxJobDetails.json");
const d = data.find(x => x.id === parseInt(params.id));
const response = d ? d : {statusCode: 404};
const response = d ? d : { statusCode: 404 };
req.reply(response);
}
@@ -122,7 +124,7 @@ function getDeploymentJobLog(req) {
const index = jobDetailsData.findIndex(x => x.id === parseInt(params.id))
const logData = require("./fixtures/AwxJobLog.json");
const d = logData[index];
const response = d ? d : {statusCode: 404};
const response = d ? d : { statusCode: 404 };
req.reply(response);
}
@@ -135,7 +137,7 @@ function getCSEntryHostWithStatus(req) {
const params = getParameters(req, "/hosts/with-status/:id")
const data = require("./fixtures/CSEntryHostWithStatus.json");
const d = data.find(x => x.csEntryHost.id === parseInt(params.id));
const response = d ? d : {statusCode: 404};
const response = d ? d : { statusCode: 404 };
req.reply(response);
}
Loading