Skip to content

Commit

Permalink
test(mirage): correct server authority string in preview builds (#1283)
Browse files Browse the repository at this point in the history
* test(mirage): set server authority string in preview builds

* fix(mirage): ensure wsUrl matches that in application code

---------

Co-authored-by: Thuan Vo <[email protected]>
(cherry picked from commit 3aaeead)
  • Loading branch information
andrewazores authored and mergify[bot] committed Jun 12, 2024
1 parent 3f84e25 commit 6b2c332
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/mirage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import { Server as WSServer, Client } from 'mock-socket';
import factories from './factories';
import models from './models';
import { Resource } from './typings';
import { sizeUnits } from 'src/app/utils/utils';

export const startMirage = ({ environment = 'development' } = {}) => {
const wsUrl = `ws://localhost:9091/api/notifications`;
const wsServer = new WSServer(wsUrl);
const wsUrl = new URL(window.location.href);
wsUrl.protocol = wsUrl.protocol.replace('http', 'ws');
wsUrl.pathname = '/api/notifications';
const wsServer = new WSServer(wsUrl.toString());

// Create a mock server socket to send notifications
let websocket: Client;
Expand Down
2 changes: 1 addition & 1 deletion webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = merge(common('production'), {
chunkFilename: '[name].[contenthash].bundle.css' // lazy-load css
}),
new EnvironmentPlugin({
CRYOSTAT_AUTHORITY: '',
CRYOSTAT_AUTHORITY: process.env.PREVIEW ? 'http://localhost:8181' : '',
PREVIEW: process.env.PREVIEW || 'false'
})
],
Expand Down

0 comments on commit 6b2c332

Please sign in to comment.