Skip to content

Commit 58cb4c7

Browse files
committed
Merge branch '4.x-master' of github.com:verdaccio/ui into 4.x-master
2 parents 6f8d891 + e1d8eaf commit 58cb4c7

File tree

8 files changed

+118
-4
lines changed

8 files changed

+118
-4
lines changed

codecept.conf.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
exports.config = {
3+
tests: './test/acceptance/*_test.js',
4+
output: './test/acceptance/output',
5+
helpers: {
6+
Puppeteer: {
7+
url: 'http://localhost:8080',
8+
// "show": true,
9+
chrome: {
10+
// headless: false
11+
}
12+
}
13+
},
14+
include: {
15+
I: './test/acceptance/steps_file.js'
16+
},
17+
smartWait: 30000,
18+
bootstrap: null,
19+
plugins: {},
20+
mocha: {},
21+
name: '@verdaccio/ui-theme'
22+
}

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
"@verdaccio/eslint-config": "2.0.0",
2929
"@verdaccio/types": "7.0.0",
3030
"autosuggest-highlight": "3.1.1",
31-
"babel-loader": "8.0.6",
3231
"bundlesize": "0.18.0",
32+
"codeceptjs": "2.1.0",
3333
"codecov": "3.5.0",
34+
"babel-loader": "8.0.6",
3435
"concurrently": "4.1.0",
3536
"cross-env": "5.2.0",
3637
"css-loader": "0.28.10",
@@ -136,7 +137,10 @@
136137
"type-check": "tsc --noEmit",
137138
"type-check:watch": "npm run type-check -- --watch",
138139
"release": "standard-version -a -s",
139-
"test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2",
140+
"test:clean": "npx jest --clearCache",
141+
"test:acceptance": "codeceptjs run --steps",
142+
"test:acceptance:server": "concurrently --kill-others \"npm run verdaccio:server\" \"npm run test:acceptance\"",
143+
"test": "cross-env NODE_ENV=test BABEL_ENV=test TZ=UTC jest --config ./jest/jest.config.js --maxWorkers 2 --passWithNoTests",
140144
"test:size": "bundlesize",
141145
"lint": "npm run lint:js && npm run lint:css",
142146
"lint:js": "npm run type-check && eslint . --ext .js,.ts,.tsx",
Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,68 @@
11
import React from 'react';
22
import { shallow } from 'enzyme';
33

4-
import Repository from './Repository';
4+
jest.mock('./img/git.png', () => '');
55

66
describe('<Repository /> component', () => {
7+
beforeEach(() => {
8+
jest.resetModules();
9+
});
10+
711
test('should render the component in default state', () => {
12+
const packageMeta = {
13+
latest: {
14+
repository: {
15+
type: 'git',
16+
url: 'git+https://github.com/verdaccio/ui.git',
17+
},
18+
},
19+
};
20+
21+
jest.doMock('../../pages/version/Version', () => ({
22+
DetailContextConsumer: component => {
23+
return component.children({ packageMeta });
24+
},
25+
}));
26+
27+
const Repository = require('./Repository').default;
828
const wrapper = shallow(<Repository />);
929
expect(wrapper.html()).toMatchSnapshot();
1030
});
31+
32+
test('should render the component in with no repository data', () => {
33+
const packageMeta = {
34+
latest: {},
35+
};
36+
37+
jest.doMock('../../pages/version/Version', () => ({
38+
DetailContextConsumer: component => {
39+
return component.children({ packageMeta });
40+
},
41+
}));
42+
43+
const Repository = require('./Repository').default;
44+
const wrapper = shallow(<Repository />);
45+
expect(wrapper.html()).toEqual('');
46+
});
47+
48+
test('should render the component in with invalid url', () => {
49+
const packageMeta = {
50+
latest: {
51+
repository: {
52+
type: 'git',
53+
url: 'git://github.com/verdaccio/ui.git',
54+
},
55+
},
56+
};
57+
58+
jest.doMock('../../pages/version/Version', () => ({
59+
DetailContextConsumer: component => {
60+
return component.children({ packageMeta });
61+
},
62+
}));
63+
64+
const Repository = require('./Repository').default;
65+
const wrapper = shallow(<Repository />);
66+
expect(wrapper.html()).toEqual('');
67+
});
1168
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`<Repository /> component should render the component in default state 1`] = `""`;
3+
exports[`<Repository /> component should render the component in default state 1`] = `"<ul class=\\"MuiList-root-1 MuiList-dense-3 MuiList-padding-2 MuiList-subheader-4\\"><h3 class=\\"MuiTypography-root-5 MuiTypography-subheading-12 css-hyrz44 e1wmjxnh0\\">Repository</h3><li class=\\"MuiListItem-root-41 MuiListItem-default-44 MuiListItem-dense-45 MuiListItem-gutters-49 css-z8a2h0 e1wmjxnh4\\"><div class=\\"MuiAvatar-root-53 MuiAvatar-colorDefault-54\\"></div><div class=\\"MuiListItemText-root-56 MuiListItemText-dense-58\\"><span class=\\"MuiTypography-root-5 MuiTypography-subheading-12 MuiListItemText-primary-59 MuiListItemText-textDense-61\\"><div class=\\"css-1mta3t8 eb8w2fo0\\"><span class=\\"css-1m8aenu eb8w2fo1\\"><a href=\\"git+https://github.com/verdaccio/ui.git\\" target=\\"_blank\\" class=\\"css-15gl0ho e1wmjxnh2\\">git+https://github.com/verdaccio/ui.git</a></span><button class=\\"MuiButtonBase-root-76 MuiIconButton-root-70 css-56v3u0 eb8w2fo2\\" tabindex=\\"0\\" type=\\"button\\" title=\\"Copy to Clipboard\\"><span class=\\"MuiIconButton-label-75\\"><svg class=\\"MuiSvgIcon-root-79\\" focusable=\\"false\\" viewBox=\\"0 0 24 24\\" aria-hidden=\\"true\\" role=\\"presentation\\"><path fill=\\"none\\" d=\\"M0 0h24v24H0z\\"></path><path d=\\"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z\\"></path></svg></span></button></div></span></div></li></ul>"`;

test/acceptance/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
output

test/acceptance/Menu_test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Feature('Menu');
2+
3+
Scenario('check if we find the npm commands to set the registry', (I) => {
4+
I.amOnPage('http://localhost:8080');
5+
I.waitForElement('#header--button-registryInfo', 5);
6+
I.click('#header--button-registryInfo');
7+
I.waitForElement('#registryInfo--dialog-container');
8+
I.see('npm set registry http://localhost:8080');
9+
});

test/acceptance/SearchResult_test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Feature('SearchResult');
2+
3+
Scenario('check if we get the "no results found" text', (I) => {
4+
I.amOnPage('http://localhost:8080');
5+
I.seeElement('header .react-autosuggest__input input');
6+
I.fillField('header .react-autosuggest__input input', 'test');
7+
I.waitForElement('header .react-autosuggest__suggestions-container');
8+
I.wait(1);
9+
I.see('No results found.', 'header .react-autosuggest__suggestions-container');
10+
});

test/acceptance/steps_file.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
// in this file you can append custom step methods to 'I' object
3+
4+
module.exports = function() {
5+
return actor({
6+
7+
// Define custom steps here, use 'this' to access default methods of I.
8+
// It is recommended to place a general 'login' function here.
9+
10+
});
11+
}

0 commit comments

Comments
 (0)