Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/DataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export default {
getDataSource(dataSourceId, params, nonce = null) {
// keep backwards compatibility
if (
!params.cache &&
!window.ProcessMaker.screen.cacheEnabled &&
!window.ProcessMaker.screen.cacheTimeout
) {
Expand All @@ -226,6 +227,7 @@ export default {
url += this.authQueryString();
return this.get(url, {
useCache: window.ProcessMaker.screen.cacheEnabled,
cache: params.cache,
params: {
pmds_config: JSON.stringify(params.config),
pmds_data: JSON.stringify(params.data)
Expand Down
11 changes: 11 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ window.ProcessMaker = {
}
}
});
} else if (url === "/requests/data_sources/1/resources/list/data") {
resolve({
data: {
response: [
{ value: 1, content: "James" },
{ value: 2, content: "John" },
{ value: 3, content: "Mary" },
{ value: 4, content: "Patricia" }
]
}
});
} else if (url === "/data_sources") {
resolve({
data: {
Expand Down
141 changes: 74 additions & 67 deletions tests/e2e/specs/SelectListCollection.spec.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,87 @@
describe("select list mustache", () => {
beforeEach(() => {
cy.visit("/");
cy.intercept(
"POST",
"/api/1.0/requests/data_sources/2",
JSON.stringify({
status: 200,
response: {
data: [
{
id: 1,
created_by_id: 2,
updated_by_id: 2,
created_at: "2021-11-08 10:29:56",
updated_at: "2021-11-08 10:29:56",
data: {
dni: "1234",
name: {
last: "Smith",
first: "Oliver"
},
id: 1
const dataSourceResponse = {
status: 200,
response: {
data: [
{
id: 1,
created_by_id: 2,
updated_by_id: 2,
created_at: "2021-11-08 10:29:56",
updated_at: "2021-11-08 10:29:56",
data: {
dni: "1234",
name: {
last: "Smith",
first: "Oliver"
},
collection_id: 1,
title: "1",
created_by: {
id: 2,
email: "admin@processmaker.com"
},
updated_by: {
id: 2,
email: "admin@processmaker.com"
}
id: 1
},
{
collection_id: 1,
title: "1",
created_by: {
id: 2,
created_by_id: 2,
updated_by_id: 2,
created_at: "2021-11-08 10:29:56",
updated_at: "2021-11-08 10:29:56",
data: {
dni: "5678",
name: {
last: "Doe",
first: "John"
},
id: 2
},
collection_id: 1,
title: "2",
created_by: {
id: 2,
email: "admin@processmaker.com"
email: "admin@processmaker.com"
},
updated_by: {
id: 2,
email: "admin@processmaker.com"
}
},
{
id: 2,
created_by_id: 2,
updated_by_id: 2,
created_at: "2021-11-08 10:29:56",
updated_at: "2021-11-08 10:29:56",
data: {
dni: "5678",
name: {
last: "Doe",
first: "John"
},
updated_by: {
id: 2,
email: "admin@processmaker.com"
}
id: 2
},
collection_id: 1,
title: "2",
created_by: {
id: 2,
email: "admin@processmaker.com"
},
updated_by: {
id: 2,
email: "admin@processmaker.com"
}
],
meta: {
filter: "",
sort_by: "",
sort_order: "",
count: 2,
total_pages: 1,
current_page: 1,
from: 1,
last_page: 1,
path: "/api/1.0/collections/1/records",
per_page: 9223372036854775807,
to: 2,
total: 2
}
],
meta: {
filter: "",
sort_by: "",
sort_order: "",
count: 2,
total_pages: 1,
current_page: 1,
from: 1,
last_page: 1,
path: "/api/1.0/collections/1/records",
per_page: 9223372036854775807,
to: 2,
total: 2
}
})
}
};

cy.intercept(
"POST",
"/api/1.0/requests/data_sources/2",
JSON.stringify(dataSourceResponse)
).as("executeScript");
cy.intercept(
"GET",
"/api/1.0/requests/data_sources/2/resources/ListAll/data*",
JSON.stringify(dataSourceResponse)
).as("executeScript");
});

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/SelectListDataSource.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ describe("Select List with DataSource", () => {
beforeEach(() => {
cy.visit("/");
cy.intercept(
"POST",
"/api/1.0/requests/data_sources/2",
"GET",
"/api/1.0/requests/data_sources/2/resources/ListAll/data*",
JSON.stringify({
status: 200,
response: {
Expand Down
99 changes: 39 additions & 60 deletions tests/e2e/specs/SelectListDependent.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
describe("select list mustache", () => {
beforeEach(() => {
cy.visit("/");
const getOutboundConfigValue = (req) => {
const config = JSON.parse(req.query.pmds_config || "{}");
return config.outboundConfig && config.outboundConfig[0]
? config.outboundConfig[0].value
: null;
};

const dataSourceResponse = (data, path) => ({
data,
meta: {
filter: "",
sort_by: "",
sort_order: "",
count: data.length,
total_pages: 1,
current_page: 1,
from: 1,
last_page: 1,
path,
per_page: 9223372036854775807,
to: data.length,
total: data.length
}
});

cy.intercept(
"POST",
"/api/1.0/requests/data_sources/3",
JSON.stringify({
status: 200,
response: {
data: [
"GET",
"/api/1.0/requests/data_sources/3/resources/ListAll/data*",
{
response: dataSourceResponse(
[
{
id: 1,
created_by_id: 2,
Expand Down Expand Up @@ -51,22 +75,9 @@ describe("select list mustache", () => {
}
}
],
meta: {
filter: "",
sort_by: "",
sort_order: "",
count: 2,
total_pages: 1,
current_page: 1,
from: 1,
last_page: 1,
path: "/api/1.0/collections/3/records",
per_page: 9223372036854775807,
to: 2,
total: 2
}
}
})
"/api/1.0/collections/3/records"
)
}
).as("executeScript");
// Bolivia Cities
const BoliviaCities = [
Expand Down Expand Up @@ -159,8 +170,8 @@ describe("select list mustache", () => {
}
];
let cities = [];
cy.intercept("POST", "/api/1.0/requests/data_sources/4", (req) => {
switch (req.body.config.outboundConfig[0].value) {
cy.intercept("GET", "/api/1.0/requests/data_sources/4/resources/ListAll/data*", (req) => {
switch (getOutboundConfigValue(req)) {
case "data.country_id=1":
cities = BoliviaCities;
break;
Expand All @@ -170,23 +181,7 @@ describe("select list mustache", () => {
default:
cities = [];
}
const response = {
data: cities,
meta: {
filter: "",
sort_by: "",
sort_order: "",
count: cities.length,
total_pages: 1,
current_page: 1,
from: 1,
last_page: 1,
path: "/api/1.0/collections/4/records",
per_page: 9223372036854775807,
to: cities.length,
total: cities.length
}
};
const response = dataSourceResponse(cities, "/api/1.0/collections/4/records");
req.reply({
headers: {
"X-Cypress-Response": `"response":${JSON.stringify(response)}}`
Expand Down Expand Up @@ -381,8 +376,8 @@ describe("select list mustache", () => {
];

let addresses = [];
cy.intercept("POST", "/api/1.0/requests/data_sources/5", (req) => {
switch (req.body.config.outboundConfig[0].value) {
cy.intercept("GET", "/api/1.0/requests/data_sources/5/resources/ListAll/data*", (req) => {
switch (getOutboundConfigValue(req)) {
case "data.city_id=1":
addresses = LaPazAddresses;
break;
Expand All @@ -398,23 +393,7 @@ describe("select list mustache", () => {
default:
addresses = [];
}
const response = {
data: addresses,
meta: {
filter: "",
sort_by: "",
sort_order: "",
count: addresses.length,
total_pages: 1,
current_page: 1,
from: 1,
last_page: 1,
path: "/api/1.0/collections/5/records",
per_page: 9223372036854775807,
to: addresses.length,
total: addresses.length
}
};
const response = dataSourceResponse(addresses, "/api/1.0/collections/5/records");
req.reply({
headers: {
"X-Cypress-Response": `"response":${JSON.stringify(response)}}`
Expand Down
Loading
Loading