Skip to content

Commit

Permalink
chore: upgrade webpack, jest and other deps (#923)
Browse files Browse the repository at this point in the history
* chore: upgrade deps for security

* chore: audit fix

* chore: fix tests

* misc: remove unused package
  • Loading branch information
embbnux authored Dec 3, 2024
1 parent f7fee2b commit cf097ef
Show file tree
Hide file tree
Showing 14 changed files with 2,282 additions and 1,397 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ extension
src/noise-reduction
site
src/plugins.json

.vscode
70 changes: 51 additions & 19 deletions getWebpackBaseConfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const path = require('path');
const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const supportedLocales = [
'en-US',
Expand Down Expand Up @@ -87,30 +85,41 @@ module.exports = function getBaseConfig({ themeFolder = null, styleLoader = 'sty
},
{
test: /\.md$/,
use: 'raw-loader',
type: 'asset/source',
},
{
test: /\.css$/,
use: [
styleLoader,
'css-loader',
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[folder]_[local]',
namedExport: false,
exportOnlyLocals: false,
exportLocalsConvention: 'as-is',
},
}
}
],
},
{
test: /\.woff|\.woff2|.eot|\.ttf/,
use: {
loader: 'url-loader',
options: {
limit: 15000,
name: 'fonts/[name]_[hash].[ext]',
// TODO: it should be upgrade css-loader and update config
esModule: false,
type: 'asset',
generator: {
filename: 'fonts/[name]_[hash][ext]',
},
parser: {
dataUrlCondition: {
maxSize: 15 * 1024,
},
},
},
{
test: /\.svg/,
exclude: /font/,
resourceQuery: { not: [/urlLoader/] },
use: [
'babel-loader',
{
Expand All @@ -128,13 +137,28 @@ module.exports = function getBaseConfig({ themeFolder = null, styleLoader = 'sty
}
]
},
{
resourceQuery: /urlLoader/,
type: 'asset/inline',
},
{
test: /\.png|\.jpg|\.gif|fonts(\/|\\).*\.svg/,
use: 'url-loader?limit=20000&name=images/[name]_[hash].[ext]',
type: 'asset',
parser: {
dataUrlCondition: {
maxSize: 20 * 1024,
},
},
generator: {
filename: 'images/[name]_[hash][ext]',
},
},
{
test: /\.ogg$/,
use: 'file-loader?publicPath=./&name=audio/[name]_[hash].[ext]',
type: 'asset/resource',
generator: {
filename: 'audio/[name]_[hash][ext]',
},
},
{
test: /\.sass|\.scss/,
Expand All @@ -143,23 +167,31 @@ module.exports = function getBaseConfig({ themeFolder = null, styleLoader = 'sty
{
loader: 'css-loader',
options: {
localIdentName: '[folder]_[local]',
modules: true,
modules: {
localIdentName: '[folder]_[local]',
namedExport: false,
exportOnlyLocals: false,
exportLocalsConvention: 'as-is',
},
}
},
{
loader: 'postcss-loader',
options: {
plugins() {
return [autoprefixer];
postcssOptions: {
plugins: [
['postcss-preset-env'],
],
},
},
},
{
loader: 'sass-loader',
options: {
outputStyle: 'expanded',
includePaths: sassLoaderIncludePaths,
sassOptions: {
style: 'expanded',
loadPaths: sassLoaderIncludePaths,
},
},
}
],
Expand Down
35 changes: 17 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
"@nrwl/eslint-plugin-nx": "15.3.3",
"@typescript-eslint/eslint-plugin": "5.36.1",
"@typescript-eslint/parser": "5.36.1",
"autoprefixer": "^9.6.1",
"autoprefixer": "^10.4.20",
"babel-eslint": "^10.0.1",
"babel-loader": "^9.1.2",
"babel-plugin-const-enum": "^1.0.1",
"babel-plugin-direct-import": "^1.0.0",
"babel-plugin-transform-typescript-metadata": "^0.3.2",
"buffer": "^6.0.3",
"copy-webpack-plugin": "^9.0.1",
"copy-webpack-plugin": "^12.0.2",
"cross-env": "^7.0.3",
"crypto-browserify": "^3.12.0",
"css-loader": "^2.1.0",
"css-loader": "^7.1.2",
"dotenv": "^6.2.0",
"eslint": "8.23.0",
"eslint-config-prettier": "8.5.0",
Expand All @@ -50,27 +50,27 @@
"eslint-plugin-react": "7.31.1",
"eslint-plugin-react-hooks": "4.6.0",
"events": "^3.3.0",
"file-loader": "^3.0.1",
"jest": "^29.6.1",
"jest-puppeteer": "^8.0.6",
"mini-css-extract-plugin": "^2.7.0",
"jest": "^29.7.0",
"jest-puppeteer": "^10.1.4",
"mini-css-extract-plugin": "^2.9.2",
"path-browserify": "^1.0.1",
"postcss-loader": "^3.0.0",
"postcss-loader": "^8.1.1",
"postcss": "^8.4.49",
"postcss-preset-env": "^10.1.1",
"process": "^0.11.10",
"puppeteer": "^19.7.3",
"puppeteer": "^23.9.0",
"querystring-es3": "^0.2.1",
"sass": "^1.43.4",
"sass-loader": "^7.3.1",
"sass-loader": "^16.0.3",
"stream-browserify": "^3.0.0",
"style-loader": "^0.23.1",
"string-replace-loader": "^3.0.3",
"terser-webpack-plugin": "^4.2.1",
"style-loader": "^4.0.0",
"string-replace-loader": "^3.1.0",
"terser-webpack-plugin": "^5.3.10",
"typescript": "^4.9.4",
"url-loader": "^4.1.1",
"vm-browserify": "1.1.2",
"webpack": "^5.94.0",
"webpack-cli": "^4.9.0",
"webpack-dev-server": "^4.3.1"
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
},
"dependencies": {
"@babel/polyfill": "^7.10.4",
Expand All @@ -91,7 +91,6 @@
"@ringcentral/juno-icon": "^1.77.0",
"@ringcentral/mfe-react": "^0.3.7",
"@ringcentral/sdk": "^4.7.2",
"@ringcentral/subscriptions": "^4.7.2",
"@rjsf/core": "^5.17.1",
"@rjsf/utils": "^5.17.1",
"@rjsf/validator-ajv8": "^5.17.1",
Expand Down
5 changes: 0 additions & 5 deletions postcss.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/lib/Adapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import styles from './styles.scss';
import Notification from '../notification';

// eslint-disable-next-line
import popupIconUrl from '!url-loader!../../assets/images/popup.svg';
import helpIconUrl from '!url-loader!../../assets/images/help.svg';
import popupIconUrl from '../../assets/images/popup.svg?urlLoader';
import helpIconUrl from '../../assets/images/help.svg?urlLoader';

function checkValidImageUri(uri) {
return (
Expand Down
4 changes: 2 additions & 2 deletions test/embeddable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { setBrowserPermission } = require('./steps/common');
const {
visitThirdPartyPage,
} = require('./steps/embeddable');

const { waitForTimeout } = require('./helpers');
const { IframeWidget } = require('./steps/IframeWidget');

describe('Embeddable', () => {
Expand All @@ -23,7 +23,7 @@ describe('Embeddable', () => {
const widgetIframe = new IframeWidget();
await widgetIframe.loadElement();
await widgetIframe.waitForLoginPage();
await page.waitForTimeout(1000);
await waitForTimeout(1000);
const loginText = await widgetIframe.getLoginButtonText();
expect(loginText).toEqual('Sign In');
});
Expand Down
4 changes: 4 additions & 0 deletions test/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ export function getNewWindowPromise() {
const newWindowPromise = new Promise(resolve => browser.once('targetcreated', target => resolve(target.page())));
return newWindowPromise;
}

export function waitForTimeout(timeout) {
return new Promise(resolve => setTimeout(resolve, timeout));
}
3 changes: 2 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const {
setBrowserPermission,
visitIndexPage,
} = require('./steps/common');
const { waitForTimeout } = require('./helpers');

const { IframeWidget } = require('./steps/IframeWidget');

Expand All @@ -20,7 +21,7 @@ describe('Index page test', () => {
const widgetIframe = new IframeWidget();
await widgetIframe.loadElement();
await widgetIframe.waitForLoginPage();
await page.waitForTimeout(1000);
await waitForTimeout(1000);
const loginText = await widgetIframe.getLoginButtonText();
expect(loginText).toEqual('Sign In');
});
Expand Down
17 changes: 9 additions & 8 deletions test/steps/IframeWidget.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const {
getNewWindowPromise,
waitForTimeout,
} = require('../helpers');

export class IframeWidget {
Expand All @@ -11,7 +12,7 @@ export class IframeWidget {

async loadElement() {
await this._targetPage.waitForSelector('iframe#rc-widget-adapter-frame', { timeout: 300000 });
await this._targetPage.waitForTimeout(3000);
await waitForTimeout(3000);
const iframeElement = await this._targetPage.$('iframe#rc-widget-adapter-frame');
this._widgetIframe = await iframeElement.contentFrame();
}
Expand Down Expand Up @@ -83,7 +84,7 @@ export class IframeWidget {
throw new Error(`Navigation button not found for ${label}`);
}
await this._widgetIframe.click('.MuiListItem-root[role="tab"][data-sign="More"]');
await this._widgetIframe.waitForTimeout(1000);
await waitForTimeout(1000);
await this.clickNavigationSubMenu(label);
}

Expand All @@ -99,7 +100,7 @@ export class IframeWidget {
});
if (hasHidden){
await this._widgetIframe.click('.MuiTabs-flexContainer button[data-tab-more-button]');
await this._widgetIframe.waitForTimeout(1000);
await waitForTimeout(1000);
await this._widgetIframe.click(`li[value="${path}"]`);
} else {
await this._widgetIframe.click(`.MuiTab-root[data-sign="${label}"]`);
Expand All @@ -125,7 +126,7 @@ export class IframeWidget {

async getCallItemList() {
await this.waitFor('.CallsListPanel_container');
await this._widgetIframe.waitForTimeout(500); // for render
await waitForTimeout(500); // for render
const callItems = await this._widgetIframe.$$('div[data-sign="calls_item_root"]');
return callItems;
}
Expand All @@ -142,14 +143,14 @@ export class IframeWidget {

async getMessageList(type) {
await this.waitFor('div[data-sign="messageList"]');
await this._widgetIframe.waitForTimeout(500); // for render
await waitForTimeout(500); // for render
const voicemailItems = await this._widgetIframe.$$(`div[data-sign="${type}"]`);
return voicemailItems;
}

async getNoMessageText() {
await this.waitFor('div[data-sign="messageList"]');
await this._widgetIframe.waitForTimeout(500);
await waitForTimeout(500);
const noMessage = await this._widgetIframe.$('p[data-sign="noMatch"]');
if (!noMessage) {
return null;
Expand Down Expand Up @@ -217,7 +218,7 @@ export class IframeWidget {

async typeSMSRecipientAndText({ recipientNumber, text}) {
await this._widgetIframe.type('input[name="receiver"]', recipientNumber);
await this._widgetIframe.waitForTimeout(1000);
await waitForTimeout(1000);
await this._widgetIframe.type('textarea[data-sign="messageInput"]', text);
}

Expand Down Expand Up @@ -261,6 +262,6 @@ export class IframeWidget {
}

async waitForTimeout(timeout) {
await this._widgetIframe.waitForTimeout(timeout);
await waitForTimeout(timeout);
}
}
8 changes: 5 additions & 3 deletions test/steps/LoginWindow.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { waitForTimeout } = require('../helpers');

export class LoginWindow {
constructor(targetPage, username, password) {
this._targetPage = targetPage;
Expand All @@ -10,9 +12,9 @@ export class LoginWindow {
await this._targetPage.type('input[name="credential"]', this._username);
await this._targetPage.click('button[type="submit"]');
await this._targetPage.waitForSelector('input[name="Password"]');
await this._targetPage.waitForTimeout(1200);
await waitForTimeout(1200);
await this._targetPage.type('input[name="Password"]', this._password);
await this._targetPage.waitForTimeout(200);
await waitForTimeout(200);
await this._targetPage.click('button[type="submit"]');
}

Expand Down Expand Up @@ -55,7 +57,7 @@ export class LoginWindow {
'document.querySelector("body").innerText.includes("Access Request")'
);
await this._targetPage.click('button.btn-primary');
await this._targetPage.waitForTimeout(200);
await waitForTimeout(200);
await this.confirmEmergencyDigitalLine();
}
}
3 changes: 2 additions & 1 deletion test/steps/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { IframeWidget } = require('./IframeWidget');
const { waitForTimeout } = require('../helpers');

export async function setBrowserPermission(permissions = ['notifications', 'microphone']) {
const context = browser.defaultBrowserContext();
Expand All @@ -21,6 +22,6 @@ export async function getAuthorizedWidget(jwtToken) {
// await widgetIframe.enableSandboxEnvironment();
// await widgetIframe.waitForLoginPage();
await widgetIframe.loginWithCallbackUri(`${__HOST_URI__}/redirect.html?jwt=${jwtToken}`);
await page.waitForTimeout(1000);
await waitForTimeout(1000);
return widgetIframe;
}
Loading

0 comments on commit cf097ef

Please sign in to comment.