2018-09-24 15:04:37 -05:00
|
|
|
/**
|
|
|
|
* @prettier
|
|
|
|
*/
|
|
|
|
|
2018-03-13 16:15:21 -05:00
|
|
|
const scopedPackageMetadata = require('./partials/pkg-scoped');
|
|
|
|
const protectedPackageMetadata = require('./partials/pkg-protected');
|
2018-02-10 10:43:14 -05:00
|
|
|
|
2019-01-23 02:25:51 -05:00
|
|
|
describe.skip('/ (Verdaccio Page)', () => {
|
2018-09-24 15:04:37 -05:00
|
|
|
let page;
|
|
|
|
// this might be increased based on the delays included in all test
|
|
|
|
jest.setTimeout(200000);
|
|
|
|
|
2018-10-01 00:06:30 -05:00
|
|
|
const clickElement = async function(selector, options = { button: 'middle', delay: 100 }) {
|
2018-09-24 15:04:37 -05:00
|
|
|
const button = await page.$(selector);
|
|
|
|
await button.focus();
|
|
|
|
await button.click(options);
|
|
|
|
};
|
|
|
|
|
|
|
|
const evaluateSignIn = async function() {
|
|
|
|
const text = await page.evaluate(() => document.querySelector('#header--button-login').textContent);
|
|
|
|
expect(text).toMatch('Login');
|
|
|
|
};
|
|
|
|
|
|
|
|
const getPackages = async function() {
|
2018-12-13 13:05:47 -05:00
|
|
|
return await page.$$('.package-list-items .package');
|
2018-09-24 15:04:37 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
const logIn = async function() {
|
|
|
|
await clickElement('#header--button-login');
|
|
|
|
await page.waitFor(500);
|
|
|
|
// we fill the sign in form
|
|
|
|
const signInDialog = await page.$('#login--form-container');
|
|
|
|
const userInput = await signInDialog.$('#login--form-username');
|
|
|
|
expect(userInput).not.toBeNull();
|
|
|
|
const passInput = await signInDialog.$('#login--form-password');
|
|
|
|
expect(passInput).not.toBeNull();
|
2018-10-01 00:06:30 -05:00
|
|
|
await userInput.type('test', { delay: 100 });
|
|
|
|
await passInput.type('test', { delay: 100 });
|
2018-09-24 15:04:37 -05:00
|
|
|
await passInput.dispose();
|
|
|
|
// click on log in
|
|
|
|
const loginButton = await page.$('#login--form-submit');
|
|
|
|
expect(loginButton).toBeDefined();
|
|
|
|
await loginButton.focus();
|
2018-10-01 00:06:30 -05:00
|
|
|
await loginButton.click({ delay: 100 });
|
2018-09-24 15:04:37 -05:00
|
|
|
await page.waitFor(500);
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
page = await global.__BROWSER__.newPage();
|
|
|
|
await page.goto('http://0.0.0.0:55558');
|
|
|
|
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await page.close();
|
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should load without error', async () => {
|
2018-11-16 16:29:56 -05:00
|
|
|
const text = await page.evaluate(() => document.body.textContent);
|
2018-09-24 15:04:37 -05:00
|
|
|
|
2018-09-27 09:37:45 -05:00
|
|
|
// FIXME: perhaps it is not the best approach
|
|
|
|
expect(text).toContain('Powered by');
|
2018-09-24 15:04:37 -05:00
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should match title with no packages published', async () => {
|
2018-11-16 16:29:56 -05:00
|
|
|
const text = await page.evaluate(() => document.querySelector('#help-card__title').textContent);
|
2018-09-24 15:04:37 -05:00
|
|
|
expect(text).toMatch('No Package Published Yet');
|
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should match title with first step', async () => {
|
2018-11-16 16:29:56 -05:00
|
|
|
const text = await page.evaluate(() => document.querySelector('#help-card').textContent);
|
|
|
|
expect(text).toContain('$ npm adduser --registry http://0.0.0.0:55558');
|
2018-09-24 15:04:37 -05:00
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should match title with second step', async () => {
|
2018-11-16 16:29:56 -05:00
|
|
|
const text = await page.evaluate(() => document.querySelector('#help-card').textContent);
|
|
|
|
expect(text).toContain('$ npm publish --registry http://0.0.0.0:55558');
|
2018-09-24 15:04:37 -05:00
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should match button Login to sign in', async () => {
|
2018-09-24 15:04:37 -05:00
|
|
|
await evaluateSignIn();
|
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should click on sign in button', async () => {
|
2018-09-24 15:04:37 -05:00
|
|
|
const signInButton = await page.$('#header--button-login');
|
|
|
|
await signInButton.click();
|
|
|
|
await page.waitFor(1000);
|
|
|
|
const signInDialog = await page.$('#login--form-container');
|
|
|
|
|
|
|
|
expect(signInDialog).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should log in an user', async () => {
|
2018-09-24 15:04:37 -05:00
|
|
|
// we open the dialog
|
|
|
|
await logIn();
|
|
|
|
// check whether user is logged
|
|
|
|
const buttonLogout = await page.$('#header--button-logout');
|
|
|
|
expect(buttonLogout).toBeDefined();
|
|
|
|
});
|
2018-02-10 07:20:17 -05:00
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should logout an user', async () => {
|
2018-09-24 15:04:37 -05:00
|
|
|
// we assume the user is logged already
|
2018-10-11 16:48:40 -05:00
|
|
|
await clickElement('#header--button-account', { clickCount: 1, delay: 500 });
|
|
|
|
await page.waitFor(1000);
|
|
|
|
await clickElement('#header--button-logout > span', { clickCount: 1, delay: 500 });
|
2018-02-10 07:20:17 -05:00
|
|
|
await page.waitFor(1000);
|
|
|
|
await evaluateSignIn();
|
2018-09-24 15:04:37 -05:00
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should check registry info dialog', async () => {
|
2018-09-24 15:04:37 -05:00
|
|
|
const registryInfoButton = await page.$('#header--button-registryInfo');
|
|
|
|
registryInfoButton.click();
|
|
|
|
await page.waitFor(500);
|
|
|
|
|
|
|
|
const registryInfoDialog = await page.$('#registryInfo--dialog-container');
|
|
|
|
expect(registryInfoDialog).not.toBeNull();
|
|
|
|
|
|
|
|
const closeButton = await page.$('#registryInfo--dialog-close');
|
|
|
|
closeButton.click();
|
|
|
|
});
|
2018-02-10 10:43:14 -05:00
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should publish a package', async () => {
|
2018-03-13 16:15:21 -05:00
|
|
|
await global.__SERVER__.putPackage(scopedPackageMetadata.name, scopedPackageMetadata);
|
2018-02-10 10:43:14 -05:00
|
|
|
await page.waitFor(1000);
|
|
|
|
await page.reload();
|
|
|
|
await page.waitFor(1000);
|
|
|
|
const packagesList = await getPackages();
|
|
|
|
expect(packagesList).toHaveLength(1);
|
|
|
|
});
|
2018-02-10 11:09:02 -05:00
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should navigate to the package detail', async () => {
|
2018-02-10 11:09:02 -05:00
|
|
|
const packagesList = await getPackages();
|
2018-12-13 13:05:47 -05:00
|
|
|
const firstPackage = packagesList[0];
|
|
|
|
await firstPackage.focus();
|
|
|
|
await firstPackage.click({ clickCount: 1, delay: 200 });
|
2018-02-10 11:09:02 -05:00
|
|
|
await page.waitFor(1000);
|
|
|
|
const readmeText = await page.evaluate(() => document.querySelector('.markdown-body').textContent);
|
|
|
|
expect(readmeText).toMatch('test');
|
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should contains last sync information', async () => {
|
2019-01-23 02:25:51 -05:00
|
|
|
const versionList = await page.$$('.sidebar-info .detail-info');
|
2018-02-10 18:02:14 -05:00
|
|
|
expect(versionList).toHaveLength(3);
|
|
|
|
});
|
|
|
|
|
2018-12-05 13:30:08 -05:00
|
|
|
test('should publish a protected package', async () => {
|
2018-03-13 16:15:21 -05:00
|
|
|
await page.goto('http://0.0.0.0:55552');
|
|
|
|
await page.waitFor(500);
|
|
|
|
await global.__SERVER_PROTECTED__.putPackage(protectedPackageMetadata.name, protectedPackageMetadata);
|
|
|
|
await page.waitFor(500);
|
|
|
|
await page.reload();
|
|
|
|
await page.waitFor(500);
|
2018-11-16 16:29:56 -05:00
|
|
|
const text = await page.evaluate(() => document.querySelector('#help-card__title').textContent);
|
2018-03-13 16:15:21 -05:00
|
|
|
expect(text).toMatch('No Package Published Yet');
|
|
|
|
});
|
2018-02-10 07:20:17 -05:00
|
|
|
});
|