Commit 23a3b4b4 authored by Mehmet-Ali Pamukci's avatar Mehmet-Ali Pamukci Committed by Curtis Adam

fix some timing problems

parent b807e0c3
......@@ -15,17 +15,21 @@ module.exports = function () {
});
this.Given(/^user is in the back end$/, function () {
browser.waitForExist("#adminpanel", 5000);
browser.url('http://localhost:3000/admin/dashboard');
browser.waitForVisible('a.cc_btn.cc_btn_accept_all',5000);
browser.click('a.cc_btn.cc_btn_accept_all');
browser.waitForVisible("#adminpanel", 5000);
browser.click('#adminpanel');
});
this.When(/^user goes to the menu item cardsets$/, function () {
browser.url('http://localhost:3000/admin/cardsets');
browser.waitForVisible("a[href='/admin/cardsets']",5000);
browser.click("a[href='/admin/cardsets']");
});
this.When(/^user clicks on the delete button$/, function () {
browser.waitForExist('.delete', 5000);
browser.waitForVisible(".deleteCardsetAdmin");
browser.click(".deleteCardsetAdmin");
browser.waitForVisible("#cardsetConfirmModalAdmin", 5000);
browser.click("#cardetDeleteAdmin");
......@@ -33,8 +37,8 @@ module.exports = function () {
this.Then(/^the cardset should not be in the list anymore$/, function () {
browser.waitForVisible("#cardsetConfirmModalAdmin", 5000, true);
browser.pause(1000);
browser.waitForVisible('.delete');
var elements = browser.elements(".delete");
expect(elements.value.length - 1).toEqual(numberOfCardsets - 1);
......
......@@ -12,18 +12,22 @@ module.exports = function () {
});
this.Given(/^user is in the back end$/, function () {
browser.waitForExist("#adminpanel", 5000);
browser.url('http://localhost:3000/admin/dashboard');
browser.waitForVisible('a.cc_btn.cc_btn_accept_all',5000);
browser.click('a.cc_btn.cc_btn_accept_all');
browser.waitForVisible("#adminpanel", 5000);
browser.click("#adminpanel");
});
this.When(/^user goes to the menu item college$/, function () {
browser.url('http://localhost:3000/admin/settings');
browser.waitForVisible("a[href='/admin/university']",5000);
browser.click("a[href='/admin/university']");
});
this.When(/^user creates a new college and course$/, function () {
browser.waitForExist('#college', 5000);
browser.setValue('#college', 'THM');
browser.setValue('#courseOfStudies', 'MSP');
browser.waitForVisible('#insertButton');
browser.click("#insertButton");
});
......
......@@ -17,39 +17,38 @@ module.exports = function () {
});
this.Given(/^change to cardset$/, function () {
// Write code here that turns the phrase above into concrete actions
browser.pause(2000);
browser.url('http://localhost:3000/cardset/2P6mg5iqCZ49QPPDz');
browser.waitForVisible('a.cc_btn.cc_btn_accept_all',5000);
browser.click('a.cc_btn.cc_btn_accept_all');
browser.waitForVisible('#cardsets',5000);
browser.click('#cardsets');
browser.waitForVisible("a[href='/cardset/2P6mg5iqCZ49QPPDz']",5000);
browser.click("a[href='/cardset/2P6mg5iqCZ49QPPDz']");
browser.waitForExist('.cardsetInfo', 5000);
});
this.Then(/^they are on the cardset$/, function () {
// Write code here that turns the phrase above into concrete actions
browser.waitForExist('.cardsetInfo', 5000);
});
this.Then(/^they change the view to cardlist$/, function () {
// Write code here that turns the phrase above into concrete actions
browser.waitForVisible('#btnToListLayout',5000);
browser.click('#btnToListLayout');
});
this.Then(/^they see the cardlist$/, function () {
// Write code here that turns the phrase above into concrete actions
browser.waitForExist('#set-details-region', 5000);
});
this.Then(/^they change the view back to cardset$/, function () {
// Write code here that turns the phrase above into concrete actions
browser.waitForVisible('#btnToCardLayout',5000);
browser.click('#btnToCardLayout');
});
this.Then(/^they se cardset again$/, function () {
// Write code here that turns the phrase above into concrete actions
browser.waitForExist('.cardsetInfo', 5000);
});
this.Then(/^they log out$/, function () {
// Write code here that turns the phrase above into concrete actions
logout();
});
};
......
......@@ -25,15 +25,17 @@ module.exports = function () {
});
this.Given(/^User is on the my cardset view$/, function () {
browser.pause(2000);
browser.url('http://localhost:3000/created');
browser.waitForVisible('a.cc_btn.cc_btn_accept_all',5000);
browser.click('a.cc_btn.cc_btn_accept_all');
browser.waitForVisible('#cardsets',5000);
browser.click('#cardsets');
browser.waitForExist('.cardsetRow', 10000);
cardsetsBeforeCreated = browser.elements('.cardsetRow').value.length;
});
this.When(/^User clicks on the create cardset button$/, function () {
browser.waitForVisible('#newCardSet',5000);
browser.click('#newCardSet');
browser.pause(2000);
});
this.Then(/^he is redirected to the new cardset form$/, function () {
......@@ -42,44 +44,53 @@ module.exports = function () {
});
this.Then(/^he should be able to edit the cardset title$/, function () {
browser.waitForExist('#newSetName',5000);
browser.setValue('#newSetName', title);
});
this.Then(/^he should be able to edit the cardset description$/, function () {
browser.waitForExist('#newSetDescription', 5000);
browser.setValue('#newSetDescription', description);
});
this.Then(/^he should be able to edit the module name$/, function () {
browser.waitForExist('#newSetModule', 5000);
browser.setValue('#newSetModule', module);
});
this.Then(/^he should be able to edit the module initials$/, function () {
browser.waitForExist('#newSetModuleShort', 5000);
browser.setValue('#newSetModuleShort', moduleInitials);
});
this.Then(/^he should be able to edit the module ID$/, function () {
browser.waitForExist('#newSetModuleNum', 5000);
browser.setValue('#newSetModuleNum', moduleID);
});
this.Then(/^he should be able to choose a college$/, function () {
browser.waitForVisible('#newSetCollege',5000);
browser.click('#newSetCollege');
browser.waitForVisible('li[data="' + college + '"] a', 5000);
browser.click('li[data="' + college + '"] a');
});
this.Then(/^he should be able to choose a course$/, function () {
browser.waitForVisible('#newSetCourse',5000);
browser.click('#newSetCourse');
browser.waitForVisible('li[data="' + course + '"] a', 5000);
browser.click('li[data="Informatik"] a');
});
this.Then(/^he should push the create new cardset button$/, function () {
browser.waitForVisible('button.save',5000);
browser.click('button.save');
});
this.Then(/^he should see the created cardset in the my cardset view with the correct values$/, function () {
var bool = browser.waitForVisible('#cardSetView tr:nth-child(3) td a', 5000);
expect(bool).toBe(true);
browser.waitForExist('.cardsetRow',5000);
var amountCardsSets = browser.elements('.cardsetRow').value.length;
expect(amountCardsSets).toBe(cardsetsBeforeCreated + 1);
});
......@@ -96,15 +107,22 @@ module.exports = function () {
var bool = browser.waitForVisible('#editCardset', 5000);
expect(bool).toBe(true);
browser.waitForVisible('#editCardset',5000);
browser.click('#editCardset');
browser.waitForVisible('#editSetName', 5000);
browser.waitForExist('#editSetName',5000);
expect(browser.elements('#editSetName').getAttribute("value")).toBe(title);
browser.waitForExist('#editSetDescription',5000);
expect(browser.elements('#editSetDescription').getAttribute("value")).toBe(description);
browser.waitForExist('#editSetModule',5000);
expect(browser.elements('#editSetModule').getAttribute("value")).toBe(module);
browser.waitForExist('#editSetModuleShort',5000);
expect(browser.elements('#editSetModuleShort').getAttribute("value")).toBe(moduleInitials);
browser.waitForExist('#editSetModuleNum',5000);
expect(browser.elements('#editSetModuleNum').getAttribute("value")).toBe(moduleID);
browser.waitForVisible('#cardSetCancel',5000);
browser.click('#cardSetCancel');
browser.waitForVisible('#editSetName', 5000, true);
logout();
......
......@@ -64,13 +64,16 @@ module.exports = function () {
});
this.Then(/^the last card should be the new created one$/, function () {
var wf = ".detailfront" + countBeforeCreated;
var selectorFront = wf + " > p";
browser.waitForExist(wf,5000);
browser.waitForExist(selectorFront,5000);
browser.waitForVisible('#leftCarouselControl');
browser.click('#leftCarouselControl');
browser.waitForVisible(wf);
var expectedFrontOfTheCard = "FRONTOFTHECARD";
browser.waitForVisible(selectorFront);
var frontOfTheCard = browser.getText(selectorFront);
expect(expectedFrontOfTheCard).toEqual(frontOfTheCard);
});
......
......@@ -13,8 +13,10 @@ module.exports = function () {
browser.windowHandleSize();
});
this.Given(/^User is on the my cardset view$/, function () {
browser.pause(1000);
browser.url('http://localhost:3000/created');
browser.waitForVisible('a.cc_btn.cc_btn_accept_all',5000);
browser.click('a.cc_btn.cc_btn_accept_all');
browser.waitForVisible('#cardsets',5000);
browser.click('#cardsets');
var bool = browser.waitForVisible('#newCardSet', 15000);
expect(bool).toBe(true);
});
......@@ -32,17 +34,18 @@ module.exports = function () {
browser.waitForVisible('#editSetName', 5000);
});
this.Then(/^he should be able to press the delete cardset button$/, function () {
browser.waitForVisible('#cardSetDelete',5000);
browser.click('#cardSetDelete');
browser.pause(1000);
});
this.Then(/^he should be able to press the delete cardset button again to be sure$/, function () {
browser.waitForVisible('#cardSetConfirm',5000);
browser.click('#cardSetConfirm');
browser.pause(1000);
});
this.Then(/^he should be returned to the my cardset view$/, function () {
browser.waitForVisible('#cardSetView', 5000);
});
this.Then(/^he should not see the deleted cardset there$/, function () {
browser.waitForExist('#cardSetView > tr',5000);
expect(browser.elements('#cardSetView > tr').value.length).toBe(1);
logout();
});
......
......@@ -23,8 +23,10 @@ module.exports = function () {
});
this.Given(/^User is on the my cardset view$/, function () {
browser.pause(1000);
browser.url('http://localhost:3000/created');
browser.waitForVisible('a.cc_btn.cc_btn_accept_all',5000);
browser.click('a.cc_btn.cc_btn_accept_all');
browser.waitForVisible('#cardsets',5000);
browser.click('#cardsets');
var bool = browser.waitForVisible('#newCardSet', 15000);
expect(bool).toBe(true);
});
......@@ -46,7 +48,6 @@ module.exports = function () {
});
this.Then(/^he should be able to edit the cardset title$/, function () {
// Warten bis Text eingetippt wird
browser.waitUntil(function () {
browser.setValue('#editSetName', title);
return browser.getValue('#editSetName') === title;
......@@ -81,16 +82,19 @@ module.exports = function () {
}, 5000, 'expected text to be different after 5s');
});
this.Then(/^he should be able to edit the college$/, function () {
browser.waitForVisible('#editSetCollege',5000);
browser.click('#editSetCollege');
browser.waitForVisible('li[data="' + college + '"] a', 5000);
browser.click('li[data="' + college + '"] a');
});
this.Then(/^he should be able to edit the course$/, function () {
browser.waitForVisible('#editSetCourse',5000);
browser.click('#editSetCourse');
browser.waitForVisible('li[data="' + course + '"] a', 5000);
browser.click('li[data="' + course + '"] a');
});
this.Then(/^he should press the save deck of cards button$/, function () {
browser.waitForVisible('#cardSetSave',5000);
browser.click('#cardSetSave');
});
this.Then(/^he should see the details of that cardset with the correct values$/, function () {
......@@ -98,13 +102,18 @@ module.exports = function () {
console.log(browser.isExisting('.modal-open'));
return browser.isExisting('.modal-open') === false;
}, 5000, 'expected text to be different after 5s');
browser.waitForVisible('#editCardset',5000);
browser.click('#editCardset');
browser.waitForVisible('#editSetName', 5000);
browser.waitForExist('#editSetName',5000);
expect(browser.elements('#editSetName').getAttribute("value")).toBe(title);
browser.waitForExist('#editSetDescription',5000);
expect(browser.elements('#editSetDescription').getAttribute("value")).toBe(description);
browser.waitForExist('#editSetModule',5000);
expect(browser.elements('#editSetModule').getAttribute("value")).toBe(module);
browser.waitForExist('#editSetModuleShort',5000);
expect(browser.elements('#editSetModuleShort').getAttribute("value")).toBe(moduleInitials);
browser.waitForExist('#editSetModuleNum',5000);
expect(browser.elements('#editSetModuleNum').getAttribute("value")).toBe(moduleID);
browser.click('#cardSetCancel');
......@@ -112,4 +121,3 @@ module.exports = function () {
logout();
});
};
......@@ -2,12 +2,11 @@ Feature: Learn Cards
As a user i would like to learn cardsets with "Leitners memo box" or "Memo" method.
Background:
Scenario: Go to "Leitners memo box"
Given User is on the site
And User is logged in
Scenario: Go to "Leitners memo box"
Given I am on the cardset view of the testcardset
And I am on the cardset view of the testcardset
When I click the Button Letiner's learning box
Then I am on the box view of the testcardset
And Box one contains two cards
......
import {login, logout, setResolution, agreeCookies} from "../helper_functions.js";
import {login, setResolution, agreeCookies} from "../helper_functions.js";
module.exports = function () {
'use strict';
......@@ -12,6 +12,8 @@ module.exports = function () {
agreeCookies();
setResolution();
browser.windowHandleSize();
browser.waitForVisible('a.cc_btn.cc_btn_accept_all',5000);
browser.click('a.cc_btn.cc_btn_accept_all');
});
......@@ -21,8 +23,8 @@ module.exports = function () {
//
/////////////////////////////////////////
this.Given(/^I am on the cardset view of the testcardset$/, function () {
browser.pause(2000);
browser.url('http://localhost:3000/created');
browser.waitForVisible('#cardsets',5000);
browser.click('#cardsets');
var bool = browser.waitForVisible('#newCardSet', 15000);
expect(bool).toBe(true);
browser.click('#cardSetView tr:nth-child(1) td a');
......@@ -31,7 +33,7 @@ module.exports = function () {
});
this.When(/^I click the Button Letiner's learning box$/, function () {
browser.waitForExist('#learnBox', 10000);
browser.waitForVisible('#learnBox', 10000);
browser.click('#learnBox');
});
......@@ -48,6 +50,7 @@ module.exports = function () {
});
this.Then(/^Boxes two to five contain zero cards$/, function () {
browser.waitForExist('#subject5 span.badge',5000);
var cards = browser.getText('#subject2 span.badge');
expect(cards).toBe("0");
cards = browser.getText('#subject3 span.badge');
......@@ -59,11 +62,9 @@ module.exports = function () {
});
this.Then(/^Learned contains zero cards$/, function () {
browser.waitForExist('#learned_card span.badge',5000);
var cards = browser.getText('#learned_card span.badge');
expect(cards).toBe("0");
logout();
browser.pause(2000);
});
......@@ -73,18 +74,20 @@ module.exports = function () {
//
/////////////////////////////////////////
this.Given(/^I went to the box view of the testcardset$/, function () {
browser.pause(1000);
browser.url('http://localhost:3000/created');
browser.waitForVisible('#cardsets',5000);
browser.click('#cardsets');
var bool = browser.waitForVisible('#newCardSet', 15000);
expect(bool).toBe(true);
browser.waitForVisible('#cardSetView tr:nth-child(1) td a',5000);
browser.click('#cardSetView tr:nth-child(1) td a');
bool = browser.waitForVisible('#learnBox', 15000);
expect(bool).toBe(true);
browser.waitForVisible('#learnBox',5000);
browser.click('#learnBox');
});
this.When(/^I click on the Button Box one$/, function () {
browser.waitForExist('#subject1', 10000);
browser.waitForVisible('#subject1', 10000);
browser.click('#subject1');
});
......@@ -96,7 +99,7 @@ module.exports = function () {
});
this.Then(/^I can click on the card$/, function () {
browser.waitForExist('#cardCarousel', 10000);
browser.waitForVisible('#cardCarousel', 10000);
browser.click('#cardCarousel');
});
......@@ -107,17 +110,13 @@ module.exports = function () {
});
this.Then(/^I can click on the button Known$/, function () {
browser.waitForExist('#known', 10000);
browser.waitForVisible('#known', 10000);
browser.click('#known');
});
this.Then(/^Box (\d+) contains one card$/, function (arg1) {
var cards = browser.getText('#subject' + arg1 + ' span.badge');
expect(cards).toBe("1");
if (arg1 == 2) {
logout();
}
});
......@@ -128,7 +127,7 @@ module.exports = function () {
/////////////////////////////////////////
this.When(/^I click the Button Memo$/, function () {
browser.waitForExist('#learnMemo', 10000);
browser.waitForVisible('#learnMemo', 10000);
browser.click('#learnMemo');
});
......@@ -141,8 +140,6 @@ module.exports = function () {
this.Then(/^The button Show answer is shown$/, function () {
var button = browser.isExisting('#memoShowAnswer');
expect(button).toBe(true);
logout();
});
......@@ -156,6 +153,7 @@ module.exports = function () {
this.Then(/^I can click on the Button Show answer$/, function () {
browser.waitForVisible('#memoShowAnswer',5000);
browser.click('#memoShowAnswer');
});
......@@ -181,16 +179,16 @@ module.exports = function () {
});
this.Then(/^I can click button three$/, function () {
browser.waitForExist('#memoRate3', 10000);
browser.waitForVisible('#memoRate3', 10000);
browser.waitForExist('.frontblock span p',5000);
oldVal = browser.getText('.frontblock span p');
browser.click('#memoRate3');
});
this.Then(/^The next card is shown$/, function () {
browser.waitForExist('.frontblock span p',5000);
var same = oldVal == browser.getText('.frontblock span p');
expect(same).toBe(false);
logout();
});
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment