Skip to content

Commit 14fba73

Browse files
authored
Relax upsert conflict violation rule from error to warning (#5674)
* Relax upsert conflict checks * Update PR number * Fix tests * Update token server URL
1 parent b4e565d commit 14fba73

File tree

122 files changed

+174
-169
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+174
-169
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ Breaking changes in this release:
384384
- Fixed activity sorting introduced in PR [#5622](https://github.com/microsoft/BotFramework-WebChat/pull/5622), part grouping, and livestreaming, by [@compulim](https://github.com/compulim) in PR [#5635](https://github.com/microsoft/BotFramework-WebChat/pull/5635)
385385
- Fixed Content Security Policy documentation and sample in PR, by [@compulim](https://github.com/compulim) in PR [#5648](https://github.com/microsoft/BotFramework-WebChat/pull/5648)
386386
- Added `img-src data:`, required for icons
387+
- Downgraded graph upsert conflict checks, by [@compulim](https://github.com/compulim) in PR [#5674](https://github.com/microsoft/BotFramework-WebChat/pull/5674)
387388

388389
## [4.18.0] - 2024-07-10
389390

__tests__/html2/simple/contentSecurityPolicy.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
Outside of the CSP defined in our /docs/CONTENT_SECURITY_POLICY.md, this test added limited number rules to enable the test case.
1010
1111
- connect-src
12-
- https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline to fetching Direct Line token
12+
- https://hawo-mockbot4-token-app.ambitiousflower-67725bfd.westus.azurecontainerapps.io/api/token/directline to fetching Direct Line token
1313
- script-src
1414
- 'nonce-TEST_PAGE_NONCE' to loading test related assets
1515
- style-src
1616
- 'nonce-TEST_PAGE_NONCE' to loading test related assets
1717
-->
1818
<meta
1919
http-equiv="Content-Security-Policy"
20-
content="default-src 'none'; base-uri 'none'; connect-src blob: https://directline.botframework.com https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline wss://directline.botframework.com; img-src blob: data:; script-src 'strict-dynamic' 'nonce-TEST_PAGE_NONCE'; style-src 'nonce-WEB_CHAT_NONCE' 'nonce-TEST_PAGE_NONCE'"
20+
content="default-src 'none'; base-uri 'none'; connect-src blob: https://directline.botframework.com https://hawo-mockbot4-token-app.ambitiousflower-67725bfd.westus.azurecontainerapps.io/api/token/directline wss://directline.botframework.com; img-src blob: data:; script-src 'strict-dynamic' 'nonce-TEST_PAGE_NONCE'; style-src 'nonce-WEB_CHAT_NONCE' 'nonce-TEST_PAGE_NONCE'"
2121
/>
2222
</head>
2323
<body>

__tests__/html2/skipped/speech.customAudioConfig.skip.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<script>
1212
run(async function () {
1313
const { authorizationToken, region } = await fetch(
14-
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/speech',
14+
'https://hawo-mockbot4-token-app.ambitiousflower-67725bfd.westus.azurecontainerapps.io/api/token/speech',
1515
{
1616
method: 'POST'
1717
}

__tests__/html2/skipped/speechRecognition.simple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe.each([
3232

3333
const { token } = await (
3434
await fetch(
35-
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline',
35+
'https://hawo-mockbot4-token-app.ambitiousflower-67725bfd.westus.azurecontainerapps.io/api/token/directline',
3636
{ method: 'POST' }
3737
)
3838
).json();

packages/core-graph/src/private/Graph.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ class Graph<TInput extends GraphNode, TOutput extends GraphNode = TInput> implem
9090
const id = node['@id'];
9191

9292
if (upsertedNodes.has(id)) {
93-
throw new Error(`Cannot upsert a node multiple times in a single transaction (@id = "${id}")`);
93+
console.warn(
94+
`botframework-webchat: Should NOT upsert a node multiple times in a single transaction (@id = "${id}")`
95+
);
9496
}
9597

9698
upsertedNodes.set(id, node);

packages/core-graph/src/private/Graph.upsert.spec.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect } from '@jest/globals';
1+
import { expect, jest } from '@jest/globals';
22
import { scenario } from '@testduet/given-when-then';
33
import Graph from './Graph';
44
import './schemas/private/expectExtendValibot';
@@ -36,24 +36,26 @@ scenario('Graph.upsert()', bdd => {
3636
);
3737

3838
bdd
39-
.given(
40-
'a Graph object',
41-
() => new Graph<{ readonly '@id': Identifier; readonly name: string }>(() => () => request => request)
42-
)
43-
.when('act().upsert() is called twice with node of same @id', graph => {
44-
try {
45-
graph.act(graph => graph.upsert({ '@id': '_:b1', name: 'John Doe' }, { '@id': '_:b1', name: 'Mary Doe' }));
46-
} catch (error) {
47-
return error;
48-
}
39+
.given('a Graph object', () => ({
40+
graph: new Graph<{ readonly '@id': Identifier; readonly name: string }>(() => () => request => request)
41+
}))
42+
.and(
43+
'spying console.warn()',
44+
precondition => {
45+
const warn = jest.spyOn(console, 'warn');
4946

50-
return undefined;
47+
return { ...precondition, warn };
48+
},
49+
({ warn }) => {
50+
warn.mockRestore();
51+
}
52+
)
53+
.when('act().upsert() is called twice with node of same @id', ({ graph }) => {
54+
graph.act(graph => graph.upsert({ '@id': '_:b1', name: 'John Doe' }, { '@id': '_:b1', name: 'Mary Doe' }));
5155
})
52-
.then('should throw', (_, error) => {
53-
expect(() => {
54-
if (error) {
55-
throw error;
56-
}
57-
}).toThrow('Cannot upsert a node multiple times in a single transaction (@id = "_:b1")');
56+
.then('should throw', ({ warn }) => {
57+
expect(warn).toHaveBeenCalledWith(
58+
'botframework-webchat: Should NOT upsert a node multiple times in a single transaction (@id = "_:b1")'
59+
);
5860
});
5961
});

packages/embed/hostDevServer.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const DEFAULT_BOT_ID = 'webchat-mockbot';
99
const app = express();
1010

1111
app.get('/', async (_, res) => {
12-
const tokenRes = await fetch('https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
12+
const tokenRes = await fetch('https://hawo-mockbot4-token-app.ambitiousflower-67725bfd.westus.azurecontainerapps.io/api/token/directline', { method: 'POST' });
1313

1414
if (!tokenRes.ok) {
1515
return res.send(500);

packages/test/page-object/src/globals/testHelpers/token/fetchDirectLineAppServiceExtensionToken.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default async function fetchDirectLineAppServiceExtensionToken() {
22
const res = await fetch(
3-
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directlinease',
3+
'https://hawo-mockbot4-token-app.ambitiousflower-67725bfd.westus.azurecontainerapps.io/api/token/directlinease',
44
{ method: 'POST' }
55
);
66

packages/test/page-object/src/globals/testHelpers/token/fetchDirectLineSpeechCredentials.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function createFetchDirectLineSpeechCredentials() {
66
if (!resultPromise || Date.now() > expireAfter) {
77
expireAfter = Date.now() + 5000;
88
resultPromise = fetch(
9-
'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/speech',
9+
'https://hawo-mockbot4-token-app.ambitiousflower-67725bfd.westus.azurecontainerapps.io/api/token/speech',
1010
{
1111
method: 'POST'
1212
}

packages/test/page-object/src/globals/testHelpers/token/fetchDirectLineToken.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default async function fetchDirectLineToken(
2-
url = 'https://hawo-mockbot4-token-app.blueriver-ce85e8f0.westus.azurecontainerapps.io/api/token/directline'
2+
url = 'https://hawo-mockbot4-token-app.ambitiousflower-67725bfd.westus.azurecontainerapps.io/api/token/directline'
33
) {
44
const res = await fetch(url, { method: 'POST' });
55

0 commit comments

Comments
 (0)