Skip to content

task demo, terms for joining community #531

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

Merged
merged 19 commits into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .exchange-rates.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1507798800,"base":"USD","rates":{"AED":3.672896,"AFN":67.974,"ALL":113,"AMD":478.925,"ANG":1.77865,"AOA":165.9215,"ARS":17.4045,"AUD":1.277432,"AWG":1.790501,"AZN":1.69,"BAM":1.648856,"BBD":2,"BDT":82.288,"BGN":1.64876,"BHD":0.377213,"BIF":1746.8,"BMD":1,"BND":1.355356,"BOB":6.885986,"BRL":3.171391,"BSD":1,"BTC":0.000195885465,"BTN":65.230321,"BWP":10.283758,"BYN":1.961895,"BZD":2.008642,"CAD":1.245347,"CDF":1562.881563,"CHF":0.973707,"CLF":0.02324,"CLP":626.965409,"CNH":6.583036,"CNY":6.585567,"COP":2953.31,"CRC":572.515,"CUC":1,"CUP":25.5,"CVE":93.375,"CZK":21.81801,"DJF":178.97,"DKK":6.275117,"DOP":47.278488,"DZD":113.454,"EGP":17.622,"ERN":15.333158,"ETB":23.45091,"EUR":0.842994,"FJD":2.051354,"FKP":0.75579,"GBP":0.75579,"GEL":2.478108,"GGP":0.75579,"GHS":4.395,"GIP":0.75579,"GMD":46.275,"GNF":8906.35,"GTQ":7.319909,"GYD":207.06,"HKD":7.80686,"HNL":23.331869,"HRK":6.330489,"HTG":63.080843,"HUF":260.717,"IDR":13502.802788,"ILS":3.4853,"IMP":0.75579,"INR":65.075,"IQD":1162.95,"IRR":33654.5,"ISK":104.74,"JEP":0.75579,"JMD":127.971482,"JOD":0.709001,"JPY":112.27,"KES":103.25,"KGS":68.399709,"KHR":4025.7,"KMF":415.25,"KPW":900,"KRW":1132.55,"KWD":0.301803,"KYD":0.830511,"KZT":333.96,"LAK":8315,"LBP":1502.9,"LKR":152.952819,"LRD":118.010556,"LSL":13.517836,"LYD":1.364414,"MAD":9.3903,"MDL":17.424728,"MGA":3046.65,"MKD":51.91,"MMK":1359.15,"MNT":2457.447826,"MOP":8.011891,"MRO":363.721657,"MUR":34.0005,"MVR":15.400126,"MWK":724.675734,"MXN":18.702241,"MYR":4.2195,"MZN":60.994761,"NAD":13.517351,"NGN":358.75,"NIO":30.207843,"NOK":7.9106,"NPR":103.905516,"NZD":1.404011,"OMR":0.385005,"PAB":1,"PEN":3.25875,"PGK":3.183202,"PHP":51.39,"PKR":104.782432,"PLN":3.600585,"PYG":5620.55,"QAR":3.729989,"RON":3.868701,"RSD":100.609575,"RUB":57.665,"RWF":830.479566,"SAR":3.750196,"SBD":7.810521,"SCR":13.541191,"SDG":6.653117,"SEK":8.092327,"SGD":1.353802,"SHP":0.75579,"SLL":7635.994028,"SOS":576.39,"SRD":7.448,"SSP":129.0194,"STD":20701.93181,"SVC":8.719665,"SYP":514.99499,"SZL":13.528287,"THB":33.105,"TJS":8.764406,"TMT":3.499986,"TND":2.463097,"TOP":2.247061,"TRY":3.637455,"TTD":6.70213,"TWD":30.197,"TZS":2245,"UAH":26.423235,"UGX":3617.4,"USD":1,"UYU":29.175341,"UZS":8032.8,"VEF":10.146563,"VND":22709.292617,"VUV":105.278798,"WST":2.531559,"XAF":552.967845,"XAG":0.05802155,"XAU":0.00077159,"XCD":2.70255,"XDR":0.707444,"XOF":552.967845,"XPD":0.0010379,"XPF":100.595948,"XPT":0.00106726,"YER":250.306642,"ZAR":13.460823,"ZMW":9.591214,"ZWL":322.355011}}
{"disclaimer":"Usage subject to terms: https://openexchangerates.org/terms","license":"https://openexchangerates.org/license","timestamp":1508414400,"base":"USD","rates":{"AED":3.672973,"AFN":68.15,"ALL":112.92,"AMD":481.728804,"ANG":1.779789,"AOA":165.9225,"ARS":17.3379,"AUD":1.270644,"AWG":1.790246,"AZN":1.6985,"BAM":1.653896,"BBD":2,"BDT":82.537473,"BGN":1.653246,"BHD":0.377203,"BIF":1750,"BMD":1,"BND":1.357043,"BOB":6.909062,"BRL":3.167437,"BSD":1,"BTC":0.000175811708,"BTN":65.045224,"BWP":10.307664,"BYN":1.957114,"BZD":2.009704,"CAD":1.246334,"CDF":1570,"CHF":0.975172,"CLF":0.023185,"CLP":624.8,"CNH":6.619015,"CNY":6.6223,"COP":2923.75,"CRC":569.998642,"CUC":1,"CUP":25.5,"CVE":93.9,"CZK":21.7448,"DJF":178.77,"DKK":6.290249,"DOP":47.86869,"DZD":114.25,"EGP":17.6474,"ERN":15.191062,"ETB":26.984211,"EUR":0.844987,"FJD":2.046698,"FKP":0.758867,"GBP":0.758867,"GEL":2.482304,"GGP":0.758867,"GHS":4.405,"GIP":0.758867,"GMD":47.45,"GNF":9001,"GTQ":7.351488,"GYD":207.795851,"HKD":7.80255,"HNL":23.592243,"HRK":6.3449,"HTG":63.506926,"HUF":260.652005,"IDR":13513.746714,"ILS":3.496997,"IMP":0.758867,"INR":65.015,"IQD":1166.85,"IRR":34243.946723,"ISK":105.21,"JEP":0.758867,"JMD":127.415141,"JOD":0.7086,"JPY":112.49516667,"KES":103.585,"KGS":68.579481,"KHR":4035.5,"KMF":417.634177,"KPW":900,"KRW":1131.75,"KWD":0.302094,"KYD":0.833193,"KZT":334.519063,"LAK":8323.9,"LBP":1515.649713,"LKR":153.548466,"LRD":118.354791,"LSL":13.535513,"LYD":1.369746,"MAD":9.404986,"MDL":17.329616,"MGA":3082.1,"MKD":52.033759,"MMK":1367.3,"MNT":2454.299176,"MOP":8.035619,"MRO":355.495295,"MUR":33.95,"MVR":15.400167,"MWK":725.535,"MXN":18.804893,"MYR":4.222083,"MZN":61.115,"NAD":13.535527,"NGN":359.805566,"NIO":30.746369,"NOK":7.9722,"NPR":104.009834,"NZD":1.424587,"OMR":0.385015,"PAB":1,"PEN":3.236683,"PGK":3.201466,"PHP":51.406,"PKR":105.230492,"PLN":3.585395,"PYG":5639.3,"QAR":3.672571,"RON":3.883094,"RSD":100.656494,"RUB":57.54295,"RWF":854.182838,"SAR":3.7512,"SBD":7.777811,"SCR":13.768427,"SDG":6.675868,"SEK":8.160019,"SGD":1.35689,"SHP":0.758867,"SLL":7643.328121,"SOS":578.460064,"SRD":7.448,"SSP":130.2183,"STD":20769.150676,"SVC":8.748749,"SYP":514.98999,"SZL":13.533002,"THB":33.124,"TJS":8.799001,"TMT":3.499986,"TND":2.458496,"TOP":2.224732,"TRY":3.660214,"TTD":6.729148,"TWD":30.242233,"TZS":2244.6,"UAH":26.506511,"UGX":3656.55,"USD":1,"UYU":29.121233,"UZS":8057.7,"VEF":9.990025,"VND":22722.253308,"VUV":105.316668,"WST":2.533273,"XAF":554.275221,"XAG":0.05869414,"XAU":0.00077711,"XCD":2.70255,"XDR":0.70955,"XOF":554.275221,"XPD":0.0010424,"XPF":100.833786,"XPT":0.00108021,"YER":250.281642,"ZAR":13.539342,"ZMW":9.748924,"ZWL":322.355011}}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
New version of Topcoder Community website.

### Knowledgebase
- [Challenge Terms - Mocking for Testing and Development](docs/challenge-terms.md)
- [Mocking Terms for Testing and Development](docs/mocking-terms.md)
- [Code Splitting](docs/code-splitting.md)
- [Coding Standards](docs/coding-standards.md)
- [How to Add a New Topcoder Community?](docs/how-to-add-a-new-topcoder-community.md)
Expand Down
16 changes: 16 additions & 0 deletions __tests__/shared/components/__snapshots__/Content.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,22 @@ exports[`Matches shallow shapshot 1`] = `
</Link>
</li>
</ul>
<h3>
Sandbox
</h3>
<p>
The right place to put any experimental and proof-of-concept stuff.
</p>
<ul>
<li>
<Link
replace={false}
to="/sandbox/payments"
>
Payments PoC
</Link>
</li>
</ul>
<h3>
Misc Examples
</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ exports[`Matches shallow shapshot 1`] = `
ignoreAccents={true}
ignoreCase={true}
inputProps={Object {}}
instanceId="id"
isLoading={false}
joinValues={false}
labelKey="label"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exports[`Match shadow snapshot 1`] = `
title="Community 2"
/>
<Connect(CommunityStatsContainer) />
<Connect(JoinCommunity) />
<Connect(JoinCommunityContainer) />
<ThemedSection
anchor={null}
composeAdhocTheme="deeply"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports[`Match shadow snapshot 1`] = `
}
}
/>
<Connect(JoinCommunity) />
<Connect(JoinCommunityContainer) />
<ThemedSection
anchor="why-topcoder-taskforce"
composeAdhocTheme="deeply"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { mount } from 'enzyme';
import React from 'react';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import tActions from 'actions/tc-communities';
import JoinCommunity from 'components/tc-communities/JoinCommunity';
Expand All @@ -25,6 +26,7 @@ describe('full render connnected component and dispatch actions', () => {
data: {
challengeGroupId: '1',
communityName: 'name',
communityId: '1',
},
},
hideJoinButton: true,
Expand All @@ -44,6 +46,9 @@ describe('full render connnected component and dispatch actions', () => {
groups: {
groups: {},
},
terms: {
terms: [],
},
};

const mockStore = configureStore();
Expand All @@ -56,7 +61,7 @@ describe('full render connnected component and dispatch actions', () => {
json: () => ({ result: { status: 200, metadata: {}, content: [] } }),
});
store = mockStore(initialState);
instance = mount(<ConnectedJoinCommunity store={store} />);
instance = mount(<Provider store={store}><ConnectedJoinCommunity /></Provider>);
joinCommunity = instance.find(JoinCommunity);
store.clearActions();
});
Expand All @@ -74,7 +79,7 @@ describe('full render connnected component and dispatch actions', () => {
},
};
store = mockStore(newStore);
instance = mount(<ConnectedJoinCommunity store={store} />);
instance = mount(<Provider store={store}><ConnectedJoinCommunity /></Provider>);
});

test('hideJoinButton', () => {
Expand Down
2 changes: 1 addition & 1 deletion config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

{
"LOG_ENTRIES_TOKEN": "LOG_ENTRIES_TOKEN",
"MOCK_CHALLENGE_TERMS_SERVICE": "MOCK_CHALLENGE_TERMS_SERVICE"
"MOCK_TERMS_SERVICE": "MOCK_TERMS_SERVICE"

}
6 changes: 3 additions & 3 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
* the setup. To override it use LOG_ENTRIES_TOKEN environment variable. */
"LOG_ENTRIES_TOKEN": "816f5574-0d4a-49f9-ab3b-00d791f7c1f7",

/* When set to true, challenge terms service is short-cut so that each time
* a user goes to challenge details page, it tells that none of challenge
/* When set to true, terms service is short-cut so that each time
* a user goes to challenge details page or community page, it tells that none of
* terms is agrees, and takes care that user is taken through the terms
* agreement flow. */
"MOCK_CHALLENGE_TERMS_SERVICE": false,
"MOCK_TERMS_SERVICE": false,

/* Configuration related to https://openexchangerates.org. This is the
* service which provides currency exchange rates. */
Expand Down
2 changes: 1 addition & 1 deletion config/webpack/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
],
loader: 'file-loader',
options: {
outputPath: '/fonts/',
outputPath: '/community-app-fonts/',
publicPath: '',
},
}, {
Expand Down
15 changes: 0 additions & 15 deletions docs/challenge-terms.md

This file was deleted.

5 changes: 4 additions & 1 deletion docs/how-to-add-a-new-topcoder-community.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ To add a new community with the name **demo**, we should follow the following pr
],
"newsFeed": "http://www.topcoder.com/feed",
"description": "A berief description which will be displayed in dashboard",
"image": "1.jpg"
"image": "1.jpg",
"terms": [21153]
}
```
Its fields serve the following purposes:
Expand Down Expand Up @@ -116,6 +117,8 @@ To add a new community with the name **demo**, we should follow the following pr
The `<NewsSection />` component does not render anything, if its `news` property is *null* or an empty array, thus it can be kept inside the page code even when there is no news feed configured for a community.
- `description`: A berief description which will be displayed in dashboard.
- `image`: A image that located at `/assets/images/tc-communities/background` will be displayed in dashboard
- `terms` - *Array of Numbers* - Optional. If provided, it should hold an array of Topcoder term of use IDs; agreement to all these terms will be necessary to self-join the community. Beside this, it has no other effects at the moment.

3. Custom pages of the community (anything beside `Challenges` and `Leaderboard`) should be created inside `/src/shared/components/tc-communities/communities/demo`. At the moment all communities have two custom pages: `Home` and `Learn`, you may just copy these from an existing community, and then customize to your particular needs.

4. The routing inside community, and code splitting of the related code, should be set up inside `/src/shared/routes/Communities`:
Expand Down
15 changes: 15 additions & 0 deletions docs/mocking-terms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Mocking Terms for Testing and Development

Development and testing related to challenges and communities terms is not straightforward because in dev. environment related functionality does not work perfect, and in prod. it is not possible to reset agreement for a terms without admin privileges. Thus, we have a mock of terms service that helps to nail development, and also to write related unit-tests with Jest.

### Development

To enable terms mocking for development, run the app with `MOCK_TERMS_SERVICE` environment variable set to `true`. E.g., on Linux, in dev. mode against production backend, you execute `$ MOCK_TERMS_SERVICE=true NODE_ENV=production PORT=80 npm run dev`. Against development backend it would be simply `$ MOCK_TERMS_SERVICE=true npm run dev`.

With this option enabled, each challenge and community you access will be protected by two terms if user is not authenticated: a simple Topcoder ones + mock DocuSign NDA (really simple mock, renders a small HTML page, that shows buttons that, when pressed, imitate DocuSign callbacks in the cases of terms agreement or rejection). If a user is authenticated then each challenge and community will be protected by three terms one of which is agreed. By default, two terms won't be agreed initially. Agreeing with them won't be stored in the service mock though after all terms agreed `checkStatusDone` action will return all terms agreed. If you reload a page, you'll see that both terms are pending to be agreed with again.

The code of the mock module, and mock data for it, can be found in the `/src/shared/services/__mocks__` folder. You can modify them for your development and testing need, but, please, don't commit these changes to the repo, as we are planning to write unit-tests using this mock (if there is a really good reason to update the mock, be sure to check that related unit-tests are updated appropriately as well).

### Unit-Testing

Using this terms mock for unit-testing with Jest is straightforward: you add to an unit-test module `jest.mock('services/terms')`, and the module will be mocked using the same logic as for development.
Loading