Fixed qs syntax to include the timestamp correcly in requests.

This commit is contained in:
Thoscellen
2019-08-23 11:21:02 +02:00
parent f852ffce0b
commit bb819b15b5
3 changed files with 50 additions and 49 deletions

View File

@@ -1,39 +1,41 @@
Cypress.Commands.add('login', function (user) {
if(user === undefined) throw new Error("Login via API failed because the user credential was not given.");
if (user === undefined) throw new Error("Login via API failed because the user credential was not given.");
cy.request({
method: 'POST',
url: "/online/api/auth?t=" + new Date().getTime(),
body: user
url: "/online/api/auth",
body: user,
qs: { "t": new Date().getTime() }
}).as("response")
});
Cypress.Commands.add('logout', function () {
cy.request({
method: 'GET',
url: "/online/logout",
});
})
Cypress.Commands.add('addFeed', function (arrayOfFeed) {
arrayOfFeed.forEach(element => {
if (cy.getCookie("session") != null) {
cy.request({
method: 'POST',
url: "/online/api/feed?t=" + new Date().getTime(),
body: {
"category": element.category,
"feed": element.feed
}
}).then((response) => {
if (response.status == 200) {
// collect data :
// id : number like 3911929
// category : number or 0 if not defined
}
})
});
method: 'GET',
url: "/online/logout",
qs: { "t": new Date().getTime() }
}).as("response");
}
})
Cypress.Commands.add('removeFeed', function () {
Cypress.Commands.add('addFeed', function (aFeed) {
cy.request({
method: 'POST',
url: "/online/api/feed",
body: {
"category": aFeed.category,
"feed": aFeed.feed
},
qs: { "t": new Date().getTime() }
}).then((response) => {
if (response.status == 200) {
// collect data :
// id : number like 3911929
// category : number or 0 if not defined
}
})
})
Cypress.Commands.add('removeFeed', function (aFeedId) {
})