-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding tests for Record view, request file, search #1488
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation error |
||
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); | ||
} | ||
}); | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
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('should have a report abuse link', async function () { | ||
// let page = Nightmare(nightmareConfig).goto(B2SHARE_URL+'/records/47077e3c4b9f4852a40709e338ad4620'); | ||
// await expect(await page.title() == 'B2SHARE'); | ||
// await page.wait('.large-record .row .col-lg-12 a.btn.btn-default') | ||
// .click('.large-record .row .col-lg-12 a.btn.btn-default') | ||
|
||
// await expect(page.url() == B2SHARE_URL+'/records/47077e3c4b9f4852a40709e338ad4620/abuse'); | ||
|
||
// await page.click(' .form-horizontal .row .col-sm-1 > #abusecontent ') //checked | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't find the radio button, can you please take a look? @emanueldima |
||
// .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') | ||
// // .end() | ||
// }); | ||
|
||
|
||
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 () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a function for this pattern would be more readable (see assertElementText) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I tried to use it, but most of the time it doesn't find the element :/ I know, doesn't make sense! |
||
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 () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented this test for now, because there is no restricted record in the demo. |
||
// 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') | ||
// }); | ||
// }); | ||
|
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(); | ||
} | ||
|
||
} | ||
}); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep the indentation here consistent