-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tests for Record view, request file, search
- Loading branch information
Showing
7 changed files
with
201 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,43 @@ | ||
import Nightmare from 'nightmare'; | ||
import { B2ACCESS_AUTH_URL, B2SHARE_URL, USER_NAME, USER_PASS, USER_EMAIL, | ||
nightmareConfig, step, print_obj, assertPageContains, assertElementText } from './common'; | ||
nightmareConfig, step, print_obj, assertPageContains, assertElementText, login } from './common'; | ||
|
||
|
||
describe('Homepage', function () { | ||
describe('Homepage', function () { | ||
test('well formed homepage', async function () { | ||
let page = Nightmare(nightmareConfig).goto(B2SHARE_URL); | ||
expect(await page.title() == 'B2SHARE'); | ||
|
||
await expect(await page.title() == 'B2SHARE'); | ||
await page.wait('#header-navbar-collapse a'); | ||
await page.wait('#page .home-page .record a'); | ||
await page.end(); | ||
}); | ||
}); | ||
|
||
describe('Login', function () { | ||
test('user can login', async function () { | ||
let page = Nightmare(nightmareConfig).goto(B2SHARE_URL); | ||
|
||
await page.wait('#header-navbar-collapse > .user > li > a') | ||
.click('#header-navbar-collapse > .user > li > a'); | ||
|
||
await expect(page.url() == B2ACCESS_AUTH_URL); | ||
|
||
await page.wait('#AuthenticationUI\\.username'); | ||
await assertPageContains(page, "Login to UNITY OAuth2 Authorization Server"); | ||
|
||
await page.type('#AuthenticationUI\\.username', USER_NAME) | ||
.type('#WebPasswordRetrieval\\.password', USER_PASS) | ||
.click('#AuthenticationUI\\.authnenticateButton') | ||
.wait('#IdpButtonsBar\\.confirmButton') | ||
.click('#IdpButtonsBar\\.confirmButton'); | ||
|
||
expect(await page.title() == 'B2SHARE'); | ||
|
||
await page.wait('#header-navbar-collapse a'); | ||
describe('Login', function () { | ||
test('user can login', async function() { | ||
let page = Nightmare(nightmareConfig).goto(B2SHARE_URL); | ||
try { | ||
await login(page); | ||
// page.end(); | ||
} catch(e){ | ||
console.error(e); | ||
} | ||
}); | ||
}); | ||
|
||
await assertElementText(page, '#header-navbar-collapse > .user > li > a', USER_EMAIL); | ||
describe('User profile', function () { | ||
test('user can navigate to the profile page', async function() { | ||
let page = Nightmare(nightmareConfig).goto(B2SHARE_URL); | ||
try { | ||
await login(page); | ||
await page.click('#header-navbar-collapse .user .dropdown .dropdown-toggle') | ||
.wait('#header-navbar-collapse .user li a .dropdown-menu li a') | ||
.click('#header-navbar-collapse .user li a .dropdown-menu li a'); | ||
// page.end(); | ||
} catch(e){ | ||
console.error(e); | ||
} | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import Nightmare from 'nightmare'; | ||
import { B2ACCESS_AUTH_URL, B2SHARE_URL, USER_NAME, USER_PASS, USER_EMAIL, | ||
nightmareConfig, step, print_obj, assertPageContains, assertElementText, login } from './common'; | ||
|
||
describe('A published record', function () { | ||
test('can be loaded and download the file', async function () { | ||
let page = Nightmare(nightmareConfig).goto(B2SHARE_URL+'/records/47077e3c4b9f4852a40709e338ad4620'); | ||
await expect(await page.title() == 'B2SHARE'); | ||
|
||
await assertElementText(page, '.col-lg-6 .well .fileList .file .row .col-sm-9 ', 'myfile'); //file name exists | ||
await assertElementText(page, '.col-lg-6 .well .fileList .file .row .col-sm-3 ', '9 B'); // file size exists | ||
|
||
await page.wait('.col-lg-6 .well .fileList .file .row .col-sm-9 > a') | ||
.click('.col-lg-6 .well .fileList .file .row .col-sm-9 > a') | ||
// .end() | ||
.then(function (result) { | ||
console.log(result) | ||
}) | ||
.catch(function (error) { | ||
console.error('Error:', error); | ||
}); | ||
}); | ||
|
||
|
||
test('have basic metadata like open access, file size, file name', async function(){ | ||
let page = Nightmare(nightmareConfig).goto(B2SHARE_URL+'/records/47077e3c4b9f4852a40709e338ad4620'); | ||
|
||
await page.wait('.col-lg-6 .well .col-sm-12.list-unstyled li .col-sm-8') //Open Access | ||
.evaluate(function () { | ||
return document.querySelector('.col-lg-6 .well .col-sm-12.list-unstyled li .col-sm-8').innerText | ||
}) | ||
.then(function(el) { | ||
expect(el).toEqual('True'); | ||
}) | ||
|
||
await page.wait('.col-lg-6 .well .fileList .file .row .col-sm-9 a') // File Name | ||
.evaluate(function () { | ||
console.log("value = ", document.querySelector('.col-lg-6 .well .fileList .file .row .col-sm-9 a').innerText) | ||
return document.querySelector('.col-lg-6 .well .fileList .file .row .col-sm-9 a').innerText | ||
}) | ||
.then(function(el) { | ||
expect(el).toEqual('myfile'); | ||
}) | ||
|
||
await page.wait('.col-lg-6 .well .fileList .file .row .col-sm-9 a') // File size | ||
.evaluate(function () { | ||
console.log("value = ", document.querySelector('.col-lg-6 .well .fileList .file .row .col-sm-3').innerText) | ||
return document.querySelector('.col-lg-6 .well .fileList .file .row .col-sm-3').innerText | ||
}) | ||
.then(function(el) { | ||
expect(el.replace( /\s/g, "")).toEqual('9B'); | ||
}) | ||
}); | ||
}); | ||
|
||
// Should move it after creating a new record with restrict access! | ||
// describe('A restricted published record', function () { | ||
// test('have open access equal to false, have a request file link and send the request file form', async function(){ | ||
// let page = Nightmare(nightmareConfig).goto(B2SHARE_URL+'/records/5e025f1af344444498ec555e7732fc7c'); | ||
// await page.wait('.col-lg-6 .well .col-sm-12.list-unstyled li .col-sm-8') | ||
// .evaluate(function () { | ||
// return document.querySelector('.col-lg-6 .well .col-sm-12.list-unstyled li .col-sm-8').innerText | ||
// }) | ||
// .then(function(el) { | ||
// expect(el).toEqual('False'); | ||
// }); | ||
|
||
// await page.wait('.large-record .row .col-lg-6 .well a') | ||
// .click('.large-record .row .col-lg-6 .well a'); | ||
|
||
// await expect(page.url() == B2SHARE_URL+'/records/5e025f1af344444498ec555e7732fc7c/accessrequest'); | ||
|
||
// await page.type(' .form-horizontal .row .col-sm-8 > textarea ', 'message') | ||
// .type(' .form-horizontal .row .col-sm-8 > input#name', 'firstname lastname') | ||
// .type(' .form-horizontal .row .col-sm-8 > input#affiliation', 'affiliation') | ||
// .type(' .form-horizontal .row .col-sm-8 > input#email', '[email protected]') | ||
// .type(' .form-horizontal .row .col-sm-8 > input#address', 'address') | ||
// .type(' .form-horizontal .row .col-sm-8 > input#city', 'Stockholm') | ||
// .type(' .form-horizontal .row .col-sm-8 > select#country', 'Sweden') | ||
// .type(' .form-horizontal .row .col-sm-8 > input#zipcode', '12345') | ||
// .type(' .form-horizontal .row .col-sm-8 > input#phone', '6392615304') | ||
// .click(' .form-horizontal .row .col-sm-offset-2.col-sm-8 .btn.btn-primary.btn-default.btn-block') | ||
// }); | ||
// }); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Nightmare from 'nightmare'; | ||
import { B2ACCESS_AUTH_URL, B2SHARE_URL, USER_NAME, USER_PASS, USER_EMAIL, | ||
nightmareConfig, step, print_obj, assertPageContains, assertElementText, login } from './common'; | ||
|
||
describe('Searching in the records', function () { | ||
test('for a common term', async function() { | ||
let queries = ['paper','ChiP-seq','Daniel Zeman', 'RDA', 'wrong_query']; | ||
|
||
for (let query of queries) { | ||
let page = Nightmare(nightmareConfig).goto(B2SHARE_URL); | ||
await page.wait('#header-navbar-collapse form .nav-search .form-control') | ||
.type('#header-navbar-collapse form .nav-search .form-control', query) | ||
.click('#header-navbar-collapse form .nav-search .input-group-btn button.btn.btn-primary') | ||
|
||
await expect(page.url() == B2SHARE_URL+'/records/?q='+query+'#'); | ||
switch(query){ | ||
case 'wrong_query': | ||
await page.evaluate(()=>document.body.textContent) | ||
.then(function(body){ | ||
expect(body).toContain('No results'); | ||
}) | ||
page.end(); | ||
break; | ||
default: | ||
await page.wait('.record.col-lg-12') | ||
.evaluate(()=>document.body.textContent) | ||
.then(function(body){ | ||
expect(body).toContain('1 - 1 of 1 results'); | ||
}) | ||
page.end(); | ||
} | ||
|
||
} | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.