I am currently trying to create a test that will check all privileges based on the array of objects passed in for an application. The idea is I would pass in the array and identify within each key the access and the type and then select those elements on the webpage. I am not sure what the correct looping structure is for this as I feel a nested loop within a loop is wrong. My example is below. The Page object is just a quick mock of what I currently was thinking of for handling the inner loop by no means a final product. I believe there is a better way possibly leveraging Cypress more but am unsure how any insight is appreciated
// Spec Test
const permissions = [
"overview page" : {
view: false,
create: false,
edit: true,
},
"campaigns" : {
view: false,
create: false,
edit: true,
}
]
permissionPage.setPermissions(permissions)
//Page object
const permissions = [];
for (const [key, value] of Permissions.entries(permissions)) {
cy.get("tr").children("td").contains(key).parents("tr").children("td");
if (value === true) {
cy.clickOn(key)
}
}
}