Files
blockly/tests/browser/test/block_undo_test.js
Rachel Fenichel 8241fca23f chore(tests): cleanup and toolbox drag tests (#7350)
* chore(tests): use helpers for the basic drag test in the playground

* chore(tests): miscellaneous test cleanup

* chore: format

* feat(tests): add test that drags out every block from the toolbox

* feat(tests): add RTL version of toolbox drag tests

* chore: lint

* chore(tests): respond to PR feedback
2023-08-03 00:31:51 +00:00

51 lines
1.3 KiB
JavaScript

/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Node.js script to run Automated tests in Chrome, via webdriver.
*/
const chai = require('chai');
const {Key} = require('webdriverio');
const {
testSetup,
testFileLocations,
dragBlockTypeFromFlyout,
screenDirection,
getAllBlocks,
} = require('./test_setup');
suite('Testing undo block movement', function (done) {
// Setting timeout to unlimited as the webdriver takes a longer time to run than most mocha test
this.timeout(0);
test('Undoing Block Movement LTR', async function () {
this.browser = await testSetup(testFileLocations.PLAYGROUND);
await testUndoBlock(this.browser, screenDirection.LTR);
});
test('Undoing Block Movement RTL', async function () {
this.browser = await testSetup(testFileLocations.PLAYGROUND_RTL);
await testUndoBlock(this.browser, screenDirection.RTL);
});
});
async function testUndoBlock(browser, direction) {
// Drag out first function
await dragBlockTypeFromFlyout(
browser,
'Functions',
'procedures_defreturn',
50 * direction,
20,
);
await browser.keys([Key.Ctrl, 'z']);
const allBlocks = await getAllBlocks(browser);
chai.assert.equal(allBlocks.length, 0);
}