mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-04-01 02:42:23 -05:00
test(e2e): add test scenario to login user
This commit is contained in:
parent
9807e21dee
commit
8c2a755f84
9 changed files with 90 additions and 18 deletions
|
@ -29,7 +29,6 @@ test:
|
|||
- yarn run test
|
||||
- nvm alias default 8
|
||||
- yarn run test
|
||||
- yarn run test:e2e
|
||||
- nvm alias default 9
|
||||
- yarn run test
|
||||
- yarn run test:e2e
|
||||
|
|
|
@ -126,6 +126,7 @@
|
|||
"supertest": "3.0.0",
|
||||
"url-loader": "0.6.2",
|
||||
"verdaccio-auth-memory": "^0.0.4",
|
||||
"verdaccio-memory": "0.0.3",
|
||||
"webpack": "3.10.0",
|
||||
"webpack-dev-server": "2.11.1",
|
||||
"webpack-merge": "4.1.1"
|
||||
|
@ -147,7 +148,7 @@
|
|||
"flow": "flow",
|
||||
"pretest": "npm run code:build",
|
||||
"test": "cross-env NODE_ENV=test BABEL_ENV=test jest --maxWorkers 2",
|
||||
"test:e2e": "cross-env npm run code-test:build && BABEL_ENV=registry jest --config ./jest.e2e.config.js --maxWorkers 2",
|
||||
"test:e2e": "npm run code-test:build && cross-env BABEL_ENV=registry jest --config ./jest.e2e.config.js --maxWorkers 2",
|
||||
"test:unit": "cross-env NODE_ENV=test BABEL_ENV=test jest '(/test/unit.*\\.spec|/test/webui/.*\\.spec)\\.js' --maxWorkers 2",
|
||||
"test:func": "cross-env NODE_ENV=test BABEL_ENV=test jest '(/test/functional.*\\.func)\\.js' --maxWorkers 2",
|
||||
"pre:ci": "npm run lint && npm run build:webui",
|
||||
|
|
|
@ -129,13 +129,13 @@ export default class Header extends React.Component {
|
|||
if (!this.isTokenExpire) { // TODO: Check jwt token expire
|
||||
return (
|
||||
<div className={ classes.welcome }>
|
||||
Hi, {storage.getItem('username')}
|
||||
<span className="user-logged-greetings">Hi, {storage.getItem('username')}</span>
|
||||
|
||||
<Button type="danger" onClick={this.handleLogout}>Logout</Button>
|
||||
<Button className="header-button-logout" type="danger" onClick={this.handleLogout}>Logout</Button>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return <Button type="danger" style={ {marginLeft: 'auto'} } onClick={ this.toggleLoginModal }>Login</Button>;
|
||||
return <Button className="header-button-login" type="danger" style={ {marginLeft: 'auto'} } onClick={ this.toggleLoginModal }>Login</Button>;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,10 +175,10 @@ export default class Header extends React.Component {
|
|||
<Input name="password" type="password" placeholder="Type your password" onChange={this.handleInput.bind(this, 'password')} />
|
||||
</Dialog.Body>
|
||||
<Dialog.Footer className="dialog-footer">
|
||||
<Button onClick={ () => this.toggleLoginModal() }>
|
||||
<Button onClick={ () => this.toggleLoginModal() } className="cancel-login-button">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="primary" onClick={ this.handleSubmit }>
|
||||
<Button type="primary" className="login-button" onClick={ this.handleSubmit }>
|
||||
Login
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
|
|
|
@ -4,6 +4,10 @@ web:
|
|||
enable: true
|
||||
title: verdaccio-server-e2e
|
||||
|
||||
store:
|
||||
memory:
|
||||
cache: true
|
||||
|
||||
auth:
|
||||
auth-memory:
|
||||
users:
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
const timeout = 5000;
|
||||
|
||||
describe('/ (Verdaccio Page)', () => {
|
||||
let page;
|
||||
// this might be increased based on the delays included in all test
|
||||
jest.setTimeout(10000);
|
||||
|
||||
beforeAll(async () => {
|
||||
page = await global.__BROWSER__.newPage();
|
||||
await page.goto('http://0.0.0.0:55558');
|
||||
}, timeout);
|
||||
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await page.close()
|
||||
|
@ -17,6 +18,66 @@ describe('/ (Verdaccio Page)', () => {
|
|||
|
||||
expect(text).toContain('adduser');
|
||||
})
|
||||
},
|
||||
timeout
|
||||
);
|
||||
|
||||
it('should match npm adduser and set registry on header', async () => {
|
||||
let text = await page.evaluate(() => document.querySelector('figure').textContent);
|
||||
expect(text).toMatch('npm set registry http://0.0.0.0:55558');
|
||||
expect(text).toMatch('npm adduser --registry http://0.0.0.0:55558');
|
||||
})
|
||||
|
||||
|
||||
it('should match title with no packages published', async () => {
|
||||
let text = await page.evaluate(() => document.querySelector('.container h1').textContent);
|
||||
expect(text).toMatch('No Package Published Yet');
|
||||
})
|
||||
|
||||
it('should match title with first step', async () => {
|
||||
let text = await page.evaluate(() => document.querySelector('#adduser code').textContent);
|
||||
expect(text).toMatch('npm adduser --registry http://0.0.0.0:55558');
|
||||
})
|
||||
|
||||
it('should match title with second step', async () => {
|
||||
let text = await page.evaluate(() => document.querySelector('#publish code').textContent);
|
||||
expect(text).toMatch('npm publish --registry http://0.0.0.0:55558');
|
||||
})
|
||||
|
||||
it('should match button Login to sign in', async () => {
|
||||
let text = await page.evaluate(() => document.querySelector('header button > span').textContent);
|
||||
expect(text).toMatch('Login');
|
||||
})
|
||||
|
||||
it('should click on sign in button', async () => {
|
||||
const signInButton = await page.$('header button');
|
||||
await signInButton.click();
|
||||
const signInDialog = await page.$('header .el-dialog__wrapper');
|
||||
|
||||
expect(signInDialog).not.toBeNull();
|
||||
})
|
||||
|
||||
it('should log in an user test', async () => {
|
||||
// we open the dialog
|
||||
const signInButton = await page.$('header button');
|
||||
await signInButton.click({button: 'middle', delay: 100});
|
||||
await page.waitFor(500);
|
||||
// we fill the sign in form
|
||||
const signInDialog = await page.$('.el-dialog');
|
||||
const userInput = await signInDialog.$('input[type=text]');
|
||||
expect(userInput).not.toBeNull();
|
||||
const passInput = await signInDialog.$('input[type=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-button');
|
||||
expect(loginButton).toBeDefined();
|
||||
await loginButton.focus();
|
||||
await loginButton.click({delay: 100});
|
||||
await page.waitFor(500);
|
||||
// check whether user is logged
|
||||
const greetings = await page.evaluate(() => document.querySelector('.user-logged-greetings').textContent);
|
||||
const buttonLogout = await page.$('.header-button-logout');
|
||||
expect(greetings).toMatch('Hi, test');
|
||||
expect(buttonLogout).toBeDefined();
|
||||
})
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = async function() {
|
|||
|
||||
const fork = await process1.init();
|
||||
console.log(chalk.green('Setup Puppeteer'));
|
||||
const browser = await puppeteer.launch({});
|
||||
const browser = await puppeteer.launch();
|
||||
global.__BROWSER__ = browser;
|
||||
global.__VERDACCIO_E2E__ = fork[0];
|
||||
mkdirp.sync(DIR);
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"list":[],"secret":"d51457fa8526d9ca3e00289433746e39f445cff4640409d4ba305e0232e13ae7"}
|
|
@ -1,3 +1,3 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Header /> snapshot test shoud match snapshot 1`] = `"<header class=\\"header\\"><div class=\\"headerWrap\\"><a href=\\"/\\"><img src=\\"\\" class=\\"logo\\"></a><figure>npm set registry nullblank<br>npm adduser --registry nullblank</figure><button style=\\"margin-left: auto;\\" class=\\"el-button el-button--danger\\" type=\\"button\\"><span>Login</span></button></div><div><div style=\\"z-index: 1013; display: none;\\" class=\\"el-dialog__wrapper\\"><div style=\\"top: 15%;\\" class=\\"el-dialog el-dialog--tiny\\"><div class=\\"el-dialog__header\\"><span class=\\"el-dialog__title\\">Login</span><button type=\\"button\\" class=\\"el-dialog__headerbtn\\"><i class=\\"el-dialog__close el-icon el-icon-close\\"></i></button></div><div class=\\"el-dialog__body\\"><br><div class=\\"el-input\\"><input type=\\"text\\" name=\\"username\\" placeholder=\\"Username\\" class=\\"el-input__inner\\" autocomplete=\\"off\\"></div><br><br><div class=\\"el-input\\"><input type=\\"password\\" name=\\"password\\" placeholder=\\"Type your password\\" class=\\"el-input__inner\\" autocomplete=\\"off\\"></div></div><div class=\\"el-dialog__footer dialog-footer\\"><button class=\\"el-button el-button--default\\" type=\\"button\\"><span>Cancel</span></button><button class=\\"el-button el-button--primary\\" type=\\"button\\"><span>Login</span></button></div></div></div><div class=\\"v-modal\\" style=\\"z-index: 1012; display: none;\\"></div></div></header>"`;
|
||||
exports[`<Header /> snapshot test shoud match snapshot 1`] = `"<header class=\\"header\\"><div class=\\"headerWrap\\"><a href=\\"/\\"><img src=\\"\\" class=\\"logo\\"></a><figure>npm set registry nullblank<br>npm adduser --registry nullblank</figure><button style=\\"margin-left: auto;\\" class=\\"el-button el-button--danger header-button-login\\" type=\\"button\\"><span>Login</span></button></div><div><div style=\\"z-index: 1013; display: none;\\" class=\\"el-dialog__wrapper\\"><div style=\\"top: 15%;\\" class=\\"el-dialog el-dialog--tiny\\"><div class=\\"el-dialog__header\\"><span class=\\"el-dialog__title\\">Login</span><button type=\\"button\\" class=\\"el-dialog__headerbtn\\"><i class=\\"el-dialog__close el-icon el-icon-close\\"></i></button></div><div class=\\"el-dialog__body\\"><br><div class=\\"el-input\\"><input type=\\"text\\" name=\\"username\\" placeholder=\\"Username\\" class=\\"el-input__inner\\" autocomplete=\\"off\\"></div><br><br><div class=\\"el-input\\"><input type=\\"password\\" name=\\"password\\" placeholder=\\"Type your password\\" class=\\"el-input__inner\\" autocomplete=\\"off\\"></div></div><div class=\\"el-dialog__footer dialog-footer\\"><button class=\\"el-button el-button--default cancel-login-button\\" type=\\"button\\"><span>Cancel</span></button><button class=\\"el-button el-button--primary login-button\\" type=\\"button\\"><span>Login</span></button></div></div></div><div class=\\"v-modal\\" style=\\"z-index: 1012; display: none;\\"></div></div></header>"`;
|
||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -200,7 +200,7 @@
|
|||
lodash "4.17.4"
|
||||
mkdirp "0.5.1"
|
||||
|
||||
"@verdaccio/streams@0.0.2":
|
||||
"@verdaccio/streams@0.0.2", "@verdaccio/streams@^0.0.2":
|
||||
version "0.0.2"
|
||||
resolved "https://registry.npmjs.org/@verdaccio/streams/-/streams-0.0.2.tgz#72cd65449e657b462a1ca094f663cad9ea872427"
|
||||
|
||||
|
@ -5598,7 +5598,7 @@ mem@^1.1.0:
|
|||
dependencies:
|
||||
mimic-fn "^1.0.0"
|
||||
|
||||
memory-fs@^0.4.0, memory-fs@~0.4.1:
|
||||
memory-fs@^0.4.0, memory-fs@^0.4.1, memory-fs@~0.4.1:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552"
|
||||
dependencies:
|
||||
|
@ -8802,6 +8802,14 @@ verdaccio-auth-memory@^0.0.4:
|
|||
version "0.0.4"
|
||||
resolved "https://registry.npmjs.org/verdaccio-auth-memory/-/verdaccio-auth-memory-0.0.4.tgz#b44a65209778a8dc3c8d39478141a0bc22e04375"
|
||||
|
||||
verdaccio-memory@0.0.3:
|
||||
version "0.0.3"
|
||||
resolved "https://registry.npmjs.org/verdaccio-memory/-/verdaccio-memory-0.0.3.tgz#8ba6b51f2cf93d67958fedad5feb3f1e19933e48"
|
||||
dependencies:
|
||||
"@verdaccio/streams" "^0.0.2"
|
||||
http-errors "1.6.2"
|
||||
memory-fs "^0.4.1"
|
||||
|
||||
verror@1.10.0:
|
||||
version "1.10.0"
|
||||
resolved "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"
|
||||
|
|
Loading…
Add table
Reference in a new issue