mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
fix(tests): use new helper function for right-clicks
This commit is contained in:
@@ -69,37 +69,36 @@ suite('Right Clicking on Blocks', function () {
|
|||||||
suiteSetup(async function () {
|
suiteSetup(async function () {
|
||||||
this.browser = await testSetup(testFileLocations.PLAYGROUND);
|
this.browser = await testSetup(testFileLocations.PLAYGROUND);
|
||||||
this.block = await dragNthBlockFromFlyout(this.browser, 'Loops', 0, 20, 20);
|
this.block = await dragNthBlockFromFlyout(this.browser, 'Loops', 0, 20, 20);
|
||||||
this.blockId = this.block.id;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clicking the collapse option collapses the block', async function () {
|
test('clicking the collapse option collapses the block', async function () {
|
||||||
await contextMenuSelect(this.browser, this.block, 'Collapse Block');
|
await contextMenuSelect(this.browser, this.block.id, 'Collapse Block');
|
||||||
chai.assert.isTrue(await getIsCollapsed(this.browser, this.blockId));
|
chai.assert.isTrue(await getIsCollapsed(this.browser, this.block.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Assumes that
|
// Assumes that
|
||||||
test('clicking the expand option expands the block', async function () {
|
test('clicking the expand option expands the block', async function () {
|
||||||
await contextMenuSelect(this.browser, this.block, 'Expand Block');
|
await contextMenuSelect(this.browser, this.block.id, 'Expand Block');
|
||||||
chai.assert.isFalse(await getIsCollapsed(this.browser, this.blockId));
|
chai.assert.isFalse(await getIsCollapsed(this.browser, this.block.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clicking the disable option disables the block', async function () {
|
test('clicking the disable option disables the block', async function () {
|
||||||
await contextMenuSelect(this.browser, this.block, 'Disable Block');
|
await contextMenuSelect(this.browser, this.block.id, 'Disable Block');
|
||||||
chai.assert.isTrue(await getIsDisabled(this.browser, this.blockId));
|
chai.assert.isTrue(await getIsDisabled(this.browser, this.block.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clicking the enable option enables the block', async function () {
|
test('clicking the enable option enables the block', async function () {
|
||||||
await contextMenuSelect(this.browser, this.block, 'Enable Block');
|
await contextMenuSelect(this.browser, this.block.id, 'Enable Block');
|
||||||
chai.assert.isFalse(await getIsDisabled(this.browser, this.block.id));
|
chai.assert.isFalse(await getIsDisabled(this.browser, this.block.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clicking the add comment option adds a comment to the block', async function () {
|
test('clicking the add comment option adds a comment to the block', async function () {
|
||||||
await contextMenuSelect(this.browser, this.block, 'Add Comment');
|
await contextMenuSelect(this.browser, this.block.id, 'Add Comment');
|
||||||
chai.assert.equal(await getCommentText(this.browser, this.block.id), '');
|
chai.assert.equal(await getCommentText(this.browser, this.block.id), '');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clicking the remove comment option removes a comment from the block', async function () {
|
test('clicking the remove comment option removes a comment from the block', async function () {
|
||||||
await contextMenuSelect(this.browser, this.block, 'Remove Comment');
|
await contextMenuSelect(this.browser, this.block.id, 'Remove Comment');
|
||||||
chai.assert.isNull(await getCommentText(this.browser, this.block.id));
|
chai.assert.isNull(await getCommentText(this.browser, this.block.id));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -139,7 +138,7 @@ suite('Disabling', function () {
|
|||||||
);
|
);
|
||||||
await connect(this.browser, child, 'OUTPUT', parent, 'IF0');
|
await connect(this.browser, child, 'OUTPUT', parent, 'IF0');
|
||||||
|
|
||||||
await contextMenuSelect(this.browser, parent, 'Disable Block');
|
await contextMenuSelect(this.browser, parent.id, 'Disable Block');
|
||||||
|
|
||||||
chai.assert.isTrue(await getIsDisabled(this.browser, child.id));
|
chai.assert.isTrue(await getIsDisabled(this.browser, child.id));
|
||||||
},
|
},
|
||||||
@@ -165,7 +164,7 @@ suite('Disabling', function () {
|
|||||||
);
|
);
|
||||||
await connect(this.browser, child, 'PREVIOUS', parent, 'DO0');
|
await connect(this.browser, child, 'PREVIOUS', parent, 'DO0');
|
||||||
|
|
||||||
await contextMenuSelect(this.browser, parent, 'Disable Block');
|
await contextMenuSelect(this.browser, parent.id, 'Disable Block');
|
||||||
|
|
||||||
chai.assert.isTrue(await getIsDisabled(this.browser, child.id));
|
chai.assert.isTrue(await getIsDisabled(this.browser, child.id));
|
||||||
},
|
},
|
||||||
@@ -191,7 +190,7 @@ suite('Disabling', function () {
|
|||||||
);
|
);
|
||||||
await connect(this.browser, child, 'PREVIOUS', parent, 'NEXT');
|
await connect(this.browser, child, 'PREVIOUS', parent, 'NEXT');
|
||||||
|
|
||||||
await contextMenuSelect(this.browser, parent, 'Disable Block');
|
await contextMenuSelect(this.browser, parent.id, 'Disable Block');
|
||||||
|
|
||||||
chai.assert.isFalse(await getIsDisabled(this.browser, child.id));
|
chai.assert.isFalse(await getIsDisabled(this.browser, child.id));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ suite('Delete blocks', function (done) {
|
|||||||
const before = (await getAllBlocks(this.browser)).length;
|
const before = (await getAllBlocks(this.browser)).length;
|
||||||
// Get first print block, click to select it, and delete it using context menu.
|
// Get first print block, click to select it, and delete it using context menu.
|
||||||
const block = await getBlockElementById(this.browser, firstBlockId);
|
const block = await getBlockElementById(this.browser, firstBlockId);
|
||||||
await contextMenuSelect(this.browser, block, 'Delete 2 Blocks');
|
await contextMenuSelect(this.browser, block.id, 'Delete 2 Blocks');
|
||||||
const after = (await getAllBlocks(this.browser)).length;
|
const after = (await getAllBlocks(this.browser)).length;
|
||||||
chai.assert.equal(
|
chai.assert.equal(
|
||||||
before - 2,
|
before - 2,
|
||||||
|
|||||||
@@ -460,13 +460,13 @@ async function dragBlockFromMutatorFlyout(browser, mutatorBlock, type, x, y) {
|
|||||||
* context menu item.
|
* context menu item.
|
||||||
*
|
*
|
||||||
* @param browser The active WebdriverIO Browser object.
|
* @param browser The active WebdriverIO Browser object.
|
||||||
* @param block The block to click, as an interactable element. This block must
|
* @param blockId The ID of the block to click. This block should
|
||||||
* have text on it, because we use the text element as the click target.
|
* have text on it, because we use the text element as the click target.
|
||||||
* @param itemText The display text of the context menu item to click.
|
* @param itemText The display text of the context menu item to click.
|
||||||
* @return A Promise that resolves when the actions are completed.
|
* @return A Promise that resolves when the actions are completed.
|
||||||
*/
|
*/
|
||||||
async function contextMenuSelect(browser, block, itemText) {
|
async function contextMenuSelect(browser, blockId, itemText) {
|
||||||
const clickEl = await getClickableBlockElementById(browser, block.id);
|
const clickEl = await getClickableBlockElementById(browser, blockId);
|
||||||
// Even though the element should definitely already exist,
|
// Even though the element should definitely already exist,
|
||||||
// one specific test breaks if you remove this...
|
// one specific test breaks if you remove this...
|
||||||
await clickEl.waitForExist();
|
await clickEl.waitForExist();
|
||||||
|
|||||||
Reference in New Issue
Block a user