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

Wait until loader becomes stale to continue in project loader tests

parent 1f2f41b5
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,8 @@ class SeleniumHelper { ...@@ -21,7 +21,8 @@ class SeleniumHelper {
'getSauceDriver', 'getSauceDriver',
'getLogs', 'getLogs',
'loadUri', 'loadUri',
'rightClickText' 'rightClickText',
'waitUntilGone'
]); ]);
} }
...@@ -119,6 +120,10 @@ class SeleniumHelper { ...@@ -119,6 +120,10 @@ class SeleniumHelper {
return this.clickXpath(`//button//*[contains(text(), '${text}')]`); return this.clickXpath(`//button//*[contains(text(), '${text}')]`);
} }
waitUntilGone (element) {
return this.driver.wait(until.stalenessOf(element));
}
getLogs (whitelist) { getLogs (whitelist) {
if (!whitelist) { if (!whitelist) {
// Default whitelist // Default whitelist
......
...@@ -4,11 +4,13 @@ import SeleniumHelper from '../helpers/selenium-helper'; ...@@ -4,11 +4,13 @@ import SeleniumHelper from '../helpers/selenium-helper';
const { const {
clickText, clickText,
clickXpath, clickXpath,
findByText,
findByXpath, findByXpath,
getDriver, getDriver,
getLogs, getLogs,
loadUri, loadUri,
scope scope,
waitUntilGone
} = new SeleniumHelper(); } = new SeleniumHelper();
const uri = path.resolve(__dirname, '../../build/index.html'); const uri = path.resolve(__dirname, '../../build/index.html');
...@@ -40,7 +42,7 @@ describe('Loading scratch gui', () => { ...@@ -40,7 +42,7 @@ describe('Loading scratch gui', () => {
const projectId = '96708228'; const projectId = '96708228';
await el.sendKeys(`scratch.mit.edu/projects/${projectId}`); await el.sendKeys(`scratch.mit.edu/projects/${projectId}`);
await clickXpath('//button[@title="View Project"]'); await clickXpath('//button[@title="View Project"]');
await new Promise(resolve => setTimeout(resolve, 2000)); await waitUntilGone(findByText('Loading'));
await clickXpath('//img[@title="Go"]'); await clickXpath('//img[@title="Go"]');
await new Promise(resolve => setTimeout(resolve, 2000)); await new Promise(resolve => setTimeout(resolve, 2000));
await clickXpath('//img[@title="Stop"]'); await clickXpath('//img[@title="Stop"]');
...@@ -63,7 +65,7 @@ describe('Loading scratch gui', () => { ...@@ -63,7 +65,7 @@ describe('Loading scratch gui', () => {
await el.clear(); await el.clear();
await el.sendKeys('scratch.mit.edu/projects/96708228'); await el.sendKeys('scratch.mit.edu/projects/96708228');
await clickXpath('//button[@title="View Project"]'); await clickXpath('//button[@title="View Project"]');
await new Promise(resolve => setTimeout(resolve, 2000)); await waitUntilGone(findByText('Loading'));
await clickXpath('//img[@title="Go"]'); await clickXpath('//img[@title="Go"]');
await new Promise(resolve => setTimeout(resolve, 2000)); await new Promise(resolve => setTimeout(resolve, 2000));
await clickXpath('//img[@title="Stop"]'); await clickXpath('//img[@title="Stop"]');
...@@ -77,7 +79,7 @@ describe('Loading scratch gui', () => { ...@@ -77,7 +79,7 @@ describe('Loading scratch gui', () => {
const projectId = '96708228'; const projectId = '96708228';
await loadUri(`${uri}#${projectId}`); await loadUri(`${uri}#${projectId}`);
await new Promise(resolve => setTimeout(resolve, 3000)); await waitUntilGone(findByText('Loading'));
await clickXpath('//img[@title="Go"]'); await clickXpath('//img[@title="Go"]');
await new Promise(resolve => setTimeout(resolve, 2000)); await new Promise(resolve => setTimeout(resolve, 2000));
await clickXpath('//img[@title="Stop"]'); await clickXpath('//img[@title="Stop"]');
...@@ -98,7 +100,7 @@ describe('Loading scratch gui', () => { ...@@ -98,7 +100,7 @@ describe('Loading scratch gui', () => {
.setSize(1920, 1080); .setSize(1920, 1080);
const projectId = '96708228'; const projectId = '96708228';
await loadUri(`${uri}#${projectId}`); await loadUri(`${uri}#${projectId}`);
await new Promise(resolve => setTimeout(resolve, 2000)); await waitUntilGone(findByText('Loading'));
await clickXpath('//img[@title="Full Screen Control"]'); await clickXpath('//img[@title="Full Screen Control"]');
await clickXpath('//img[@title="Go"]'); await clickXpath('//img[@title="Go"]');
await new Promise(resolve => setTimeout(resolve, 2000)); await new Promise(resolve => setTimeout(resolve, 2000));
...@@ -119,7 +121,7 @@ describe('Loading scratch gui', () => { ...@@ -119,7 +121,7 @@ describe('Loading scratch gui', () => {
const projectId = '96708228'; const projectId = '96708228';
await inputElement.sendKeys(`scratch.mit.edu/projects/${projectId}`); await inputElement.sendKeys(`scratch.mit.edu/projects/${projectId}`);
await clickXpath('//button[@title="View Project"]'); await clickXpath('//button[@title="View Project"]');
await new Promise(resolve => setTimeout(resolve, 2000)); await waitUntilGone(findByText('Loading'));
await findByXpath('//*[span[text()="Costumes"]]'); await findByXpath('//*[span[text()="Costumes"]]');
await clickText('Costumes'); await clickText('Costumes');
await clickXpath( await clickXpath(
...@@ -138,7 +140,7 @@ describe('Loading scratch gui', () => { ...@@ -138,7 +140,7 @@ describe('Loading scratch gui', () => {
const projectId = '96708228'; const projectId = '96708228';
await inputElement.sendKeys(`scratch.mit.edu/projects/${projectId}`); await inputElement.sendKeys(`scratch.mit.edu/projects/${projectId}`);
await clickXpath('//button[@title="View Project"]'); await clickXpath('//button[@title="View Project"]');
await new Promise(resolve => setTimeout(resolve, 2000)); await waitUntilGone(findByText('Loading'));
await clickXpath( await clickXpath(
'//div[contains(@class, "menu-bar_menu-bar-item") and ' + '//div[contains(@class, "menu-bar_menu-bar-item") and ' +
'contains(@class, "menu-bar_hoverable")][span[text()="File"]]' 'contains(@class, "menu-bar_hoverable")][span[text()="File"]]'
...@@ -155,7 +157,7 @@ describe('Loading scratch gui', () => { ...@@ -155,7 +157,7 @@ describe('Loading scratch gui', () => {
const projectId = '96708228'; const projectId = '96708228';
await inputElement.sendKeys(`scratch.mit.edu/projects/${projectId}`); await inputElement.sendKeys(`scratch.mit.edu/projects/${projectId}`);
await clickXpath('//button[@title="View Project"]'); await clickXpath('//button[@title="View Project"]');
await new Promise(resolve => setTimeout(resolve, 2000)); await waitUntilGone(findByText('Loading'));
await clickText('Sounds'); await clickText('Sounds');
await clickXpath('//button[@aria-label="Choose a Sound"]'); await clickXpath('//button[@aria-label="Choose a Sound"]');
await clickText('A Bass', scope.modal); // Should close the modal await clickText('A Bass', scope.modal); // Should close the modal
......
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