diff --git a/CHANGELOG.md b/CHANGELOG.md index e3e768e64..65bef8fac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,22 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +# [3.6.0](https://github.com/verdaccio/verdaccio/compare/v3.5.1...v3.6.0) (2018-08-13) + + +### Bug Fixes + +* abort the stream to prevent overwriting existing tarbal ([2e5a409](https://github.com/verdaccio/verdaccio/commit/2e5a409)) +* **webui:** search crash on ' ' as a value [#898](https://github.com/verdaccio/verdaccio/issues/898) ([#902](https://github.com/verdaccio/verdaccio/issues/902)) ([fd67698](https://github.com/verdaccio/verdaccio/commit/fd67698)) + + +### Features + +* **translations:** enable Chinese Simplified on website ([88b29e0](https://github.com/verdaccio/verdaccio/commit/88b29e0)) + + + ## [3.5.1](https://github.com/verdaccio/verdaccio/compare/v3.5.0...v3.5.1) (2018-08-02) diff --git a/package.json b/package.json index bce633d69..0d08fabcf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "verdaccio", - "version": "3.5.1", + "version": "3.6.0", "description": "Private npm repository server", "author": { "name": "Alex Kocharin", diff --git a/src/lib/local-storage.js b/src/lib/local-storage.js index 4c46686a9..49289a630 100644 --- a/src/lib/local-storage.js +++ b/src/lib/local-storage.js @@ -426,6 +426,7 @@ class LocalStorage implements IStorage { writeStream.on('error', (err) => { if (err.code === fileExist) { uploadStream.emit('error', ErrorCode.getConflict()); + uploadStream.abort(); } else if (err.code === noSuchFile) { // check if package exists to throw an appropriate message this.getPackageMetadata(name, function(_err, res) { diff --git a/src/webui/modules/home/index.js b/src/webui/modules/home/index.js index 8a916fa10..edc86850a 100644 --- a/src/webui/modules/home/index.js +++ b/src/webui/modules/home/index.js @@ -89,7 +89,7 @@ export default class Home extends React.Component { handleSearchInput(e) { this.setState({ - query: e.target.value + query: e.target.value.trim() }); } diff --git a/test/unit/api/local-storage.spec.js b/test/unit/api/local-storage.spec.js index e95132bc3..686bb17c8 100644 --- a/test/unit/api/local-storage.spec.js +++ b/test/unit/api/local-storage.spec.js @@ -11,7 +11,6 @@ import {readFile} from '../../functional/lib/test.utils'; import {generatePackageTemplate} from '../../../src/lib/storage-utils'; import {generateNewVersion} from '../../lib/utils-test'; - const readMetadata = (fileName: string = 'metadata') => readFile(`../../unit/partials/${fileName}`); import type {Config, MergeTags} from '@verdaccio/types'; @@ -339,17 +338,18 @@ describe('LocalStorage', () => { test('should fails on add a duplicated new tarball ', (done) => { const tarballData = JSON.parse(readMetadata('addTarball')); const stream = storage.addTarball(pkgName, tarballName); + let spy; + // $FlowFixMe + spy = jest.spyOn(stream && stream._readableState && stream._readableState.pipes, 'abort'); stream.on('error', (err) => { expect(err).not.toBeNull(); expect(err.statusCode).toEqual(HTTP_STATUS.CONFLICT); - expect(err.message).toMatch(/this package is already present/); + expect(err.message).toMatch(/this package is already present/); + }); + stream.on('success', function(){ + expect(spy).toHaveBeenCalled(); done(); }); - - stream.on('success', function() { - done(); - }); - stream.end(new Buffer(tarballData.data, 'base64')); stream.done(); }); @@ -397,26 +397,25 @@ describe('LocalStorage', () => { stream.done(); }); - describe('LocalStorage::removeTarball', () => { + }); + describe('LocalStorage::removeTarball', () => { - test('should remove a tarball', (done) => { - storage.removeTarball(pkgName, tarballName2, 'rev', (err, pkg) => { - expect(err).toBeNull(); - expect(pkg).toBeUndefined(); - done(); - }); - }); - - test('should remove a tarball that does not exist', (done) => { - storage.removeTarball(pkgName, tarballName2, 'rev', (err) => { - expect(err).not.toBeNull(); - expect(err.statusCode).toEqual(HTTP_STATUS.NOT_FOUND); - expect(err.message).toMatch(/no such file available/); - done(); - }); + test('should remove a tarball', (done) => { + storage.removeTarball(pkgName, tarballName2, 'rev', (err, pkg) => { + expect(err).toBeNull(); + expect(pkg).toBeUndefined(); + done(); }); }); + test('should remove a tarball that does not exist', (done) => { + storage.removeTarball(pkgName, tarballName2, 'rev', (err) => { + expect(err).not.toBeNull(); + expect(err.statusCode).toEqual(HTTP_STATUS.NOT_FOUND); + expect(err.message).toMatch(/no such file available/); + done(); + }); + }); }); describe('LocalStorage::getTarball', () => { diff --git a/test/unit/webui/modules/home.spec.js b/test/unit/webui/modules/home.spec.js new file mode 100644 index 000000000..2f28133bc --- /dev/null +++ b/test/unit/webui/modules/home.spec.js @@ -0,0 +1,39 @@ +/** + * Home Component + */ + +import React from 'react'; +import { mount } from 'enzyme'; +import Home from '../../../../src/webui/modules/home/index'; + +describe(' Component', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(); + }); + + it('handleSearchInput - should match the search query', () => { + const { handleSearchInput } = wrapper.instance(); + const result = 'test query string one'; + const input = { + target: { + value: result + } + }; + handleSearchInput(input); + expect(wrapper.state('query')).toBe(result); + }); + + it('handleSearchInput - should match the trimmed search query', () => { + const { handleSearchInput } = wrapper.instance(); + const result = ' '; + const input = { + target: { + value: result + } + }; + handleSearchInput(input); + expect(wrapper.state('query')).toBe(result.trim()); + }); +});