Commit 648f2b42 authored by Mehmet-Ali Pamukci's avatar Mehmet-Ali Pamukci Committed by Curtis Adam

fixed test errors (create and edit card)

parent 41f82393
......@@ -2,16 +2,14 @@ Feature: Create a new Card and delete it
A user to the site wants to create a new card in his own cardset
and he wants to be able to delete it
Background:
Given User is on the poolview with username "testuser"
And he is on the view of the cardset named --test-cards1--
Scenario: Create a new card and delete it
Given User is on the poolview with username "testuser"
And he is on the view of a cardset
When the user clicks on the --create a new card-- button
And he is redirected to the --New card-- view
And he enters a text for the front of the card
And he enters a text for the back of the card
And he press on the "Save" button
And he press on the save button
Then he should be redirected to his own cardsets view back again
And the card should be saved
And the last card should be the new created one
......
import {login, logout, setResolution, agreeCookies} from "./helper_functions"
import {login, setResolution, agreeCookies} from "../helper_functions";
module.exports = function () {
var countBeforeCreated = 0;
var countCards = 0;
......@@ -9,14 +9,21 @@ module.exports = function () {
* ---------------------------------------------------------------------
*/
this.Given(/^User is on the poolview with username "([^"]*)"$/, function (arg1) {
browser.url('http://localhost:3000');
login("testuser");
if (browser.getUrl() != "http://localhost:3000") {
browser.url('http://localhost:3000');
}
login(arg1);
setResolution();
agreeCookies();
browser.windowHandleSize();
});
this.Given(/^he is on the view of the cardset named \-\-test\-cards(\d+)\-\-$/, function (arg1) {
browser.url('http://localhost:3000/cardset/2P6mg5iqCZ49QPPDz');
this.Given(/^he is on the view of a cardset$/, function () {
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(".carousel-inner", 5000);
countBeforeCreated = browser.elements(".carousel-inner > div").value.length;
});
......@@ -41,7 +48,7 @@ module.exports = function () {
this.When(/^he enters a text for the back of the card$/, function () {
browser.setValue('#backEditor', 'BACKOFTHECARD');
});
this.When(/^he press on the "([^"]*)" button$/, function (arg1) {
this.When(/^he press on the save button$/, function () {
browser.waitForExist('#cardSave', 5000);
browser.click('#cardSave');
});
......@@ -51,6 +58,7 @@ module.exports = function () {
expect(currentUrl).toEqual(expectedUrl);
});
this.Then(/^the card should be saved$/, function () {
browser.waitForVisible(".carousel-inner > div",5000);
countCards = browser.elements(".carousel-inner > div").value.length;
expect(countBeforeCreated + 1).toEqual(countCards);
});
......@@ -67,15 +75,16 @@ module.exports = function () {
expect(expectedFrontOfTheCard).toEqual(frontOfTheCard);
});
this.Then(/^he can go back and delete the card$/, function () {
browser.waitForVisible('#editCard',5000);
var editButton = browser.elements('#editCard').value[countCards - 1];
editButton.waitForVisible(5000);
editButton.click();
browser.waitForVisible('#cardDelete',5000);
var deleteButton = browser.element('#cardDelete');
deleteButton.click();
});
this.Then(/^he have to confirm the delete process$/, function () {
browser.waitForVisible('#cardConfirm',5000);
var confirmDeleteButton = browser.element('#cardConfirm');
confirmDeleteButton.waitForVisible(5000);
confirmDeleteButton.click();
});
/**
......@@ -91,6 +100,5 @@ module.exports = function () {
var currentUrl = browser.getUrl();
var expectedUrl = "http://localhost:3000/cardset/2P6mg5iqCZ49QPPDz";
expect(currentUrl).toEqual(expectedUrl);
logout();
});
};
......@@ -3,7 +3,7 @@ Feature: Edit a card
Background:
Given User is on the poolview with username "testuser" (EaC)
And he is on the view of the cardset named --test-cards1-- (EaC)
And he is on the view of a cardset (EaC)
Scenario: Edit card
When the user clicks on the edit button of the first card
......
......@@ -2,7 +2,6 @@ import {login, logout, setResolution, agreeCookies} from "../helper_functions";
module.exports = function () {
'use strict';
var sFront,sBack;
/*jshint unused:false*/
/**
* ---------------------------------------------------------------------
* Background
......@@ -15,8 +14,13 @@ module.exports = function () {
agreeCookies();
browser.windowHandleSize();
});
this.Given(/^he is on the view of the cardset named \-\-test\-cards(\d+)\-\- \(EaC\)$/, function (arg1) {
browser.url('http://localhost:3000/cardset/2P6mg5iqCZ49QPPDz');
this.Given(/^he is on the view of a cardset \(EaC\)$/, function () {
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(".carousel-inner", 5000);
});
this.When(/^the user clicks on the edit button of the first card$/, function () {
......
/* exported login */
export function login(username) {
browser.waitForVisible('#TestingBackdorUsername',5000);
var SetUsername = function (name) {
$('#TestingBackdorUsername').val(name);
};
browser.waitForExist("#TestingBackdorUsername", 5000);
client.execute(SetUsername, username);
browser.waitForVisible('a[id="BackdoorLogin"]',5000);
browser.click('a[id="BackdoorLogin"]');
browser.pause(1000);
}
/* exported 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