Skip to content

Commit

Permalink
E2E: Fix running with ts-loader
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Yen <[email protected]>
  • Loading branch information
mook-as committed Jul 15, 2024
1 parent f858fa1 commit 313e893
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
24 changes: 13 additions & 11 deletions pkg/rancher-desktop/utils/testUtils/setupElectron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@

import path from 'path';

jest.mock('electron', () => {
return {
__esModule: true,
default: {
app: {
isPackaged: false,
getAppPath: () => path.resolve('.'),
if ('jest' in globalThis && 'mock' in jest) {
jest.mock('electron', () => {
return {
__esModule: true,
default: {
app: {
isPackaged: false,
getAppPath: () => path.resolve('.'),
},
ipcMain: {},
},
ipcMain: {},
},
};
});
};
});
}
12 changes: 11 additions & 1 deletion pkg/rancher-desktop/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ module.exports = {
.test(/\.ts$/)
.use('ts-loader')
.loader('ts-loader')
.options({ transpileOnly: process.env.NODE_ENV === 'development' });
.options({
transpileOnly: process.env.NODE_ENV === 'development',
appendTsSuffixTo: ['\\.vue$'],
happyPackMode: true,
});

config.module.rule('yaml')
.test(/\.ya?ml(?:\?[a-z0-9=&.]+)?$/)
Expand All @@ -49,6 +53,12 @@ module.exports = {
featureExtensions: true,
}),
}]);

config.module.rule('vue').use('vue-loader').tap((options) => {
_.set(options, 'loaders.ts', 'ts-loader');

return options;
});
},

css: {
Expand Down
6 changes: 1 addition & 5 deletions pkg/rancher-desktop/window/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,7 @@ export function openDialog(id: string, opts?: Electron.BrowserWindowConstructorO
}
});

if (Shortcuts.isRegistered(window)) {
return window;
}

if (escapeKey) {
if (!Shortcuts.isRegistered(window) && escapeKey) {
Shortcuts.register(
window,
{ key: 'Escape' },
Expand Down

0 comments on commit 313e893

Please sign in to comment.