Skip to content
Snippets Groups Projects
Commit 2d56c816 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Update tests to include reporter clicking and variable clicking.

parent c8f04c09
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ class SeleniumHelper {
'clickText',
'clickButton',
'clickXpath',
'findByText',
'findByXpath',
'getDriver',
'getLogs'
......@@ -29,12 +30,16 @@ class SeleniumHelper {
return this.driver.wait(until.elementLocated(By.xpath(xpath), 5 * 1000));
}
findByText (text, scope) {
return this.findByXpath(`//body//${scope || '*'}//*[contains(text(), '${text}')]`);
}
clickXpath (xpath) {
return this.findByXpath(xpath).then(el => el.click());
}
clickText (text, scope) {
return this.clickXpath(`//body//${scope || '*'}//*[contains(text(), '${text}')]`);
return this.findByText(text, scope).then(el => el.click());
}
clickButton (text) {
......
......@@ -5,6 +5,7 @@ const {
clickText,
clickButton,
clickXpath,
findByText,
findByXpath,
getDriver,
getLogs
......@@ -21,6 +22,7 @@ let driver;
const blocksTabScope = "*[@id='react-tabs-1']";
const costumesTabScope = "*[@id='react-tabs-3']";
const soundsTabScope = "*[@id='react-tabs-5']";
const reportedValueScope = '*[@class="blocklyDropDownContent"]';
describe('costumes, sounds and variables', () => {
beforeAll(() => {
......@@ -31,6 +33,18 @@ describe('costumes, sounds and variables', () => {
await driver.quit();
});
test('Blocks report when clicked in the toolbox', async () => {
await driver.get(`file://${uri}`);
await clickText('Blocks');
await clickText('Operators', blocksTabScope);
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for scroll animation
await clickText('join', blocksTabScope); // Click "join <hello> <world>" block
await findByText('helloworld', reportedValueScope); // Tooltip with result
const logs = await getLogs(errorWhitelist);
await expect(logs).toEqual([]);
});
test('Adding a costume', async () => {
await driver.get(`file://${uri}`);
await clickText('Costumes');
......@@ -93,6 +107,13 @@ describe('costumes, sounds and variables', () => {
el = await findByXpath("//input[@placeholder='']");
await el.sendKeys('second variable');
await clickButton('OK');
// Make sure reporting works on a new variable
await clickText('Data', blocksTabScope);
await new Promise(resolve => setTimeout(resolve, 1000)); // Wait for scroll animation
await clickText('score', blocksTabScope);
await findByText('0', reportedValueScope); // Tooltip with result
const logs = await getLogs(errorWhitelist);
await expect(logs).toEqual([]);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment