-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add React hooks for customization (part 4) (#2543)
* Typo * Update entry * Add useActivities, useReferenceGrammarID and useSendBoxDictationStarted * Add useStyleOptions and useStyleSet * Fix errors * Add useStyleOptions and useStyleSet * Add useLanguage and useLocalize * Fix ESLint * Cleanup * Clean up * Fix useLocalize * Revert dev build * Typo * Update entry * Fix ESLint * Add useStyleOptions and useStyleSet * Add useStyleOptions and useStyleSet * Add useLanguage and useLocalize * Use useLocalize * Add useStyleOptions and useStyleSet * Add useLanguage and useLocalize * Add useAdaptiveCards* and useRenderMarkdownAsHTML * Update PR number * Use HostConfig from package * Update entry * Fix tests * Improve test reliability * Remove useWebSpeechPonyfill test * Fix tests * Fix ESLint * Fix ESLint * Fix bad merge * Fix bad merge * Undo dev changes * Fix test * Add test * Add test * Update screenshot * Fix tests
- Loading branch information
Showing
32 changed files
with
389 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+19.9 KB
...me-docker/adaptive-cards-js-breakfast-card-with-custom-style-options-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
test('getter should return Adaptive Cards host config set in props', async () => { | ||
const { pageObjects } = await setupWebDriver({ | ||
props: { | ||
adaptiveCardsHostConfig: { | ||
supportsInteractivity: false | ||
} | ||
} | ||
}); | ||
|
||
const [adaptiveCardsHostConfig] = await pageObjects.runHook('useAdaptiveCardsHostConfig'); | ||
|
||
expect(adaptiveCardsHostConfig).toMatchInlineSnapshot(` | ||
Object { | ||
"supportsInteractivity": false, | ||
} | ||
`); | ||
}); | ||
|
||
test('getter should return default Adaptive Cards host config if not set in props', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
|
||
const [adaptiveCardsHostConfig] = await pageObjects.runHook('useAdaptiveCardsHostConfig'); | ||
|
||
expect(adaptiveCardsHostConfig.supportsInteractivity).toMatchInlineSnapshot(`true`); | ||
}); | ||
|
||
test('setter should be undefined', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
const [_, setAdaptiveCardsHostConfig] = await pageObjects.runHook('useAdaptiveCardsHostConfig'); | ||
|
||
expect(setAdaptiveCardsHostConfig).toBeUndefined(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
test('getter should return Adaptive Cards package set in props', async () => { | ||
const { pageObjects } = await setupWebDriver({ | ||
props: { | ||
adaptiveCardsPackage: { | ||
__DUMMY__: 0 | ||
} | ||
} | ||
}); | ||
|
||
const [adaptiveCardsPackage] = await pageObjects.runHook('useAdaptiveCardsPackage'); | ||
|
||
expect(adaptiveCardsPackage).toMatchInlineSnapshot(` | ||
Object { | ||
"__DUMMY__": 0, | ||
} | ||
`); | ||
}); | ||
|
||
test('getter should return default Adaptive Cards package if not set in props', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
|
||
const [adaptiveCardsPackage] = await pageObjects.runHook('useAdaptiveCardsPackage', [], results => | ||
results[0].AdaptiveCard.currentVersion.toString() | ||
); | ||
|
||
expect(adaptiveCardsPackage).toMatchInlineSnapshot(`"1"`); | ||
}); | ||
|
||
test('setter should be undefined', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
const setAdaptiveCardsPackage = await pageObjects.runHook( | ||
'useAdaptiveCardsPackage', | ||
[], | ||
results => typeof results[1] === 'undefined' | ||
); | ||
|
||
expect(setAdaptiveCardsPackage).toMatchInlineSnapshot(`true`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { timeouts } from '../constants.json'; | ||
|
||
// selenium-webdriver API doc: | ||
// https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html | ||
|
||
jest.setTimeout(timeouts.test); | ||
|
||
test('renderMarkdown should use Markdown-It if not set in props', async () => { | ||
const { pageObjects } = await setupWebDriver(); | ||
|
||
await expect(pageObjects.runHook('useRenderMarkdownAsHTML', [], fn => fn('Hello, World!'))).resolves.toBe( | ||
'<p>Hello, World!</p>\n' | ||
); | ||
}); | ||
|
||
test('renderMarkdown should use custom Markdown transform function from props', async () => { | ||
const { pageObjects } = await setupWebDriver({ | ||
props: { | ||
renderMarkdown: text => text.toUpperCase() | ||
} | ||
}); | ||
|
||
await expect( | ||
pageObjects.runHook('useRenderMarkdownAsHTML', [], fn => fn('Hello, World!')) | ||
).resolves.toMatchInlineSnapshot(`"HELLO, WORLD!"`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { By, until } from 'selenium-webdriver'; | ||
|
||
export default function scrollToBottomButtonVisible() { | ||
return until.elementLocated(By.css(`[role="log"] > button:last-child`)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
process.env.npm_package_version = '0.0.0-test'; | ||
|
||
describe('loading Web Chat', () => { | ||
test('of variant "es5" should set META tag', () => { | ||
require('../index-es5'); | ||
|
||
expect(document.querySelector('head > meta[name="botframework-webchat:bundle:variant"]').content).toBe('full-es5'); | ||
|
||
expect(document.querySelector('head > meta[name="botframework-webchat:bundle:version"]').content).toBe( | ||
'0.0.0-test' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
process.env.npm_package_version = '0.0.0-test'; | ||
|
||
describe('loading Web Chat', () => { | ||
test('of variant "full" should set META tag', () => { | ||
require('../index'); | ||
|
||
expect(document.querySelector('head > meta[name="botframework-webchat:bundle:variant"]').content).toBe('full'); | ||
|
||
expect(document.querySelector('head > meta[name="botframework-webchat:bundle:version"]').content).toBe( | ||
'0.0.0-test' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
process.env.npm_package_version = '0.0.0-test'; | ||
|
||
describe('loading Web Chat', () => { | ||
test('of variant "minimal" should set META tag', () => { | ||
require('../index-minimal'); | ||
|
||
expect(document.querySelector('head > meta[name="botframework-webchat:bundle:variant"]').content).toBe('minimal'); | ||
|
||
expect(document.querySelector('head > meta[name="botframework-webchat:bundle:version"]').content).toBe( | ||
'0.0.0-test' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { createContext } from 'react'; | ||
|
||
const AdaptiveCardHostConfigContext = createContext({ | ||
adaptiveCardsPackage: undefined, | ||
hostConfig: undefined | ||
}); | ||
|
||
export default AdaptiveCardHostConfigContext; |
Oops, something went wrong.