test(e2e): add test scenario to load readme on detail page

This commit is contained in:
Juan Picado @jotadeveloper 2018-02-10 17:09:02 +01:00
parent 705eda1697
commit e91bb8e723
No known key found for this signature in database
GPG Key ID: 18AC54485952D158
2 changed files with 19 additions and 5 deletions

View File

@ -16,7 +16,7 @@ auth:
password: test password: test
logs: logs:
- {type: stdout, format: pretty, level: trace} - {type: stdout, format: pretty, level: warn}
packages: packages:
'@*/*': '@*/*':

View File

@ -3,9 +3,9 @@ const publishMetadata = require('../unit/partials/publish-api');
describe('/ (Verdaccio Page)', () => { describe('/ (Verdaccio Page)', () => {
let page; let page;
// this might be increased based on the delays included in all test // this might be increased based on the delays included in all test
jest.setTimeout(10000000); jest.setTimeout(20000);
const clickButton = async function(selector, options = {button: 'middle', delay: 100}) { const clickElement = async function(selector, options = {button: 'middle', delay: 100}) {
const button = await page.$(selector); const button = await page.$(selector);
await button.focus(); await button.focus();
await button.click(options); await button.click(options);
@ -21,7 +21,7 @@ describe('/ (Verdaccio Page)', () => {
} }
const logIn = async function() { const logIn = async function() {
await clickButton('header button'); await clickElement('header button');
await page.waitFor(500); await page.waitFor(500);
// we fill the sign in form // we fill the sign in form
const signInDialog = await page.$('.el-dialog'); const signInDialog = await page.$('.el-dialog');
@ -102,7 +102,7 @@ describe('/ (Verdaccio Page)', () => {
it('should logout an user', async () => { it('should logout an user', async () => {
// we asume the user is logged already // we asume the user is logged already
await clickButton('.header-button-logout', {clickCount: 3, delay: 200}); await clickElement('.header-button-logout', {clickCount: 1, delay: 200});
await page.waitFor(1000); await page.waitFor(1000);
await evaluateSignIn(); await evaluateSignIn();
}) })
@ -113,6 +113,20 @@ describe('/ (Verdaccio Page)', () => {
await page.reload(); await page.reload();
await page.waitFor(1000); await page.waitFor(1000);
const packagesList = await getPackages(); const packagesList = await getPackages();
expect(packagesList).toHaveLength(1); expect(packagesList).toHaveLength(1);
}); });
it('should navigate to the package detail', async () => {
const packagesList = await getPackages();
const packageItem = packagesList[0];
await packageItem.focus();
await packageItem.click({clickCount: 1, delay: 200});
await page.waitFor(1000);
await page.screenshot({path: 'readme.png'});
const readmeText = await page.evaluate(() => document.querySelector('.markdown-body').textContent);
expect(readmeText).toMatch('test');
});
}); });