Commit 1b979b13 authored by Curtis Adam's avatar Curtis Adam
Browse files

WIP: Remove chimpy and refactor gitlab-ci

parent 03c91291
......@@ -6,3 +6,4 @@ npm-debug.log
.DS_Store
node_modules/
.coverage/
/tests/unitTests/errors/*
......@@ -7,14 +7,14 @@ variables:
DB_TEST_DUMP: tests/testDatabaseDump/meteor
stages:
- test
- codestyle
- build
- chimptest
- test
- review
- deploy
jshint:
stage: test
stage: codestyle
tags:
- nodejs
dependencies: []
......@@ -24,7 +24,7 @@ jshint:
- node_modules/jshint/bin/jshint --config .jshintrc ./client/head.js ./server/ ./imports/ ./i18n ./tests
jscs:
stage: test
stage: codestyle
tags:
- nodejs
dependencies: []
......@@ -33,7 +33,7 @@ jscs:
- node_modules/jscs/bin/jscs --config .jscsrc ./client/head.js ./server/ ./imports/ ./i18n ./tests
sonar:
stage: test
stage: codestyle
only:
- master
- staging
......@@ -75,8 +75,8 @@ build:
paths:
- "$BUNDLE_DIR"
chimp:
stage: chimptest
unit_tests:
stage: test
except:
- staging
- master
......@@ -99,9 +99,16 @@ chimp:
- mongo --quiet --eval "version();" --host "$MONGO_HOST"
- cd "$BUNDLE_DIR/programs/server" && npm install
- cd -
- node "$BUNDLE_DIR/main.js" &
- sleep 15
- ./tests/runTests.sh
- ./tests/run_unit_tests.sh
e2e_tests:
stage: test
except:
- staging
- master
allow_failure: true
script:
- ./tests/run_e2e_tests.sh
review:
stage: review
......
This diff is collapsed.
......@@ -38,7 +38,6 @@
"devDependencies": {
"babel-plugin-istanbul": "^5.2.0",
"chai": "^4.2.0",
"chimpy": "^1.2.0",
"gulp-jscs": "^3.0.2",
"gulp-jshint": "^2.1.0",
"gulp-watch": "^5.0.1",
......
Feature: Create new deck of cards
As a user of the site,
so that I can create and learn cards,
I want to create a new deck of cards
Background:
Given User is logged in
And User is on the my cardset view
@watch
Scenario: User creates a new deck of cards
When User clicks on the create cardset button
Then he is redirected to the new cardset form
Then he should be able to edit the cardset title
And he should be able to edit the card type
And he should be able to edit the cardset description
And he should push the create new cardset button
And he should see the details of that cardset with the correct values
import * as navigation from "../../features_helper/navigation.js";
module.exports = function () {
'use strict';
let title = "CardTitle";
let description = "description";
this.Given(/^User is logged in$/, function () {
navigation.login("edu");
});
this.Given(/^User is on the my cardset view$/, function () {
navigation.selectMyCardset();
});
this.When(/^User clicks on the create cardset button$/, function () {
navigation.newCardset(true);
});
this.Then(/^he is redirected to the new cardset form$/, function () {
navigation.contentVisible('#setCardsetFormModalTitle');
});
this.Then(/^he should be able to edit the cardset title$/, function () {
navigation.setContent('#setName', title);
});
this.Then(/^he should be able to edit the card type$/, function () {
navigation.clickElement('#setCardsetFormModal .setCardTypeDropdown');
navigation.clickElement('#setCardsetFormModal .cardType');
});
this.Then(/^he should be able to edit the cardset description$/, function () {
navigation.setContent('#contentEditor', description);
});
this.Then(/^he should push the create new cardset button$/, function () {
navigation.clickElement('#cardSetSave');
});
this.Then(/^he should see the details of that cardset with the correct values$/, function () {
navigation.clickElement('#editCardset');
navigation.compareContent('#setName', title, 2, 'value');
navigation.compareContent('#contentEditor', description, 2, 'value');
navigation.clickElement('#cardSetCancel');
navigation.waitForModalBackdrop();
navigation.logout();
});
};
Feature: Create a new Card
A user to the site wants to create a new card in his own cardset
Scenario: Create a new card
Given User is on the poolview
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 subject of the card
And he enters a text for the front of the card
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 they log out
\ No newline at end of file
import * as cardset from "../../features_helper/cardset.js";
import * as navigation from "../../features_helper/navigation.js";
module.exports = function () {
'use strict';
let countBeforeCreated = 0;
let countAfterCreated = 0;
let url;
/**
* ---------------------------------------------------------------------
* Background
* ---------------------------------------------------------------------
*/
this.Given(/^User is on the poolview$/, function () {
navigation.login("edu");
});
this.Given(/^he is on the view of a cardset$/, function () {
navigation.selectMyCardset();
navigation.selectCardsetLink(4);
countBeforeCreated = navigation.checkCardsetCardQuantity();
});
/**
* ---------------------------------------------------------------------
* Create a new card
* ---------------------------------------------------------------------
*/
this.When(/^the user clicks on the \-\-create a new card\-\- button$/, function () {
url = browser.getUrl();
cardset.newCard();
});
this.When(/^he is redirected to the \-\-New card\-\- view$/, function () {
navigation.compareUrl(url + '/newcard', browser.getUrl());
});
this.When(/^he enters a text for the subject of the card$/, function () {
navigation.setContent('#subjectEditor', 'SUBJECTOFTHECARD');
});
this.When(/^he enters a text for the front of the card$/, function () {
navigation.setContent('#contentEditor', 'FRONTOFTHECARD');
});
this.When(/^he press on the save button$/, function () {
cardset.saveCardReturn();
});
this.Then(/^he should be redirected to his own cardsets view back again$/, function () {
cardset.newCard(false);
navigation.compareUrl(url, browser.getUrl());
});
this.Then(/^the card should be saved$/, function () {
countAfterCreated = navigation.checkCardsetCardQuantity();
navigation.compareContent(++countBeforeCreated, countAfterCreated, 5, '');
});
this.Then(/^they log out$/, function () {
navigation.logout();
});
};
import * as global from "./global.js";
import * as navigation from "./navigation";
module.exports = {
collapseCardsetInfo: function (click = true) {
browser.waitForVisible('#collapseCardsetInfoButton', global.threshold);
if (click) {
browser.click('#collapseCardsetInfoButton');
}
},
learnMemo: function (click = true) {
browser.waitForVisible('.learnBtn', global.threshold);
if (click) {
browser.click('.learnBtn');
}
browser.waitForVisible('#learnMemo', global.threshold);
if (click) {
browser.click('#learnMemo');
}
browser.waitForVisible('#startPom', global.threshold);
browser.click('#startPom');
browser.waitForVisible('#wozniakHelpConfirm', global.threshold);
browser.click('#wozniakHelpConfirm');
},
learnBox: function (click = true) {
browser.waitForVisible('.learnBtn', global.threshold);
if (click) {
browser.click('.learnBtn');
}
browser.waitForVisible('#learnBox', global.threshold);
if (click) {
browser.click('#learnBox');
}
browser.waitForVisible('#startPom', global.threshold);
browser.click('#startPom');
browser.waitForVisible('#leitnerHelpConfirm', global.threshold);
browser.click('#leitnerHelpConfirm');
},
leitnerProgress: function (click = true) {
browser.waitForVisible('.learnBtn', global.threshold);
if (click) {
browser.click('.learnBtn');
}
browser.waitForVisible('#leitnerProgress', global.threshold);
if (click) {
browser.click('#leitnerProgress');
}
},
cardList: function (click = true) {
browser.waitForVisible('#btnToListLayout', global.threshold);
if (click) {
browser.click('#btnToListLayout');
}
},
cardDetail: function (click = true) {
browser.waitForVisible('#btnToCardLayout', global.threshold);
if (click) {
browser.click('#btnToCardLayout');
}
},
newCard: function (click = true) {
browser.waitForExist('#newCardBtn', global.threshold);
if (click) {
browser.click('#newCardBtn');
browser.waitForExist('#subjectEditor', global.threshold);
browser.click('#subjectEditor');
}
},
saveCard: function (click = true) {
browser.waitForExist('.cardSave', global.threshold);
if (click) {
browser.click('.cardSave');
}
},
saveCardReturn: function (click = true) {
browser.waitForExist('#cardSaveReturn', global.threshold);
if (click) {
browser.click('#cardSaveReturn');
}
},
cancelCardEdit: function (click = true) {
browser.waitForVisible('#cardCancel', global.threshold);
if (click) {
navigation.contentVisible('#cancelEditConfirm');
browser.click('#cancelEditConfirm');
}
},
editCard: function (click = true) {
browser.waitForVisible('#editCard', global.threshold);
if (click) {
let editButton = browser.elements('#editCard').value[0];
editButton.click();
}
},
deleteCard: function (click = true) {
browser.waitForVisible('#cardDelete', global.threshold);
if (click) {
browser.click('#cardDelete');
}
},
deleteCardConfirm: function (click = true) {
navigation.contentVisible('#deleteCardConfirm');
if (click) {
browser.click('#deleteCardConfirm');
}
},
deleteAllCards: function (click = true) {
browser.waitForVisible('#delete_cards', global.threshold);
if (click) {
browser.click('#delete_cards');
}
},
deleteAllCardsConfirm: function (click = true) {
browser.waitForVisible('#deleteCardsConfirm', global.threshold);
if (click) {
browser.click('#deleteCardsConfirm');
}
},
deleteAllCardsCancel: function (click = true) {
browser.waitForVisible('#deleteCardsCancel', global.threshold);
if (click) {
browser.click('#deleteCardsCancel');
}
}
};
export const threshold = 15000;
export const thresholdText = " after 15 seconds.";
export const baseURL = "http://localhost:3000";
export const createRoute = "/personal/cardsets";
export const learnRoute = "/learn";
export const cardsetRoute = "/cardset";
export const learnBoxRoute = "/box";
export const superMemoRoute = "/memo";
export const poolRoute = "/public/cardsets";
import * as global from "./global.js";
module.exports = {
memoView: function () {
browser.waitForVisible('#memoFlashcard', global.threshold);
}
};
import * as global from "./global.js";
function agreeCookies() {
browser.waitForExist('.cc-dismiss', global.threshold);
browser.setCookie({name: 'cookieconsent_dismissed', value: 'yes'});
browser.click('.cc-dismiss');
}
function setResolution() {
browser.windowHandleMaximize('current');
}
module.exports = {
login: function (userLogin) {
browser.url(global.baseURL);
setResolution();
agreeCookies();
userLogin += "Login";
browser.waitForVisible('#TestingBackdoorUsername', global.threshold);
this.clickElement('#TestingBackdoorUsername', global.threshold);
browser.waitForVisible('#' + userLogin);
this.clickElement('#' + userLogin);
browser.waitForVisible('#BackdoorLogin', global.threshold);
this.clickElement('#BackdoorLogin');
browser.waitForVisible('#useCasesModal .close', global.threshold);
this.clickElement('#useCasesModal .close', global.threshold);
if (browser.isVisible(".bert-alert")) {
this.clickElement(".bert-alert");
}
},
logout: function () {
browser.waitForVisible('.logout-main', global.threshold);
browser.click('.logout-main');
},
selectMyCardset: function () {
browser.waitForVisible('#navbar-personal', global.threshold);
browser.click('#navbar-personal');
browser.waitForVisible('#navbar-personal-cardsets', global.threshold);
browser.click('#navbar-personal-cardsets');
this.checkUrl(global.createRoute);
},
selectLearnset: function () {
browser.waitForVisible('#navbar-learn-decks', global.threshold);
browser.click('#navbar-learn-decks');
this.checkUrl(global.learnRoute);
browser.waitForVisible('#browseCardset', global.threshold);
browser.click('#browseCardset');
},
selectPool: function () {
browser.waitForVisible('#pool', global.threshold);
browser.click('#pool');
this.checkUrl(global.poolRoute);
},
selectCardsetLink: function (number) {
number = number - 1;
if (browser.isVisible('#showMoreResults')) {
browser.click('#showMoreResults', global.threshold);
}
browser.waitForVisible('#cardsetLink' + number, global.threshold);
browser.click('#cardsetLink' + number);
},
checkCardsetCardQuantity: function () {
browser.waitForExist("#collapseCardsetInfoButton", global.threshold);
browser.click('#collapseCardsetInfoButton');
browser.waitForExist(".cardsetCardCount", global.threshold);
return browser.getAttribute(".cardsetCardCount", "data-count");
},
checkUrl: function (url) {
browser.waitUntil(function () {
return (global.baseURL + url) === browser.getUrl();
}, global.threshold, 'expected URL to be ' + browser.getUrl() + ' but got ' + (global.baseURL + url) + global.thresholdText);
},
compareUrl: function (url1, url2) {
browser.waitUntil(function () {
return url1 === url2;
}, global.threshold, 'expected URL to be ' + url1 + ' but got ' + url2 + global.thresholdText);
},
firstLogin: function (username) {
this.login(username);
browser.waitForExist('#accept_checkbox', global.threshold);
browser.$('#accept_checkbox').click();
browser.click('button[id="accept_button"]');
},
logoutAdmin: function () {
browser.waitForExist('#logout_admin', global.threshold);
browser.click('#logout_admin');
},
leitnerWozniakBackButton: function (click = true) {
browser.waitForVisible('.backToCardset', global.threshold);
if (click) {
browser.click('.backToCardset');
}
},
back: function (click = true) {
browser.waitForVisible('#backButton', global.threshold);
if (click) {
browser.click('#backButton');
}
},
switchToBackEnd: function (click = true) {
browser.waitForVisible("#adminpanel", global.threshold);
if (click) {
browser.click('#adminpanel');
}
},
backendCardset: function (click = true) {
browser.waitForVisible("a[href='/admin/cardsets']", global.threshold);
if (click) {
browser.click("a[href='/admin/cardsets']");
}
},
backendCollege: function (click = true) {
browser.waitForVisible("a[href='/admin/university']", global.threshold);
if (click) {
browser.click("a[href='/admin/university']");
}
},
newCardset: function (click = true) {
browser.waitForVisible('#newCardSet', global.threshold);
if (click) {
browser.click('#newCardSet');
}
},
compareContent: function (content1, content2, dataType, attribute = 0, isTrue = true) {
let errorMessage = '';
let receivedContent = '';
if (dataType < 4) {
browser.waitForVisible(content1, global.threshold);
errorMessage = 'Expected content of ' + content1 + ' to be ' + content2 + ' but got ';
} else {
errorMessage = 'Expected content ' + content1 + ' to be ' + content2;
}
browser.waitUntil(function () {
switch (dataType) {
case 0:
browser.waitForVisible(content1, global.threshold);
receivedContent = browser.getText(content1);
return (receivedContent === content2) === isTrue;
case 1:
browser.waitForVisible(content1, global.threshold);
receivedContent = browser.elements(content1).value.length;
return (receivedContent === content2) === isTrue;
case 2:
browser.waitForVisible(content1, global.threshold);
receivedContent = browser.getAttribute(content1, attribute);
return (receivedContent === content2) === isTrue;
case 3:
browser.waitForVisible(content1, global.threshold);
receivedContent = browser.getAttribute(content1, attribute);
return (parseInt(receivedContent) === parseInt(content2)) === isTrue;
case 4:
return (content1 === content2) === isTrue;
case 5:
return (parseInt(content1) === parseInt(content2)) === isTrue;
case 6:
browser.waitForVisible(content1, global.threshold);
receivedContent = browser.getText(content1);
return (parseInt(receivedContent) === parseInt(content2)) === isTrue;
}
}, global.threshold, errorMessage + receivedContent + global.thresholdText);
},
getContent: function (content, dataType, attribute = 0) {
browser.waitForVisible(content, global.threshold);
switch (dataType) {
case 0:
return browser.getText(content);
case 1:
return browser.elements(content).value.length;
case 2:
return browser.getAttribute(content, attribute);
}
},
contentVisible: function (element, isVisible = true) {
let notVisible = '';
if (!isVisible) {
notVisible = 'not ';
}
browser.waitUntil(function () {
return browser.isVisible(element) === isVisible;
}, global.threshold, 'expected ' + element + ' to be ' + notVisible + 'visible' + global.thresholdText);
},
setContent: function (content, text) {
browser.waitForVisible(content, global.threshold);
browser.setValue(content, text);
},
clickElement: function (element) {
browser.waitForVisible(element, global.threshold);
browser.click(element);
},
resetPool: function () {
this.selectPool();
browser.waitForVisible('.resetBtn', global.threshold);
browser.click('.resetBtn');
},
waitForModalBackdrop: function () {
browser.waitUntil(function () {
return browser.isVisible(".modal-backdrop") === false;
}, global.threshold, 'expected Modal to be not visible' + global.thresholdText);
}
};
#!/bin/bash
DIRECTORY=`dirname $0`
if [ -z "$CALLED_FROM_SCRIPT" ] ; then
source $DIRECTORY/scriptSettings.sh
calledFromScript
fi
# confirm calling pid
if [ -z "$CALLED_FROM_SCRIPT" ] ; then
CALLED_FROM_SCRIPT=false
source errors/helpers/scriptSettings.sh
echo -e $RED"Script needs to be called by another script"$NC
exit 0
fi
if [ -n "$DISPLAY" ] ; then
./node_modules/.bin/chimpy .thresholds/chimp.js --ddp=http://localhost:$PORT --path=$testDir $1 --browser=firefox