View | Details | Raw Unified | Return to bug 38503
Collapse All | Expand All

(-)a/package.json (-1 / +3 lines)
Lines 9-14 Link Here
9
  "dependencies": {
9
  "dependencies": {
10
    "@cypress/vue": "^3.1.1",
10
    "@cypress/vue": "^3.1.1",
11
    "@cypress/webpack-dev-server": "^1.8.3",
11
    "@cypress/webpack-dev-server": "^1.8.3",
12
    "@faker-js/faker": "^9.2.0",
12
    "@fortawesome/fontawesome-svg-core": "^6.1.0",
13
    "@fortawesome/fontawesome-svg-core": "^6.1.0",
13
    "@fortawesome/free-solid-svg-icons": "^6.0.0",
14
    "@fortawesome/free-solid-svg-icons": "^6.0.0",
14
    "@fortawesome/vue-fontawesome": "^3.0.0-5",
15
    "@fortawesome/vue-fontawesome": "^3.0.0-5",
Lines 42-48 Link Here
42
    "vue": "^3.2.31",
43
    "vue": "^3.2.31",
43
    "vue-flatpickr-component": "^9",
44
    "vue-flatpickr-component": "^9",
44
    "vue-router": "^4.0.14",
45
    "vue-router": "^4.0.14",
45
    "vue-select": "4.0.0-beta.3"
46
    "vue-select": "4.0.0-beta.3",
47
    "yaml": "^2.6.1"
46
  },
48
  },
47
  "scripts": {
49
  "scripts": {
48
    "css:build": "gulp css && gulp css --view opac",
50
    "css:build": "gulp css && gulp css --view opac",
(-)a/t/cypress/integration/t/mockData.ts (+9 lines)
Line 0 Link Here
1
import { mount } from "@cypress/vue";
2
3
describe("Generate Random Patron", () => {
4
    it("should generate a random patron from the schema", () => {
5
        cy.task("buildSamplePatron").then(mockPatron => {
6
            expect(mockPatron).to.have.property("patron_id");
7
        });
8
    });
9
});
(-)a/t/cypress/plugins/index.js (-13 / +22 lines)
Lines 1-19 Link Here
1
const { startDevServer } = require('@cypress/webpack-dev-server')
1
const { startDevServer } = require("@cypress/webpack-dev-server");
2
const webpackConfig = require('@vue/cli-service/webpack.config.js')
2
const webpackConfig = require("@vue/cli-service/webpack.config.js");
3
3
4
module.exports = (on, config) => {
4
module.exports = (on, config) => {
5
  on('dev-server:start', options =>
5
    on("dev-server:start", options =>
6
    startDevServer({
6
        startDevServer({
7
      options,
7
            options,
8
      webpackConfig
8
            webpackConfig,
9
    })
9
        })
10
  )
10
    );
11
11
12
  return config
12
    return config;
13
}
13
};
14
14
15
const mysql = require('cypress-mysql');
15
const mysql = require("cypress-mysql");
16
16
17
module.exports = (on, config) => {
17
module.exports = (on, config) => {
18
  mysql.configurePlugin(on);
18
    mysql.configurePlugin(on);
19
}
19
};
20
21
const { buildSamplePatron } = require("./mockData.js");
22
23
module.exports = (on, config) => {
24
    on("task", {
25
        buildSamplePatron,
26
    });
27
    return config;
28
};
(-)a/t/cypress/plugins/mockData.js (+39 lines)
Line 0 Link Here
1
const { faker } = require("@faker-js/faker");
2
const { readYamlFile } = require("./../plugins/readYamlFile.js");
3
4
const generateMockData = type => {
5
    switch (type) {
6
        case "string":
7
            return faker.lorem.words(3);
8
        case "integer":
9
            return faker.number.int();
10
        case "boolean":
11
            return faker.datatype.boolean();
12
        case "array":
13
            return [faker.lorem.word(), faker.lorem.word()];
14
        case "number":
15
            return faker.number.float();
16
        default:
17
            return faker.lorem.word();
18
    }
19
};
20
21
const generateDataFromSchema = properties => {
22
    const mockData = {};
23
    Object.entries(properties).forEach(([key, value]) => {
24
        mockData[key] = generateMockData(value.type);
25
    });
26
    return mockData;
27
};
28
29
const buildSamplePatron = () => {
30
    const yamlPath = "api/v1/swagger/definitions/patron.yaml";
31
    const schema = readYamlFile(yamlPath);
32
    return generateDataFromSchema(schema.properties);
33
};
34
35
module.exports = {
36
    generateMockData,
37
    generateDataFromSchema,
38
    buildSamplePatron,
39
};
(-)a/t/cypress/plugins/readYamlFile.js (-1 / +14 lines)
Line 0 Link Here
0
- 
1
const path = require("path");
2
const fs = require("fs");
3
const yaml = require("yaml");
4
5
const readYamlFile = filePath => {
6
    const absolutePath = path.resolve(filePath);
7
    if (!fs.existsSync(absolutePath)) {
8
        throw new Error(`File not found: ${absolutePath}`);
9
    }
10
    const fileContent = fs.readFileSync(absolutePath, "utf8");
11
    return yaml.parse(fileContent);
12
};
13
14
module.exports = { readYamlFile };

Return to bug 38503