diff --git a/src/react-components/profile-entry-panel.js b/src/react-components/profile-entry-panel.js index 91044c27cab1955c7e35698322c618b907a3f95d..7dd04d84ecbaab4ae3248fbab400579d3d621135 100644 --- a/src/react-components/profile-entry-panel.js +++ b/src/react-components/profile-entry-panel.js @@ -7,12 +7,12 @@ class ProfileEntryPanel extends Component { static propTypes = { store: PropTypes.object, messages: PropTypes.object, - finished: PropTypes.func + finished: PropTypes.func, + htmlPrefix: PropTypes.string } constructor(props) { super(props); - window.store = this.props.store; this.state = { display_name: this.props.store.state.profile.display_name, avatar_id: this.props.store.state.profile.avatar_id, @@ -77,10 +77,7 @@ class ProfileEntryPanel extends Component { ref={inp => this.nameInput = inp}/> <iframe className="profile-entry__avatar-selector" - src={ - /* HACK: Have to account for the smoke test server like this. Feels wrong though. */ - `${/smoke/i.test(location.hostname) ? 'smoke-' : ''}avatar-selector.html#avatar_id=${this.state.avatar_id}` - } + src={`${this.props.htmlPrefix}avatar-selector.html#avatar_id=${this.state.avatar_id}`} ref={ifr => this.avatarSelector = ifr}></iframe> <input className="profile-entry__form-submit" type="submit" value={formatMessage({ id: "profile.save" }) }/> </div> diff --git a/src/react-components/ui-root.js b/src/react-components/ui-root.js index 26ffdfbf3d55227218ea4c36f3752fbe888461df..f5ae5dbc4ac7502ee34d9d9d3ffabe98bc3585f9 100644 --- a/src/react-components/ui-root.js +++ b/src/react-components/ui-root.js @@ -61,7 +61,8 @@ class UIRoot extends Component { forcedVREntryType: PropTypes.string, enableScreenSharing: PropTypes.bool, store: PropTypes.object, - scene: PropTypes.object + scene: PropTypes.object, + htmlPrefix: PropTypes.object }; state = { @@ -661,7 +662,11 @@ class UIRoot extends Component { <div className={dialogBoxContentsClassNames}>{dialogContents}</div> {this.state.showProfileEntry && ( - <ProfileEntryPanel finished={this.onProfileFinished} store={this.props.store} /> + <ProfileEntryPanel + finished={this.onProfileFinished} + store={this.props.store} + htmlPrefix={this.props.htmlPrefix} + /> )} </div> )} diff --git a/src/room.html b/src/room.html index 5fc6c309b438a3e7788abb92ff346bdb0ee42754..65aa343c01fe3c989a844b9b0f425d622ecf9a35 100644 --- a/src/room.html +++ b/src/room.html @@ -13,7 +13,7 @@ <% } %> </head> -<body> +<body data-html-prefix="<%= HTML_PREFIX %>"> <audio id="test-tone" src="./assets/sfx/tone.ogg"></audio> <a-scene diff --git a/src/room.js b/src/room.js index 232bc18accb2d4150f3213e09f1cbaac5d0c4d47..40cf9442f46c11e3a1a5f27d736b09e72b2e210c 100644 --- a/src/room.js +++ b/src/room.js @@ -218,6 +218,7 @@ function mountUI(scene) { const disableAutoExitOnConcurrentLoad = qsTruthy("allow_multi"); const forcedVREntryType = qs.vr_entry_type || null; const enableScreenSharing = qsTruthy("enable_screen_sharing"); + const htmlPrefix = document.body.dataset.htmlPrefix || ""; const uiRoot = ReactDOM.render( <UIRoot @@ -229,7 +230,8 @@ function mountUI(scene) { disableAutoExitOnConcurrentLoad, forcedVREntryType, enableScreenSharing, - store + store, + htmlPrefix }} />, document.getElementById("ui-root") diff --git a/webpack.config.js b/webpack.config.js index d404babbb6d5af438271621b4e3f2fbac235a266..aa2462d195e7edd7882bfb0e99b82179c091e44d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,6 +9,8 @@ const HTMLWebpackPlugin = require("html-webpack-plugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); const _ = require("lodash"); +const SMOKE_PREFIX = "smoke-"; + function createHTTPSConfig() { if (process.env.NODE_ENV === "production") { return false; @@ -218,6 +220,7 @@ const config = { // expose these variables to the lodash template // ex: <%= ORIGIN_TRIAL_TOKEN %> imports: { + HTML_PREFIX: process.env.GENERATE_SMOKE_TESTS ? SMOKE_PREFIX : "", NODE_ENV: process.env.NODE_ENV, ORIGIN_TRIAL_EXPIRES: process.env.ORIGIN_TRIAL_EXPIRES, ORIGIN_TRIAL_TOKEN: process.env.ORIGIN_TRIAL_TOKEN @@ -238,14 +241,14 @@ module.exports = () => { const smokeConfig = Object.assign({}, config, { // Set the public path for to point to the correct assets on the smoke-test build. output: Object.assign({}, config.output, { - publicPath: process.env.BASE_ASSETS_PATH.replace("://", "://smoke-") + publicPath: process.env.BASE_ASSETS_PATH.replace("://", `://${SMOKE_PREFIX}`) }), // For this config plugins: config.plugins.map(plugin => { if (plugin instanceof HTMLWebpackPlugin) { return new HTMLWebpackPlugin( Object.assign({}, plugin.options, { - filename: "smoke-" + plugin.options.filename + filename: SMOKE_PREFIX + plugin.options.filename }) ); }