diff --git a/.env.development b/.env.development
new file mode 100644
index 00000000..cff1ca7b
--- /dev/null
+++ b/.env.development
@@ -0,0 +1,2 @@
+NODE_ENV=development
+REACT_APP_ENV=development
diff --git a/.env.test b/.env.test
new file mode 100644
index 00000000..d8e17a78
--- /dev/null
+++ b/.env.test
@@ -0,0 +1,3 @@
+NODE_ENV=test
+REACT_APP_ENV=test
+REACT_APP_SHARETRIBE_MARKETPLACE_CURRENCY=USD
diff --git a/package.json b/package.json
index e68e3107..644ffd30 100644
--- a/package.json
+++ b/package.json
@@ -55,12 +55,12 @@
},
"scripts": {
"clean": "rm -rf build/*",
- "dev": "REACT_APP_ENV=development sharetribe-scripts start",
+ "dev": "sharetribe-scripts start",
"build": "sharetribe-scripts build",
"format": "prettier --write '**/*.{js,css}'",
"format-ci": "prettier --list-different '**/*.{js,css}'",
- "test": "export REACT_APP_SHARETRIBE_MARKETPLACE_CURRENCY=USD&&sharetribe-scripts test --env=jsdom",
- "test-ci": "export REACT_APP_SHARETRIBE_MARKETPLACE_CURRENCY=USD&&sharetribe-scripts test --env=jsdom --runInBand",
+ "test": "sharetribe-scripts test --env=jsdom",
+ "test-ci": "sharetribe-scripts test --env=jsdom --runInBand",
"eject": "sharetribe-scripts eject",
"start": "node server/index.js",
"dev-server": "export REACT_APP_ENV=development REACT_APP_CANONICAL_ROOT_URL=http://localhost:4000&&yarn run build&&nodemon --watch server server/index.js",
diff --git a/src/app.js b/src/app.js
index 277ac632..24d81e86 100644
--- a/src/app.js
+++ b/src/app.js
@@ -4,6 +4,7 @@ import ReactDOMServer from 'react-dom/server';
import Helmet from 'react-helmet';
import { BrowserRouter, StaticRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
+import { mapValues } from 'lodash';
import moment from 'moment';
import { IntlProvider, addLocaleData } from 'react-intl';
import configureStore from './store';
@@ -18,7 +19,19 @@ import config from './config';
import localeData from 'react-intl/locale-data/en';
import messages from './translations/en.json';
+const isTestEnv = process.env.NODE_ENV === 'test';
+
+// Locale should not affect the tests. We ensure this by providing
+// messages with the key as the value of each message.
+const testMessages = mapValues(messages, (val, key) => key);
+const localeMessages = isTestEnv ? testMessages : messages;
+
const setupLocale = () => {
+ if (isTestEnv) {
+ // Don't change the locale in tests
+ return;
+ }
+
// Add the translation messages
addLocaleData([...localeData]);
@@ -31,7 +44,7 @@ export const ClientApp = props => {
const { store } = props;
setupLocale();
return (
-
+
@@ -49,7 +62,7 @@ export const ServerApp = props => {
const { url, context, store } = props;
setupLocale();
return (
-
+
diff --git a/src/app.test.js b/src/app.test.js
index 827e72f1..728d5ca8 100644
--- a/src/app.test.js
+++ b/src/app.test.js
@@ -34,16 +34,16 @@ describe('Application', () => {
it('server renders pages that do not require authentication', () => {
const urlTitles = {
- '/': 'Book saunas everywhere',
- '/s': 'Search results for map search',
- '/l/listing-title-slug/1234': 'Loading listing…',
- '/l/1234': 'Loading listing…',
- '/u/1234': ' | Saunatime',
- '/login': 'Log in',
- '/signup': 'Sign up',
- '/recover-password': 'Request a new password',
- '/this-url-should-not-be-found': 'Page not found',
- '/reset-password?t=token&e=email': 'Reset password',
+ '/': 'LandingPage.schemaTitle',
+ '/s': 'SearchPage.schemaTitle',
+ '/l/listing-title-slug/1234': 'ListingPage.loadingListingTitle',
+ '/l/1234': 'ListingPage.loadingListingTitle',
+ '/u/1234': 'ProfilePage.schemaTitle',
+ '/login': 'AuthenticationPage.schemaTitleLogin',
+ '/signup': 'AuthenticationPage.schemaTitleSignup',
+ '/recover-password': 'PasswordRecoveryPage.title',
+ '/this-url-should-not-be-found': 'NotFoundPage.title',
+ '/reset-password?t=token&e=email': 'PasswordResetPage.title',
};
forEach(urlTitles, (title, url) => {
const context = {};
diff --git a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap
index 5ad0b41e..2af3179a 100644
--- a/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap
+++ b/src/components/BookingBreakdown/__snapshots__/BookingBreakdown.test.js.snap
@@ -11,7 +11,7 @@ exports[`BookingBreakdown customer transaction data matches snapshot 1`] = `
className={undefined}
>
- Price per night
+ BookingBreakdown.pricePerNight
-
- 2017-04-14
-
- –
-
- 2017-04-16
-
+ BookingBreakdown.bookingPeriod
@@ -62,7 +52,7 @@ exports[`BookingBreakdown customer transaction data matches snapshot 1`] = `
className={undefined}
>
- Total price
+ BookingBreakdown.total
- Price per night
+ BookingBreakdown.pricePerNight
-
- 2017-04-14
-
- –
-
- 2017-04-16
-
+ BookingBreakdown.bookingPeriod
@@ -136,7 +116,7 @@ exports[`BookingBreakdown pretransaction data matches snapshot 1`] = `
className={undefined}
>
- Total price
+ BookingBreakdown.total
- Price per night
+ BookingBreakdown.pricePerNight
-
- 2017-04-14
-
- –
-
- 2017-04-16
-
+ BookingBreakdown.bookingPeriod
@@ -207,7 +177,7 @@ exports[`BookingBreakdown provider canceled transaction data matches snapshot 1`
className={undefined}
>
- Subtotal
+ BookingBreakdown.subTotal
- Refund
+ BookingBreakdown.refund
- Total price
+ BookingBreakdown.providerTotalCanceled
- Price per night
+ BookingBreakdown.pricePerNight
-
- 2017-04-14
-
- –
-
- 2017-04-16
-
+ BookingBreakdown.bookingPeriod
@@ -313,7 +273,7 @@ exports[`BookingBreakdown provider transaction data matches snapshot 1`] = `
className={undefined}
>
- Subtotal
+ BookingBreakdown.subTotal
- Saunatime fee
+ BookingBreakdown.commission
- You'll make
+ BookingBreakdown.providerTotalDefault
diff --git a/src/components/DateRangeInputField/__snapshots__/DateRangeInputField.test.js.snap b/src/components/DateRangeInputField/__snapshots__/DateRangeInputField.test.js.snap
index 8f76739a..a6ab501f 100644
--- a/src/components/DateRangeInputField/__snapshots__/DateRangeInputField.test.js.snap
+++ b/src/components/DateRangeInputField/__snapshots__/DateRangeInputField.test.js.snap
@@ -35,7 +35,7 @@ exports[`DateRangeInput matches snapshot 1`] = `
className="screen-reader-only"
id="DateInput__screen-reader-message-bookingStartDate"
>
- Date input
+ DateRangeInputField.screenReaderInputMessage
- Date input
+ DateRangeInputField.screenReaderInputMessage
- Book saunas everywhere.
+ SectionHero.title
- The largest online community to rent saunas in Finland.
+ SectionHero.subTitle
- Search saunas
+ SectionHero.mobileSearchButtonText
diff --git a/src/components/TopbarDesktop/__snapshots__/TopbarDesktop.test.js.snap b/src/components/TopbarDesktop/__snapshots__/TopbarDesktop.test.js.snap
index 2719969d..a95ff13c 100644
--- a/src/components/TopbarDesktop/__snapshots__/TopbarDesktop.test.js.snap
+++ b/src/components/TopbarDesktop/__snapshots__/TopbarDesktop.test.js.snap
@@ -65,7 +65,7 @@ exports[`TopbarDesktop data matches snapshot 1`] = `
onChange={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
- placeholder="Search saunas…"
+ placeholder="TopbarSearchForm.placeholder"
type="search"
value=""
/>
@@ -82,7 +82,7 @@ exports[`TopbarDesktop data matches snapshot 1`] = `
className={undefined}
>
- + Add your sauna
+ TopbarDesktop.createListing
@@ -97,7 +97,7 @@ exports[`TopbarDesktop data matches snapshot 1`] = `
className={undefined}
>
- Inbox
+ TopbarDesktop.inbox
@@ -142,7 +142,7 @@ exports[`TopbarDesktop data matches snapshot 1`] = `
className={undefined}
/>
- Your listings
+ TopbarDesktop.yourListingsLink
@@ -161,7 +161,7 @@ exports[`TopbarDesktop data matches snapshot 1`] = `
className={undefined}
/>
- Profile settings
+ TopbarDesktop.profileSettingsLink
@@ -180,7 +180,7 @@ exports[`TopbarDesktop data matches snapshot 1`] = `
className={undefined}
/>
- Account settings
+ TopbarDesktop.accountSettingsLink
@@ -197,7 +197,7 @@ exports[`TopbarDesktop data matches snapshot 1`] = `
className={undefined}
/>
- Log out
+ TopbarDesktop.logout
diff --git a/src/containers/EditListingDescriptionForm/__snapshots__/EditListingDescriptionForm.test.js.snap b/src/containers/EditListingDescriptionForm/__snapshots__/EditListingDescriptionForm.test.js.snap
index 3859ca0a..40e835c7 100644
--- a/src/containers/EditListingDescriptionForm/__snapshots__/EditListingDescriptionForm.test.js.snap
+++ b/src/containers/EditListingDescriptionForm/__snapshots__/EditListingDescriptionForm.test.js.snap
@@ -13,7 +13,7 @@ exports[`EditListingDescriptionForm matches snapshot 1`] = `
- The name of your sauna
+ EditListingDescriptionForm.title
@@ -37,7 +37,7 @@ exports[`EditListingDescriptionForm matches snapshot 1`] = `
- Describe your sauna
+ EditListingDescriptionForm.description
diff --git a/src/containers/EditListingPricingForm/__snapshots__/EditListingPricingForm.test.js.snap b/src/containers/EditListingPricingForm/__snapshots__/EditListingPricingForm.test.js.snap
index 1ef7e7a2..0c56bfbf 100644
--- a/src/containers/EditListingPricingForm/__snapshots__/EditListingPricingForm.test.js.snap
+++ b/src/containers/EditListingPricingForm/__snapshots__/EditListingPricingForm.test.js.snap
@@ -13,7 +13,7 @@ exports[`EditListingPricingForm matches snapshot 1`] = `
- Price per night in euros
+ EditListingPricingForm.pricePerNight
diff --git a/src/containers/LoginForm/__snapshots__/LoginForm.test.js.snap b/src/containers/LoginForm/__snapshots__/LoginForm.test.js.snap
index e4bd485e..acc5148d 100644
--- a/src/containers/LoginForm/__snapshots__/LoginForm.test.js.snap
+++ b/src/containers/LoginForm/__snapshots__/LoginForm.test.js.snap
@@ -14,7 +14,7 @@ exports[`LoginForm matches snapshot 1`] = `
- Email
+ LoginForm.emailLabel
@@ -36,7 +36,7 @@ exports[`LoginForm matches snapshot 1`] = `
- Password
+ LoginForm.passwordLabel
@@ -63,18 +63,7 @@ exports[`LoginForm matches snapshot 1`] = `
className={undefined}
>
- Forgot your password?
-
-
- Reset password.
-
-
+ LoginForm.forgotPasswordInfo
@@ -84,7 +73,7 @@ exports[`LoginForm matches snapshot 1`] = `
type="submit"
>
- Log in
+ LoginForm.logIn
diff --git a/src/containers/SignupForm/__snapshots__/SignupForm.test.js.snap b/src/containers/SignupForm/__snapshots__/SignupForm.test.js.snap
index d2fa4f49..0718b98e 100644
--- a/src/containers/SignupForm/__snapshots__/SignupForm.test.js.snap
+++ b/src/containers/SignupForm/__snapshots__/SignupForm.test.js.snap
@@ -14,7 +14,7 @@ exports[`SignupForm matches snapshot 1`] = `
- Email
+ SignupForm.emailLabel
@@ -39,7 +39,7 @@ exports[`SignupForm matches snapshot 1`] = `
- First name
+ SignupForm.firstNameLabel
@@ -61,7 +61,7 @@ exports[`SignupForm matches snapshot 1`] = `
- Last name
+ SignupForm.lastNameLabel
@@ -84,7 +84,7 @@ exports[`SignupForm matches snapshot 1`] = `
- Password
+ SignupForm.passwordLabel
@@ -111,18 +111,7 @@ exports[`SignupForm matches snapshot 1`] = `
className={undefined}
>
- By signing up you accept the
-
-
- terms and conditions
-
-
+ SignupForm.termsAndConditionsAcceptText
@@ -132,7 +121,7 @@ exports[`SignupForm matches snapshot 1`] = `
type="submit"
>
- Sign up
+ SignupForm.signUp
diff --git a/src/util/test-helpers.js b/src/util/test-helpers.js
index e63c4e6c..f544cbda 100644
--- a/src/util/test-helpers.js
+++ b/src/util/test-helpers.js
@@ -1,5 +1,6 @@
import React from 'react';
import renderer from 'react-test-renderer';
+import { mapValues } from 'lodash';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import { IntlProvider, addLocaleData } from 'react-intl';
@@ -7,7 +8,11 @@ import en from 'react-intl/locale-data/en';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import configureStore from '../store';
-import localeData from '../translations/en.json';
+import messages from '../translations/en.json';
+
+// Locale should not affect the tests. We ensure this by providing
+// messages with the key as the value of each message.
+const testMessages = mapValues(messages, (val, key) => key);
// Provide all the context for components that connect to the Redux
// store, i18n, router, etc.
@@ -15,7 +20,7 @@ export const TestProvider = props => {
const store = configureStore();
addLocaleData([...en]);
return (
-
+
{props.children}