Add integration test for making receiving (#305)

Update docker scripts to work with data volumes (#284)
This commit is contained in:
jekkos
2016-01-27 20:11:21 +01:00
parent 574548f360
commit 85c6da4346
5 changed files with 57 additions and 31 deletions

View File

@@ -20,6 +20,7 @@ RUN npm install -g grunt-cli
RUn ln -s /usr/local/bin/grunt /usr/bin/grunt
RUN ln -fs /app/* /var/www/html
RUN rm /var/www/html/index.html
ADD ./docker/start_container.sh /start_container.sh
RUN chmod 755 /start_container.sh
EXPOSE 80 3306

View File

@@ -25,9 +25,15 @@ To build and run the image, issue following commands in a terminal with docker i
docker build -t me/ospos https://github.com/jekkos/opensourcepos.git
docker run -d -p 80:80 me/ospos
Docker will clone the latest master into the image and start a LAMP stack with the application configured.
Docker will clone the latest master into the image and start a LAMP stack with the application configured. If you like to persist your changes in this install, then you can use two docker data containers to store database and filesystem changes. In this case you will need following command (first time only)
A more extensive setup guide can be found at [this site](http://www.opensourceposguide.com/guide/gettingstarted/installation)
docker run -d -v /app --name="ospos" -v /var/lib/mysql --name="ospos-sql" -p 127.0.0.1:80:80 me/ospos
After stopping the created container for the first time, this command will be replaced with
docker run -d -v /app --volumes-from="ospos" -v /var/lib/mysql --volumes-from="ospos-sql" -p 127.0.0.1:80:80 me/ospos
Both the data and mysql directories will be persisted in a separate docker container and can be mounted within any other container using the last command. A more extensive setup guide can be found at [this site](http://www.opensourceposguide.com/guide/gettingstarted/installation)
If you like the project, and you are making money out of it on a daily basis, then consider to buy me a coffee so I can keep adding features.

View File

@@ -1,10 +1,10 @@
#!/bin/bash
if [ ! -f /mysql-configured ]; then
if [ ! -f /app/mysql-configured ]; then
/usr/bin/mysqld_safe &
sleep 10s
MYSQL_PASSWORD=`pwgen -c -n -1 12`
echo mysql root password: $MYSQL_PASSWORD
echo $MYSQL_PASSWORD > /mysql-root-pw.txt
echo $MYSQL_PASSWORD > /app/mysql-root-pw.txt
[ -f /var/www/html/index.html ] && rm /var/www/html/index.html
mysqladmin -u root password $MYSQL_PASSWORD
cp /app/application/config/database.php.tmpl /app/application/config/database.php
@@ -12,7 +12,7 @@ if [ ! -f /mysql-configured ]; then
sed -i -e "s/\(password.*\?=.\).*\(.\)$/\1'${MYSQL_PASSWORD}'\2/g" /app/application/config/database.php
sed -i -e "s/\(database.*\?=.\).*\(.\)$/\1'ospos'\2/g" /app/application/config/database.php
mysql -e "CREATE DATABASE IF NOT EXISTS ospos; use ospos; source /app/database/tables.sql; source /app/database/constraints.sql;" -uroot -p${MYSQL_PASSWORD}
touch /mysql-configured
touch /app/mysql-configured
killall mysqld
sleep 10s
fi

View File

@@ -1,26 +0,0 @@
var assert = require('assert');
var ospos = require('./ospos');
describe("create item and make sale", function () {
this.timeout(25000);
it("should be able to add item", function (done) {
return this.browser.get(ospos.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click()
.waitForElementByName("name", 10000).type("anItem").elementById("category").type("aCategory")
.elementById('cost_price', 2000).clear().type("10").elementById("unit_price", 2000).type("20")
.elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21")
.elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click()
.waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) {
assert.equal(value, "anItem", "item could not be created!!");
}).then(done, done);
});
it("should be able to make sale", function(done) {
return this.browser.get(ospos.url("/index.php/sales")).elementById("item", 3000).type("1\r\n")
.waitForElementByName("quantity", 5000).clear().type("2").elementByName("discount", 1000).type("10").elementByName("edit_item").click()
.elementById("add_payment_button", 2000).click().elementByCssSelector("tbody#payment_contents tr td:nth-child(3)", 5000).text().then(function(value) {
assert.equal(value, "$43.56", "discounted price " + value + " is not correct!!");
}).then(done, done);
});
});

View File

@@ -0,0 +1,45 @@
var assert = require('assert');
var ospos = require('./ospos');
describe("create item and make sale", function () {
this.timeout(25000);
it("should be able to add item", function (done) {
return this.browser.get(ospos.url("/index.php/items")).elementByCssSelector("a[title='New Item']", 5000).click()
.waitForElementByName("name", 10000).type("anItem").elementById("category").type("aCategory")
.elementById('cost_price', 2000).clear().type("10").elementById("unit_price", 2000).type("20")
.elementById('tax_name_1', 2000).type('VAT').elementById("tax_percent_name_1", 2000).type("21")
.elementById("1_quantity", 2000).type("1").elementById("reorder_level", 2000).type("0").elementById("submit", 2000).click()
.waitForElementByXPath("//table/tbody/tr[td/text()='anItem']/td[3]").text().then(function (value) {
assert.equal(value, "anItem", "item could not be created!!");
}).then(done, done);
});
it("should be able to make sale", function(done) {
return this.browser.get(ospos.url("/index.php/sales"))
.elementById("item", 3000).type("1\r\n")
.waitForElementByName("quantity", 5000).clear().type("2").elementByName("discount", 1000).type("10").elementByName("edit_item").click()
.elementById("add_payment_button", 2000).click().elementByCssSelector("tbody#payment_contents tr td:last-child", 5000).text().then(function(value) {
assert.equal(value, "$43.56", "price " + value + " in sale register is not correct!!");
}).elementById("finish_sale_button", 3000).submit().elementByCssSelector("#receipt_items tbody tr:nth-child(7) td:last-child", 5000).text().then(function(value) {
assert.equal(value, "$43.56", "price " + value + " on sale receipt is not correct!!");
}).elementByCssSelector("#receipt_items tbody tr:nth-child(9) td:last-child div.total-value", 5000).text().then(function(value) {
assert.equal(value, "-$43.56", "payment amount " + value + " on sale receipt is not correct!!")
}).then(done, done);
});
it("should be able to make receiving", function(done) {
return this.browser.get(ospos.url("/index.php/receivings"))
.elementById("item", 3000).type("1\r\n")
.waitForElementByName("quantity", 3000).clear().type("2").elementByName("edit_item").click()
.elementByCssSelector("td:nth-last-child(2)").text().then(function(value) {
assert.equal(value, "$20.00", "price " + value + " in receiving register is not correct!!");
}).elementById("finish_receiving_button").submit().elementByCssSelector("#receipt_items tbody tr:nth-last-child(2) td:nth-child(2) div.total-value").text().then(function(value) {
assert.equal(value, "$20.00", "price " + value + " on receiving receipt is not correct!!");
})
.then(done, done);
});
});