Skip to content

Commit 80cdcfc

Browse files
committed
chore: Add a test for HTML toasts.
1 parent 7a6a5cb commit 80cdcfc

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import * as chai from 'chai';
8+
import * as Blockly from 'blockly/core';
9+
import {PAUSE_TIME, testFileLocations, testSetup} from './test_setup.js';
10+
11+
suite('HTML toasts', function () {
12+
setup(async function () {
13+
this.browser = await testSetup(testFileLocations.BASE);
14+
await this.browser.pause(PAUSE_TIME);
15+
});
16+
17+
test('Can be displayed', async function () {
18+
const equal = await this.browser.execute(() => {
19+
const element = document.createElement('div');
20+
element.id = 'testToast';
21+
element.innerHTML = 'This is a <b>test</b>';
22+
23+
const options = {
24+
element,
25+
message: 'Placeholder',
26+
};
27+
Blockly.dialog.toast(
28+
Blockly.getMainWorkspace() as Blockly.WorkspaceSvg,
29+
options,
30+
);
31+
32+
// Ensure that the element displayed in the toast is the one we specified.
33+
return document.querySelector('.blocklyToast #testToast') === element;
34+
});
35+
36+
chai.assert.isTrue(equal);
37+
});
38+
});

0 commit comments

Comments
 (0)