Commit 913dfbed authored by Vegard Murvold Sporstøl's avatar Vegard Murvold Sporstøl
Browse files

Merge branch 'testing' into 'master'

Testing

See merge request !11
parents f6885150 da8edafb
Pipeline #117035 failed with stages
in 5 minutes and 2 seconds
stages:
- test
- staging
test:
- test-frontend
- test-backend
- deploy
test-frontend:
image: node:latest
stage: test-frontend
script:
# Configure browser
- apt-get update -yqqq
- apt-get install -yqq xvfb
- apt-get install iceweasel -yqq
- apt-get install dbus-x11 -yqq
- Xvfb :99 -screen 0 1280x720x24 -ac &
- export DISPLAY=:99
- export $(dbus-launch)
# Install dependencies
- npm install -g testcafe
- testcafe --list-browsers
# Run tests
- testcafe firefox frontend-test.js --skip-js-errors
test-backend:
image: python:3.8
stage: test
stage: test-backend
script:
# this configures Django application to use attached postgres database that is run on `postgres` host
- cd backend/secfit
- apt-get update -qy
- pip install -r requirements.txt
- python manage.py test
staging:
deploy:
type: deploy
image: ruby
stage: staging
stage: deploy
script:
- apt-get update -qy
- apt-get install -y ruby-dev
......
import { Selector, ClientFunction, RequestHook } from 'testcafe';
import https from 'https';
const getLocation = ClientFunction(() => document.location.href);
fixture`login`
.page`https://secfit-group15-frontend.herokuapp.com/login.html`;
test('login test passed', async t => { //check that you are able to log in
await t
.wait(1000)
.typeText('input[name="username"]', "admin")
.typeText('input[name="password"]', "Password")
.click('input[id="btn-login"]')
.expect(getLocation()).contains('https://secfit-group15-frontend.herokuapp.com/workouts.html')
.wait(3000);
});
test('login test fail', async t => { //check that wrong credentials are not allowed
await t
.wait(1000)
.typeText('input[name="username"]', "admin")
.typeText('input[name="password"]', "password")
.click('input[id="btn-login"]')
.expect(getLocation()).notContains('https://secfit-group15-frontend.herokuapp.com/workouts.html')
.wait(1000);
});
fixture`statistics`
.page`https://secfit-group15-frontend.herokuapp.com/login.html`
test('statistics logic', async t => { //check that the logic of the statistics is valid
await t
.wait(1000)
.typeText('input[name="username"]', "admin")
.typeText('input[name="password"]', "Password")
.click('input[id="btn-login"]')
.navigateTo(`https://secfit-group15-frontend.herokuapp.com/statistics.html`)
.wait(2000)
const week = await Selector('#week').innerText;
const month = await Selector('#month').innerText;
const year = await Selector('#year').innerText
await t
.wait(1000)
.expect(parseInt(month)).gte(parseInt(week))
.expect(parseInt(year)).gte(parseInt(month))
});
fixture`exercises`
.page`https://secfit-group15-frontend.herokuapp.com/login.html`;
test('exercise value', async t => { //check that the checkboxes get checked/unchecked as intended + sort
await t
.wait(1000)
.typeText('input[name="username"]', "admin")
.typeText('input[name="password"]', "Password")
.click('input[id="btn-login"]')
.wait(1000)
.navigateTo(`https://secfit-group15-frontend.herokuapp.com/workouts.html`)
.wait(1000)
.navigateTo(`https://secfit-group15-frontend.herokuapp.com/exercises.html`)
.wait(1000)
.click('input[value="Strength"]')
.wait(1000)
.expect(Selector('input[value="Strength"]').checked).eql(false)
.click('input[value="Strength"]')
.expect(Selector('input[value="Strength"]').checked).eql(true)
.click('input[value="Endurance"]')
.click('input[value="Strength"]')
.click('input[value="Balance"]')
.click('input[value="Flexibility"]')
.click('input[value="Other"]')
.wait(2000)
if (await Selector('h5[class="mb-1"]').exists) {
await t
.click('h5[class="mb-1"]')
}
await t
.wait(5000)
.expect(getLocation()).notContains('https://secfit-group15-frontend.herokuapp.com/exercise.html') //check that no exercise exists
.wait(3000)
})
test('Create exercise', async t => { //check that you access "create exercise"
await t
.wait(1000)
.typeText('input[name="username"]', "admin")
.typeText('input[name="password"]', "Password")
.click('input[id="btn-login"]')
.wait(1000)
.navigateTo(`https://secfit-group15-frontend.herokuapp.com/exercises.html`)
.wait(1000)
.click('input[id="btn-create-exercise"]')
.wait(2000)
.expect(getLocation()).contains('https://secfit-group15-frontend.herokuapp.com/exercise.html')
})
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
crossorigin="anonymous"
/>
<script
src="https://kit.fontawesome.com/0ce6c392ca.js"
crossorigin="anonymous"
></script>
<link rel="stylesheet" href="styles/style.css" />
<script src="scripts/navbar.js" type="text/javascript" defer></script>
</head>
<body>
<navbar-el></navbar-el>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous" />
<div class="container">
<div class="card mt-3 border-0">
<article class="card-body mx-auto">
<h4 class="card-title mt-3 text-center">Log In</h4>
<form id="form-login">
<div class="input-group mb-2">
<span class="input-group-text">
<i class="fas fa-user"></i>
</span>
<input
name="username"
class="form-control"
placeholder="User name"
type="text"
required
/>
</div>
<!-- form-group// -->
<div class="input-group mb-2">
<span class="input-group-text">
<i class="fas fa-lock"></i>
</span>
<input
class="form-control"
name="password"
placeholder="Password"
type="password"
required
/>
</div>
<!-- form-group// -->
<div class="input-group mb-2">
<label class="checkbox" style="border: none;">
<input type="checkbox" value="rememberMe" id="rememberMe" />
Remember me
</label>
</div>
<!-- form-group// -->
<div class="d-grid">
<input
type="button"
class="btn btn-primary"
id="btn-login"
value=" Log in "
/>
</div>
<!-- form-group// -->
</form>
</article>
</div>
<!-- card.// -->
<script src="https://kit.fontawesome.com/0ce6c392ca.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="styles/style.css" />
<script src="scripts/navbar.js" type="text/javascript" defer></script>
</head>
<body>
<navbar-el></navbar-el>
<div class="container">
<div class="card mt-3 border-0">
<article class="card-body mx-auto">
<h4 class="card-title mt-3 text-center">Log In</h4>
<form id="form-login">
<div class="input-group mb-2">
<span class="input-group-text">
<i class="fas fa-user"></i>
</span>
<input name="username" id="username" class="form-control" placeholder="User name" type="text" required />
</div>
<!-- form-group// -->
<div class="input-group mb-2">
<span class="input-group-text">
<i class="fas fa-lock"></i>
</span>
<input class="form-control" name="password" id="password" placeholder="Password" type="password" required />
</div>
<!-- form-group// -->
<div class="input-group mb-2">
<label class="checkbox" style="border: none;">
<input type="checkbox" value="rememberMe" id="rememberMe" />
Remember me
</label>
</div>
<!-- form-group// -->
<div class="d-grid">
<input type="button" class="btn btn-primary" id="btn-login" value=" Log in " />
</div>
<!-- form-group// -->
</form>
</article>
</div>
<!-- card.// -->
</div>
<script src="scripts/defaults.js"></script>
<script src="scripts/scripts.js"></script>
<script src="scripts/login.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
crossorigin="anonymous"></script>
</body>
<script src="scripts/defaults.js"></script>
<script src="scripts/scripts.js"></script>
<script src="scripts/login.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
crossorigin="anonymous"
></script>
</body>
</html>
</html>
\ No newline at end of file
../rimraf/bin.js
\ No newline at end of file
test
.gitignore
.travis.yml
Makefile
example.js
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# balanced-match
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
## Example
Get the first matching pair of braces:
```js
var balanced = require('balanced-match');
console.log(balanced('{', '}', 'pre{in{nested}}post'));
console.log(balanced('{', '}', 'pre{first}between{second}post'));
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
```
The matches are:
```bash
$ node example.js
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
{ start: 3,
end: 9,
pre: 'pre',
body: 'first',
post: 'between{second}post' }
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
```
## API
### var m = balanced(a, b, str)
For the first non-nested matching pair of `a` and `b` in `str`, return an
object with those keys:
* **start** the index of the first match of `a`
* **end** the index of the matching `b`
* **pre** the preamble, `a` and `b` not included
* **body** the match, `a` and `b` not included
* **post** the postscript, `a` and `b` not included
If there's no match, `undefined` will be returned.
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
### var r = balanced.range(a, b, str)
For the first non-nested matching pair of `a` and `b` in `str`, return an
array with indexes: `[ <a index>, <b index> ]`.
If there's no match, `undefined` will be returned.
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
## Installation
With [npm](https://npmjs.org) do:
```bash
npm install balanced-match
```
## License
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'use strict';
module.exports = balanced;
function balanced(a, b, str) {
if (a instanceof RegExp) a = maybeMatch(a, str);
if (b instanceof RegExp) b = maybeMatch(b, str);
var r = range(a, b, str);
return r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + a.length, r[1]),
post: str.slice(r[1] + b.length)
};
}
function maybeMatch(reg, str) {
var m = str.match(reg);
return m ? m[0] : null;
}
balanced.range = range;
function range(a, b, str) {
var begs, beg, left, right, result;
var ai = str.indexOf(a);
var bi = str.indexOf(b, ai + 1);
var i = ai;
if (ai >= 0 && bi > 0) {
begs = [];
left = str.length;
while (i >= 0 && !result) {
if (i == ai) {
begs.push(i);
ai = str.indexOf(a, i + 1);
} else if (begs.length == 1) {
result = [ begs.pop(), bi ];
} else {
beg = begs.pop();
if (beg < left) {
left = beg;
right = bi;
}
bi = str.indexOf(b, i + 1);
}
i = ai < bi && ai >= 0 ? ai : bi;
}
if (begs.length) {
result = [ left, right ];
}
}
return result;
}
{
"_from": "balanced-match@^1.0.0",
"_id": "balanced-match@1.0.0",
"_inBundle": false,
"_integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"_location": "/balanced-match",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "balanced-match@^1.0.0",
"name": "balanced-match",
"escapedName": "balanced-match",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/brace-expansion"
],
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"_shasum": "89b4d199ab2bee49de164ea02b89ce462d71b767",
"_spec": "balanced-match@^1.0.0",
"_where": "/Users/irina/Desktop/tdt4242-base/node_modules/brace-expansion",
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
"url": "http://juliangruber.com"
},
"bugs": {
"url": "https://github.com/juliangruber/balanced-match/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Match balanced character pairs, like \"{\" and \"}\"",
"devDependencies": {
"matcha": "^0.7.0",
"tape": "^4.6.0"
},
"homepage": "https://github.com/juliangruber/balanced-match",
"keywords": [
"match",
"regexp",
"test",
"balanced",
"parse"
],
"license": "MIT",
"main": "index.js",
"name": "balanced-match",
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/balanced-match.git"
},
"scripts": {
"bench": "make bench",
"test": "make test"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/8..latest",
"firefox/20..latest",
"firefox/nightly",
"chrome/25..latest",
"chrome/canary",
"opera/12..latest",
"opera/next",
"safari/5.1..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2..latest"
]
},
"version": "1.0.0"
}
MIT License
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# brace-expansion
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
as known from sh/bash, in JavaScript.
[![build status](https://secure.travis-ci.org/juliangruber/brace-expansion.svg)](http://travis-ci.org/juliangruber/brace-expansion)
[![downloads](https://img.shields.io/npm/dm/brace-expansion.svg)](https://www.npmjs.org/package/brace-expansion)
[![Greenkeeper badge](https://badges.greenkeeper.io/juliangruber/brace-expansion.svg)](https://greenkeeper.io/)
[![testling badge](https://ci.testling.com/juliangruber/brace-expansion.png)](https://ci.testling.com/juliangruber/brace-expansion)
## Example
```js
var expand = require('brace-expansion');
expand('file-{a,b,c}.jpg')
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
expand('-v{,,}')
// => ['-v', '-v', '-v']
expand('file{0..2}.jpg')
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']