Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #3419

Closed
wants to merge 46 commits into from
Closed

test #3419

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7581d15
Updating libs and adding basic flux
stolksdorf Dec 26, 2016
47396e5
Added smart componenets, page line number highlighting
stolksdorf Dec 26, 2016
95aa803
Trying to fix prod builds breaking
stolksdorf Dec 27, 2016
8abf6ab
Updating pico-flux and vitreum to latest
stolksdorf Dec 27, 2016
f4cf288
newPage is now working, working on editpage
stolksdorf Dec 27, 2016
f75f60a
Edit page finally converted over
stolksdorf Dec 27, 2016
41303e6
'Share
stolksdorf Dec 27, 2016
924b398
Added new navitems
stolksdorf Dec 28, 2016
1173af5
'Created
stolksdorf Dec 30, 2016
95c09ba
moved welcome message and adding in egads errors
stolksdorf Jan 1, 2017
5ba3f98
Finally testing, things should be working a bit better now
stolksdorf Jan 1, 2017
10f4759
adding in some api tests
stolksdorf Jan 2, 2017
68ecf74
Stubbing out test files
stolksdorf Jan 1, 2017
25e0a16
whatever
stolksdorf Jan 1, 2017
a0bc4fd
moving the db setup out
stolksdorf Jan 1, 2017
537a75b
Triyng to setup api tests
stolksdorf Jan 2, 2017
3dc4c13
Something is up
stolksdorf Jan 6, 2017
5820564
added nodemon'd test npm task
stolksdorf Jan 6, 2017
66ca09b
Both types of tests are now working
stolksdorf Jan 6, 2017
174c297
Split off app into own file
stolksdorf Jan 6, 2017
7b38bcc
config file for tests
stolksdorf Jan 6, 2017
987363e
Fixing the pathing to the build folder
stolksdorf Jan 6, 2017
ca40ec5
Added in full test coverage of current spec
stolksdorf Jan 6, 2017
a26c4e2
Cleaned up the admin routes
stolksdorf Jan 7, 2017
d77fa0a
Backend of local login working
stolksdorf Jan 7, 2017
0d0f0d8
Adding in env configs and aextra protection on dev routes
stolksdorf Jan 7, 2017
baaa82e
Added in a logout to the user page
stolksdorf Jan 9, 2017
07f249b
Local login now working great
stolksdorf Jan 9, 2017
894e345
Fixed bug where new page loaded null brews sometimes
stolksdorf Jan 12, 2017
1aa79b3
Remove chrome warnings from after rebase
stolksdorf Jan 22, 2017
37de888
Creating a brand new admin page
stolksdorf Jan 10, 2017
cd2eb5f
Adding in lookup route
stolksdorf Jan 10, 2017
e77532a
Added tests for admin routes, lookup is working
stolksdorf Jan 10, 2017
0878439
Fixed issue with arrays not being saved
stolksdorf Jan 10, 2017
728277f
Removing invalid brews is working
stolksdorf Jan 10, 2017
dfcb04f
Setting up search tests
stolksdorf Jan 11, 2017
a405c7c
Stubbing out tests for searching
stolksdorf Jan 12, 2017
efee8ff
Basic search is working
stolksdorf Jan 23, 2017
2f82d38
Adding a new script from populating the DB with a bunch of random brews
stolksdorf Jan 27, 2017
8e58e5a
MOved the brews search to its own file, writing out more tests
stolksdorf Jan 27, 2017
8018442
Upgrading the brew generation for testing
stolksdorf Jan 27, 2017
a826aaf
created a brew generator and chai plugin for easier testing
stolksdorf Jan 27, 2017
26bcb33
Fixing edge cases in the search tests
stolksdorf Jan 28, 2017
75111ac
All tests should be done, phew
stolksdorf Jan 28, 2017
7e6f42f
Merge branch 'search' into newAdmin
stolksdorf Jan 28, 2017
6030134
New brew search finished on admin page
stolksdorf Jan 28, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .babelrc

This file was deleted.

3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ All brews made previous to the release of v3.0.0 will still render normally.
- Fixed realtime renderer not functioning if loaded with malformed html on load (thanks u/RattiganIV re:247)
- Removed a lot of unused files in shared
- vitreum v4 now lets me use codemirror as a pure node dependacy

- Moved the brew editor and renderer into shared, and made a new hybrid component for them
- Added a line highlighter to lines with new pages


### Saturday, 03/12/2016 - v2.6.0
Expand Down
53 changes: 28 additions & 25 deletions client/admin/admin.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
const React = require('react');
const _ = require('lodash');

var HomebrewAdmin = require('./homebrewAdmin/homebrewAdmin.jsx');
const Nav = require('naturalcrit/nav/nav.jsx');

var Admin = React.createClass({
const BrewLookup = require('./brewLookup/brewLookup.jsx');
const AdminSearch = require('./adminSearch/adminSearch.jsx');
const InvalidBrew = require('./invalidBrew/invalidBrew.jsx');

const Admin = React.createClass({
getDefaultProps: function() {
return {
url : "",
admin_key : "",
homebrews : [],
admin_key : '',
};
},

render : function(){
var self = this;
return(
<div className='admin'>

<header>
<div className='container'>
<i className='fa fa-rocket' />
naturalcrit admin
</div>
</header>

<div className='container'>
renderNavbar : function(){
return <Nav.base>
<Nav.section>
<Nav.item icon='fa-magic' className='homebreweryLogo'>
Homebrewery Admin
</Nav.item>
</Nav.section>
</Nav.base>
},

<HomebrewAdmin homebrews={this.props.homebrews} admin_key={this.props.admin_key} />
</div>
render : function(){
return <div className='admin'>
{this.renderNavbar()}
<main className='content'>
<BrewLookup adminKey={this.props.admin_key} />
<AdminSearch adminKey={this.props.admin_key} />

<div className='dangerZone'>Danger Zone</div>

</div>
);
<InvalidBrew adminKey={this.props.admin_key} />
</main>
</div>
}
});

Expand Down
68 changes: 41 additions & 27 deletions client/admin/admin.less
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
@import 'naturalcrit/styles/reset.less';
@import 'naturalcrit/styles/elements.less';
@import 'naturalcrit/styles/animations.less';
@import 'naturalcrit/styles/colors.less';
@import 'naturalcrit/styles/tooltip.less';

@import 'font-awesome/css/font-awesome.css';

html,body, #reactContainer, .naturalCrit{
@import 'naturalcrit/styles/core.less';
html,body, #reactRoot{
min-height : 100%;
}

@sidebarWidth : 250px;

body{
background-color : #eee;
height : 100%;
margin : 0;
padding : 0;
background-color : #ddd;
font-family : 'Open Sans', sans-serif;
color : #4b5055;
font-weight : 100;
color : #4b5055;
text-rendering : optimizeLegibility;
margin : 0;
padding : 0;
height : 100%;
}

.admin{

header{
.admin {
nav {
background-color : @red;
font-size: 2em;
padding : 20px 0px;
color : white;
margin-bottom: 30px;
i{
margin-right: 30px;
.navItem{
background-color : @red;
}
.homebreweryLogo{
font-family : CodeBold;
font-size : 12px;
color : white;
div{
margin-top : 2px;
margin-bottom : -2px;
}
}
}
h1{
margin-bottom : 10px;
font-size : 2em;
font-weight : 800;
border-bottom : 1px solid #ddd;
}
main.content{
width : 1000px;
margin : 0 auto;
padding : 50px 20px;
background-color : white;
.dangerZone{
margin : 30px 0px;
padding : 10px 20px;
background : repeating-linear-gradient(45deg, @yellow, @yellow 10px, darken(#333, 10%) 10px, darken(#333, 10%) 20px);
font-size : 1em;
font-weight : 800;
color : white;
text-transform : uppercase;
}
}

}
86 changes: 86 additions & 0 deletions client/admin/adminSearch/adminSearch.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

const React = require('react');
const _ = require('lodash');
const cx = require('classnames');
const request = require('superagent');

const BrewTable = require('../brewTable/brewTable.jsx');

const LIMIT = 10;

const AdminSearch = React.createClass({
getDefaultProps: function() {
return {
adminKey : '',
};
},
getInitialState: function() {
return {
totalBrews : 1,
brews: [],

searching : false,
error : null,

page : 1,
searchTerms : ''
};
},

handleSearch : function(e){
this.setState({
searchTerms : e.target.value
});
},
handlePage : function(e){
this.setState({
page : e.target.value
});
},

search : function(){
this.setState({ searching : true, error : null });

request.get(`/api/brew`)
.query({
terms : this.state.searchTerms,
limit : LIMIT,
page : this.state.page - 1
})
.set('x-homebrew-admin', this.props.adminKey)
.end((err, res) => {
if(err){
this.setState({
searching : false,
error : err && err.toString()
});
}else{
this.setState({
brews : res.body.brews,
totalBrews : res.body.total
});
}
});
},

render: function(){
return <div className='adminSearch'>
<h1>Admin Search</h1>
<div className='controls'>
<input className='search' type='text' value={this.state.searchTerms} onChange={this.handleSearch} />

<button onClick={this.search}> <i className='fa fa-search' /> search </button>


<div className='page'>
page:
<input type='text' value={this.state.page} onChange={this.handlePage} />
/ {Math.ceil(this.state.totalBrews / LIMIT)}
</div>
</div>
<BrewTable brews={this.state.brews} />
</div>
}
});

module.exports = AdminSearch;
17 changes: 17 additions & 0 deletions client/admin/adminSearch/adminSearch.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

.adminSearch{
.controls{
margin-bottom : 20px;
input.search{
height : 33px;
padding : 10px;
}
.page {
float : right;
font-weight : 800;
input{
width : 20px;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ const _ = require('lodash');
const cx = require('classnames');

const request = require('superagent');
const Moment = require('moment');

const BrewTable = require('../brewTable/brewTable.jsx');

const BrewLookup = React.createClass({
getDefaultProps: function() {
Expand All @@ -16,7 +15,8 @@ const BrewLookup = React.createClass({
return {
query:'',
resultBrew : null,
searching : false
searching : false,
error : null
};
},

Expand All @@ -26,13 +26,14 @@ const BrewLookup = React.createClass({
})
},
lookup : function(){
this.setState({ searching : true });
this.setState({ searching : true, error : null });

request.get(`/admin/lookup/${this.state.query}`)
.query({ admin_key : this.props.adminKey })
.set('x-homebrew-admin', this.props.adminKey)
.end((err, res) => {
this.setState({
searching : false,
error : err && err.toString(),
resultBrew : (err ? null : res.body)
});
})
Expand All @@ -42,14 +43,31 @@ const BrewLookup = React.createClass({
if(this.state.searching) return <div className='searching'><i className='fa fa-spin fa-spinner' /></div>;
if(!this.state.resultBrew) return <div className='noBrew'>No brew found.</div>;

return <BrewTable brews={[this.state.resultBrew ]} />

/*
const brew = this.state.resultBrew;
return <div className='brewRow'>
<div>{brew.title}</div>
<div>{brew.authors.join(', ')}</div>
<div><a href={'/edit/' + brew.editId} target='_blank'>/edit/{brew.editId}</a></div>
<div><a href={'/share/' + brew.shareId} target='_blank'>/share/{brew.shareId}</a></div>
<div><a href={'/edit/' + brew.editId} target='_blank'>{brew.editId}</a></div>
<div><a href={'/share/' + brew.shareId} target='_blank'>{brew.shareId}</a></div>
<div>{Moment(brew.updatedAt).fromNow()}</div>
<div>{brew.views}</div>
<div>
<div className='deleteButton'>
<i className='fa fa-trash' />
</div>
</div>
</div>
*/
},

renderError : function(){
if(!this.state.error) return;

return <div className='error'>
{this.state.error}
</div>
},

Expand All @@ -60,6 +78,7 @@ const BrewLookup = React.createClass({
<button onClick={this.lookup}><i className='fa fa-search'/></button>

{this.renderFoundBrew()}
{this.renderError()}
</div>
}
});
Expand Down
13 changes: 13 additions & 0 deletions client/admin/brewLookup/brewLookup.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

.brewLookup{
height : 200px;
input{
height : 33px;
margin-bottom : 20px;
padding : 0px 10px;
}
.error{
font-weight : 800;
color : @red;
}
}
Loading
Loading