Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc.production.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
overrides:
- files:
- '__tests__/**/*.js'
- '__tests__/**/*.mjs'
- '*.spec.js'
- '*.spec.mjs'
- '*.test.js'
- '*.test.mjs'

env:
jest: true

rules:
no-restricted-globals: off
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
- Fixed long citation identifiers break activity layout, in PR [#5507](https://github.com/microsoft/BotFramework-WebChat/pull/5507), by [@OEvgeny](https://github.com/OEvgeny)
- Updated file-based import with `.js` extension and removed the file extension from build config, by [@compulim](https://github.com/compulim), in PR [#5516](https://github.com/microsoft/BotFramework-WebChat/pull/5516)
- Fixed [#5518](https://github.com/microsoft/BotFramework-WebChat/issues/5518). Minimal bundled build should work properly, in PR [#5507](https://github.com/microsoft/BotFramework-WebChat/pull/5507), by [@compulim](https://github.com/compulim)
- Fixed [#5520](https://github.com/microsoft/BotFramework-WebChat/issues/5520). Version information should be injected when installed via npm, in PR [#5521](https://github.com/microsoft/BotFramework-WebChat/pull/5521), by [@compulim](https://github.com/compulim)

# Removed

Expand Down
2 changes: 1 addition & 1 deletion __tests__/html/fluentTheme/simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
);

expect(buildInfo).toHaveProperty('build-tool', 'tsup');
expect(buildInfo).toHaveProperty('module-format', 'esmodules');
expect(buildInfo).toHaveProperty('module-format', 'global');
expect(buildInfo.version).toMatch(/^\d+\.\d+\.\d+($|-)/u);

expect(window.WebChat.FluentThemeProvider).toBeTruthy();
Expand Down
7 changes: 7 additions & 0 deletions __tests__/html2/basic/bundle/es5.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
expect(metaMap.has('botframework-webchat:core:version')).toBe(true);
expect(metaMap.has('botframework-webchat:core')).toBe(true);
expect(metaMap.has('botframework-webchat:ui:version')).toBe(true);

expect(
metaMap
.get('botframework-webchat:bundle')
.split(';')
.map(value => value.trim())
).toEqual(expect.arrayContaining(['variant=full-es5', 'build-tool=tsup', 'module-format=global']));
});
</script>
</body>
Expand Down
7 changes: 7 additions & 0 deletions __tests__/html2/basic/bundle/full.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
expect(metaMap.has('botframework-webchat:core:version')).toBe(true);
expect(metaMap.has('botframework-webchat:core')).toBe(true);
expect(metaMap.has('botframework-webchat:ui:version')).toBe(true);

expect(
metaMap
.get('botframework-webchat:bundle')
.split(';')
.map(value => value.trim())
).toEqual(expect.arrayContaining(['variant=full', 'build-tool=tsup', 'module-format=global']));
});
</script>
</body>
Expand Down
7 changes: 7 additions & 0 deletions __tests__/html2/basic/bundle/minimal.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
expect(metaMap.has('botframework-webchat:core:version')).toBe(true);
expect(metaMap.has('botframework-webchat:core')).toBe(true);
expect(metaMap.has('botframework-webchat:ui:version')).toBe(true);

expect(
metaMap
.get('botframework-webchat:bundle')
.split(';')
.map(value => value.trim())
).toEqual(expect.arrayContaining(['variant=minimal', 'build-tool=tsup', 'module-format=global']));
});
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion __tests__/html2/preact/fluentTheme/simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
);

expect(buildInfo).toHaveProperty('build-tool', 'tsup');
expect(buildInfo).toHaveProperty('module-format', 'esmodules');
expect(buildInfo).toHaveProperty('module-format', 'global');
expect(buildInfo.version).toMatch(/^\d+\.\d+\.\d+($|-)/u);

expect(window.WebChat.FluentThemeProvider).toBeTruthy();
Expand Down
6 changes: 3 additions & 3 deletions jest.legacy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
npm_package_version: '0.0.0-0.jest'
},
moduleDirectories: ['node_modules', 'packages'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
moduleFileExtensions: ['js', 'jsx', 'mjs', 'ts', 'tsx'],
rootDir: './',
setupFilesAfterEnv: [
'<rootDir>/__tests__/setup/setupDotEnv.js',
Expand Down Expand Up @@ -76,14 +76,14 @@ module.exports = {
],
transform: {
'[\\/]__tests__[\\/]html[\\/]': '<rootDir>/babel-passthru-transformer.js',
'\\.[jt]sx?$': '<rootDir>/babel-jest-config.js'
'\\.m?[jt]sx?$': '<rootDir>/babel-jest-config.js'
},
transformIgnorePatterns: [
// jest-environment-jsdom import packages as browser.
// Packages, such as "uuid", export itself for browser as ES5 + ESM.
// Since jest@28 cannot consume ESM yet, we need to transpile these packages.
`/node_modules/(?!(${TRANSFORM_IGNORE_PACKAGES.join('|')})/)`,
'/packages/(?:test/)?\\w+/(?:lib/|dist/|\\w+\\.js)',
'/packages/(?:test/)?\\w+/(?:lib/|dist/.+?\\.js$|\\w+\\.js)',
...defaults.transformIgnorePatterns.filter(pattern => pattern !== '/node_modules/')
]
};
29 changes: 19 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/api/src/__tests__/addMetaTag.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @jest-environment @happy-dom/jest-environment */

test('CommonJS should export matching buildInfo', () => {
const { buildInfo } = jest.requireActual('../../dist/botframework-webchat-api.js');

expect(buildInfo).toHaveProperty('buildTool', 'tsup');
expect(buildInfo).toHaveProperty('moduleFormat', 'commonjs');
});
8 changes: 8 additions & 0 deletions packages/api/src/__tests__/addMetaTag.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @jest-environment @happy-dom/jest-environment */

test('ESModules should export matching buildInfo', () => {
const { buildInfo } = jest.requireActual('../../dist/botframework-webchat-api.mjs');

expect(buildInfo).toHaveProperty('buildTool', 'tsup');
expect(buildInfo).toHaveProperty('moduleFormat', 'esmodules');
});
2 changes: 2 additions & 0 deletions packages/api/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ const config: typeof baseConfig = {
export default defineConfig([
{
...config,
env: { ...config.env, module_format: 'esmodules' },
format: 'esm',
noExternal: ['globalize']
},
{
...config,
env: { ...config.env, module_format: 'commonjs' },
format: 'cjs',
target: [...config.target, 'es2019']
}
Expand Down
2 changes: 2 additions & 0 deletions packages/base/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ const config: typeof baseConfig = {
export default defineConfig([
{
...config,
env: { ...config.env, module_format: 'esmodules' },
format: 'esm'
},
{
...config,
env: { ...config.env, module_format: 'commonjs' },
format: 'cjs',
target: [...config.target, 'es2019']
}
Expand Down
32 changes: 32 additions & 0 deletions packages/bundle/src/__tests__/addMetaTag/full-es5.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/** @jest-environment @happy-dom/jest-environment */

describe('importing full (ES5) bundle', () => {
beforeEach(() => {
jest.spyOn(console, 'warn').mockImplementation(() => {
// Intentionally left blank.
});

// "adaptivecards" is trying to load "swiper", which is ESM only, mocking it
jest.mock('swiper', () => ({}));
jest.requireActual('../../../dist/botframework-webchat.es5.js');
});

test('should have injected <meta> tag', () => {
const metaMap = new Map(
Array.from(document.querySelectorAll('meta'))
.filter(({ name }) => name.startsWith('botframework-webchat'))
.map(({ content, name }) => [name, content])
);

expect(metaMap.has('botframework-webchat:bundle')).toBe(true);

expect(
metaMap
.get('botframework-webchat:bundle')
.split(';')
.map(value => value.trim())
).toEqual(expect.arrayContaining(['build-tool=tsup', 'module-format=commonjs']));

expect(metaMap.get('botframework-webchat:bundle:variant')).toBe('full-es5');
});
});
32 changes: 32 additions & 0 deletions packages/bundle/src/__tests__/addMetaTag/full-es5.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/** @jest-environment @happy-dom/jest-environment */

describe('importing full (ES5) bundle', () => {
beforeEach(() => {
jest.spyOn(console, 'warn').mockImplementation(() => {
// Intentionally left blank.
});

// "adaptivecards" is trying to load "swiper", which is ESM only, mocking it
jest.mock('swiper', () => ({}));
jest.requireActual('../../../dist/botframework-webchat.es5.mjs');
});

test('should have injected <meta> tag', () => {
const metaMap = new Map(
Array.from(document.querySelectorAll('meta'))
.filter(({ name }) => name.startsWith('botframework-webchat'))
.map(({ content, name }) => [name, content])
);

expect(metaMap.has('botframework-webchat:bundle')).toBe(true);

expect(
metaMap
.get('botframework-webchat:bundle')
.split(';')
.map(value => value.trim())
).toEqual(expect.arrayContaining(['build-tool=tsup', 'module-format=esmodules']));

expect(metaMap.get('botframework-webchat:bundle:variant')).toBe('full-es5');
});
});
32 changes: 32 additions & 0 deletions packages/bundle/src/__tests__/addMetaTag/full.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/** @jest-environment @happy-dom/jest-environment */

describe('importing full bundle', () => {
beforeEach(() => {
jest.spyOn(console, 'warn').mockImplementation(() => {
// Intentionally left blank.
});

// "adaptivecards" is trying to load "swiper", which is ESM only, mocking it
jest.mock('swiper', () => ({}));
jest.requireActual('../../../dist/botframework-webchat.js');
});

test('should have injected <meta> tag', () => {
const metaMap = new Map(
Array.from(document.querySelectorAll('meta'))
.filter(({ name }) => name.startsWith('botframework-webchat'))
.map(({ content, name }) => [name, content])
);

expect(metaMap.has('botframework-webchat:bundle')).toBe(true);

expect(
metaMap
.get('botframework-webchat:bundle')
.split(';')
.map(value => value.trim())
).toEqual(expect.arrayContaining(['build-tool=tsup', 'module-format=commonjs']));

expect(metaMap.get('botframework-webchat:bundle:variant')).toBe('full');
});
});
32 changes: 32 additions & 0 deletions packages/bundle/src/__tests__/addMetaTag/full.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/** @jest-environment @happy-dom/jest-environment */

describe('importing full bundle', () => {
beforeEach(() => {
jest.spyOn(console, 'warn').mockImplementation(() => {
// Intentionally left blank.
});

// "adaptivecards" is trying to load "swiper", which is ESM only, mocking it
jest.mock('swiper', () => ({}));
jest.requireActual('../../../dist/botframework-webchat.mjs');
});

test('should have injected <meta> tag', () => {
const metaMap = new Map(
Array.from(document.querySelectorAll('meta'))
.filter(({ name }) => name.startsWith('botframework-webchat'))
.map(({ content, name }) => [name, content])
);

expect(metaMap.has('botframework-webchat:bundle')).toBe(true);

expect(
metaMap
.get('botframework-webchat:bundle')
.split(';')
.map(value => value.trim())
).toEqual(expect.arrayContaining(['build-tool=tsup', 'module-format=esmodules']));

expect(metaMap.get('botframework-webchat:bundle:variant')).toBe('full');
});
});
26 changes: 26 additions & 0 deletions packages/bundle/src/__tests__/addMetaTag/minimal.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @jest-environment @happy-dom/jest-environment */

describe('importing minimal bundle', () => {
beforeEach(() => {
jest.requireActual('../../../dist/botframework-webchat.minimal.js');
});

test('should have injected <meta> tag', () => {
const metaMap = new Map(
Array.from(document.querySelectorAll('meta'))
.filter(({ name }) => name.startsWith('botframework-webchat'))
.map(({ content, name }) => [name, content])
);

expect(metaMap.has('botframework-webchat:bundle')).toBe(true);

expect(
metaMap
.get('botframework-webchat:bundle')
.split(';')
.map(value => value.trim())
).toEqual(expect.arrayContaining(['build-tool=tsup', 'module-format=commonjs']));

expect(metaMap.get('botframework-webchat:bundle:variant')).toBe('minimal');
});
});
26 changes: 26 additions & 0 deletions packages/bundle/src/__tests__/addMetaTag/minimal.spec.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @jest-environment @happy-dom/jest-environment */

describe('importing minimal bundle', () => {
beforeEach(() => {
jest.requireActual('../../../dist/botframework-webchat.minimal.mjs');
});

test('should have injected <meta> tag', () => {
const metaMap = new Map(
Array.from(document.querySelectorAll('meta'))
.filter(({ name }) => name.startsWith('botframework-webchat'))
.map(({ content, name }) => [name, content])
);

expect(metaMap.has('botframework-webchat:bundle')).toBe(true);

expect(
metaMap
.get('botframework-webchat:bundle')
.split(';')
.map(value => value.trim())
).toEqual(expect.arrayContaining(['build-tool=tsup', 'module-format=esmodules']));

expect(metaMap.get('botframework-webchat:bundle:variant')).toBe('minimal');
});
});
Loading
Loading