MCPcopy
hub / github.com/getredash/redash / seedDatabase

Function seedDatabase

client/cypress/cypress.js:17–42  ·  view source on GitHub ↗
(seedValues)

Source from the content-addressed store, hash-verified

15const baseUrl = process.env.CYPRESS_baseUrl || cypressConfigBaseUrl || "http://localhost:5001";
16
17function seedDatabase(seedValues) {
18 get(baseUrl + "/login", (_, { headers }) => {
19 const request = seedValues.shift();
20 const data = request.type === "form" ? { formData: request.data } : { json: request.data };
21
22 if (headers["set-cookie"]) {
23 const cookies = headers["set-cookie"].map(cookie => new Cookie(cookie));
24 const csrfCookie = find(cookies, { key: "csrf_token" });
25 if (csrfCookie) {
26 if (request.type === "form") {
27 data["formData"] = { ...data["formData"], csrf_token: csrfCookie.value };
28 } else {
29 data["headers"] = { "X-CSRFToken": csrfCookie.value };
30 }
31 }
32 }
33
34 post(baseUrl + request.route, data, (err, response) => {
35 const result = response ? response.statusCode : err;
36 console.log("POST " + request.route + " - " + result);
37 if (seedValues.length) {
38 seedDatabase(seedValues);
39 }
40 });
41 });
42}
43
44function buildServer() {
45 console.log("Building the server...");

Callers 1

cypress.jsFile · 0.85

Calls 2

postFunction · 0.85
getFunction · 0.50

Tested by

no test coverage detected