0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/e2e/e2e.spec.js

197 lines
7 KiB
JavaScript
Raw Normal View History

/**
* @prettier
*/
const scopedPackageMetadata = require('./partials/pkg-scoped');
const protectedPackageMetadata = require('./partials/pkg-protected');
2019-02-17 14:39:58 -05:00
describe('/ (Verdaccio Page)', () => {
let page;
// this might be increased based on the delays included in all test
jest.setTimeout(200000);
const clickElement = async function(selector, options = { button: 'middle', delay: 100 }) {
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() {
2019-03-04 16:19:49 -05:00
return await page.$$('.package-list-items .package-link a');
};
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();
await userInput.type('test', { delay: 100 });
await passInput.type('test', { delay: 100 });
await passInput.dispose();
// click on log in
const loginButton = await page.$('#login--form-submit');
expect(loginButton).toBeDefined();
await loginButton.focus();
await loginButton.click({ delay: 100 });
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 () => {
const text = await page.evaluate(() => document.body.textContent);
// FIXME: perhaps it is not the best approach
expect(text).toContain('Powered by');
});
2018-12-05 13:30:08 -05:00
test('should match title with no packages published', async () => {
const text = await page.evaluate(() => document.querySelector('#help-card__title').textContent);
expect(text).toMatch('No Package Published Yet');
});
2018-12-05 13:30:08 -05:00
test('should match title with first step', async () => {
const text = await page.evaluate(() => document.querySelector('#help-card').textContent);
2019-03-27 02:01:28 -05:00
expect(text).toContain('npm adduser --registry http://0.0.0.0:55558');
});
2018-12-05 13:30:08 -05:00
test('should match title with second step', async () => {
const text = await page.evaluate(() => document.querySelector('#help-card').textContent);
2019-03-27 02:01:28 -05:00
expect(text).toContain('npm publish --registry http://0.0.0.0:55558');
});
2018-12-05 13:30:08 -05:00
test('should match button Login to sign in', async () => {
await evaluateSignIn();
});
2018-12-05 13:30:08 -05:00
test('should click on sign in button', async () => {
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 () => {
// 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 () => {
// we assume the user is logged already
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-12-05 13:30:08 -05:00
test('should check registry info dialog', async () => {
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-12-05 13:30:08 -05:00
test('should publish a package', async () => {
await global.__SERVER__.putPackage(scopedPackageMetadata.name, scopedPackageMetadata);
await page.waitFor(1000);
await page.reload();
await page.waitFor(1000);
const packagesList = await getPackages();
expect(packagesList).toHaveLength(1);
});
2018-12-05 13:30:08 -05:00
test('should navigate to the package detail', async () => {
const packagesList = await getPackages();
Package Refactor (#1145) * chore: fix unit test, forgotten line on merge chore: add node 11 to circleci (#1153) chore: fix the use of Node 11 in CircleCI (#1154) refactor: added css in js, new design, added types feat: added Tag component refactor: added modifiers refactor: replaced by polished ellipsis refactor: added types, new design and css in js refactor: removed ul. it needs refactor refactor: changed media queries refactor: changed icon height refactor: changed Header media queries refactor: removed margin top refactor: updated snapshots refactor: removed unnecessary format author refactor: added license icon & changed size refactor: changed media queries refactor: added icon size refactor: changed media queries refactor: updated snap refactor: replaced Description by Details refactor: updated tests refactor: fixed modifiers type feat: created missed types fix: fixed types fix: fixed prop type fix: fixed undefined prop refactor: replaced label by name refactor: updated snap refactor: moved polished to dev refactor: changed formatAuthor and pkg author type fix: removed incorrect meta's type refactor: removed polished refactor: added spacing & ellipsis mixin refactor: added modifier type refactor: changed datetime format refactor: updated snapshots refactor: rreplaced polished by mixins func * refactor: updated styled * fix: added missed semicolon * refactor: updated media * refactor: updated tests * refactor: organized modifiers * refactor: removed unused imports * refactor: design adjusts * refactor: updated snapshot * refactor: changed minor things * refactor: updated snapshots * refactor: commented tests. fix later
2018-12-13 13:05:47 -05:00
const firstPackage = packagesList[0];
await firstPackage.click({ clickCount: 1, delay: 200 });
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 () => {
const versionList = await page.$$('.sidebar-info .detail-info');
2019-02-17 14:39:58 -05:00
expect(versionList).toHaveLength(1);
});
test('should display dependencies tab', async () => {
const dependenciesTab = await page.$$('#dependencies-tab');
expect(dependenciesTab).toHaveLength(1);
await dependenciesTab[0].click({ clickCount: 1, delay: 200 });
await page.waitFor(1000);
const tags = await page.$$('.dep-tag');
const tag = tags[0];
const label = await page.evaluate(el => el.innerText, tag);
expect(label).toMatch('verdaccio@');
});
test('should display version tab', async () => {
const versionsTab = await page.$$('#versions-tab');
expect(versionsTab).toHaveLength(1);
await versionsTab[0].click({ clickCount: 1, delay: 200 });
await page.waitFor(1000);
const versionItems = await page.$$('.version-item');
expect(versionItems).toHaveLength(2);
});
test('should display uplinks tab', async () => {
const upLinksTab = await page.$$('#uplinks-tab');
expect(upLinksTab).toHaveLength(1);
await upLinksTab[0].click({ clickCount: 1, delay: 200 });
await page.waitFor(1000);
});
test('should display readme tab', async () => {
const readmeTab = await page.$$('#readme-tab');
expect(readmeTab).toHaveLength(1);
await readmeTab[0].click({ clickCount: 1, delay: 200 });
await page.waitFor(1000);
});
2018-12-05 13:30:08 -05:00
test('should publish a protected package', async () => {
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);
const text = await page.evaluate(() => document.querySelector('#help-card__title').textContent);
expect(text).toMatch('No Package Published Yet');
});
2019-03-27 14:24:34 -05:00
test('should go to 404 page', async () => {
await page.goto('http://0.0.0.0:55552/-/web/detail/@verdaccio/not-found');
await page.waitFor(500);
const text = await page.evaluate(() => document.querySelector('.not-found-text').textContent);
expect(text).toMatch("Sorry, we couldn't find it...");
});
2018-02-10 07:20:17 -05:00
});