mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-03-22 19:05:56 -04:00
test: use navigate() instead of driver.get()
This commit is contained in:
parent
a0d8129356
commit
c9f67c06cf
10 changed files with 77 additions and 66 deletions
|
@ -8,6 +8,7 @@ const {
|
|||
clickXpath,
|
||||
containsClass,
|
||||
findByXpath,
|
||||
navigate,
|
||||
signIn
|
||||
} = new SeleniumHelper();
|
||||
|
||||
|
@ -48,7 +49,7 @@ let driver;
|
|||
describe('comment tests', () => {
|
||||
beforeAll(async () => {
|
||||
driver = await buildDriver('www-integration project comments');
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
});
|
||||
|
||||
afterAll(() => driver.quit());
|
||||
|
@ -60,13 +61,13 @@ describe('comment tests', () => {
|
|||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
await clickXpath('//a[contains(@class, "user-info")]');
|
||||
await clickText('Sign out');
|
||||
});
|
||||
|
||||
test('leave comment on project', async () => {
|
||||
await driver.get(projectUrl);
|
||||
await navigate(projectUrl);
|
||||
|
||||
// leave the comment
|
||||
const commentBox = await findByXpath('//textArea[@name="compose-comment"]');
|
||||
|
@ -82,7 +83,7 @@ describe('comment tests', () => {
|
|||
});
|
||||
|
||||
test('leave comment on a profile', async () => {
|
||||
await driver.get(profileUrl);
|
||||
await navigate(profileUrl);
|
||||
|
||||
// leave the comment
|
||||
const commentXpath = '//form[@id="main-post-form"]/div/textArea';
|
||||
|
@ -97,11 +98,11 @@ describe('comment tests', () => {
|
|||
expect(commentVisible).toBe(true);
|
||||
|
||||
// return to homepage to sign out with www
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
});
|
||||
|
||||
test('leave comment on studio', async () => {
|
||||
await driver.get(studioUrl);
|
||||
await navigate(studioUrl);
|
||||
|
||||
// leave the comment
|
||||
const commentBox = await findByXpath('//textArea[@name="compose-comment"]');
|
||||
|
@ -138,7 +139,7 @@ describe('comment tests', () => {
|
|||
});
|
||||
|
||||
test('project comment message visible', async () => {
|
||||
await driver.get(`${rootUrl}/messages`);
|
||||
await navigate(`${rootUrl}/messages`);
|
||||
|
||||
const projectMessageXpath = '//p[@class="emoji-text mod-comment" ' +
|
||||
`and contains(text(), "${projectComment}")]`;
|
||||
|
@ -148,7 +149,7 @@ describe('comment tests', () => {
|
|||
});
|
||||
|
||||
test('profile comment message visible', async () => {
|
||||
await driver.get(`${rootUrl}/messages`);
|
||||
await navigate(`${rootUrl}/messages`);
|
||||
|
||||
const profileMessageXpath = '//p[@class="emoji-text mod-comment" ' +
|
||||
`and contains(text(), "${profileComment}")]`;
|
||||
|
@ -163,7 +164,7 @@ describe('comment tests', () => {
|
|||
const projectLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
||||
`and contains(text(), "${projectComment}")]/../../../p[@class = "comment-message-info"]/span/a[2]`;
|
||||
|
||||
await driver.get(`${rootUrl}/messages`);
|
||||
await navigate(`${rootUrl}/messages`);
|
||||
await clickXpath(projectLinkXpath);
|
||||
|
||||
// find green flag overlay
|
||||
|
@ -175,7 +176,7 @@ describe('comment tests', () => {
|
|||
const projectLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
||||
`and contains(text(), "${projectComment}")]/../../../p[@class = "comment-message-info"]/span/a[2]`;
|
||||
|
||||
await driver.get(`${rootUrl}/messages`);
|
||||
await navigate(`${rootUrl}/messages`);
|
||||
await clickXpath(projectLinkXpath);
|
||||
|
||||
const commentXpath = `//span[contains(text(), "${projectComment}")]`;
|
||||
|
@ -189,7 +190,7 @@ describe('comment tests', () => {
|
|||
`and contains(text(), "${projectComment}")]/../../../p[@class = "comment-message-info"]/span/a[2]`;
|
||||
const containerXpath = `//span[contains(text(), "${projectComment}")]/../../../..`;
|
||||
|
||||
await driver.get(`${rootUrl}/messages`);
|
||||
await navigate(`${rootUrl}/messages`);
|
||||
await clickXpath(projectLinkXpath);
|
||||
|
||||
const commentContainer = await findByXpath(containerXpath);
|
||||
|
@ -201,7 +202,7 @@ describe('comment tests', () => {
|
|||
const profileLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
||||
`and contains(text(), "${profileComment}")]/../../../` +
|
||||
'p[@class = "comment-message-info"]/span/a[2]';
|
||||
await driver.get(`${rootUrl}/messages`);
|
||||
await navigate(`${rootUrl}/messages`);
|
||||
await clickXpath(profileLinkXpath);
|
||||
|
||||
// find profile data
|
||||
|
@ -218,7 +219,7 @@ describe('comment tests', () => {
|
|||
const profileLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
||||
`and contains(text(), "${profileComment}")]/../../../` +
|
||||
'p[@class = "comment-message-info"]/span/a[2]';
|
||||
await driver.get(`${rootUrl}/messages`);
|
||||
await navigate(`${rootUrl}/messages`);
|
||||
await clickXpath(profileLinkXpath);
|
||||
|
||||
// find comment
|
||||
|
@ -233,7 +234,7 @@ describe('comment tests', () => {
|
|||
const profileLinkXpath = '//p[@class="emoji-text mod-comment" ' +
|
||||
`and contains(text(), "${profileComment}")]/../../../` +
|
||||
'p[@class = "comment-message-info"]/span/a[2]';
|
||||
await driver.get(`${rootUrl}/messages`);
|
||||
await navigate(`${rootUrl}/messages`);
|
||||
await clickXpath(profileLinkXpath);
|
||||
|
||||
// comment highlighted?
|
||||
|
@ -244,7 +245,7 @@ describe('comment tests', () => {
|
|||
});
|
||||
|
||||
test('project: reply to comment', async () => {
|
||||
await driver.get(projectUrl);
|
||||
await navigate(projectUrl);
|
||||
const commentXpath = `//span[contains(text(), "${projectComment}")]/../..`;
|
||||
const replyXpath = `${commentXpath}//span[@class = "comment-reply"]`;
|
||||
await clickXpath(replyXpath);
|
||||
|
@ -264,7 +265,7 @@ describe('comment tests', () => {
|
|||
});
|
||||
|
||||
test('profile reply to comment', async () => {
|
||||
await driver.get(profileUrl);
|
||||
await navigate(profileUrl);
|
||||
// find the comment and click reply
|
||||
const commentXpath = `//div[contains(text(), "${profileComment}")]/..`;
|
||||
await clickXpath(`${commentXpath}//a[@class = "reply"]`);
|
||||
|
@ -281,7 +282,7 @@ describe('comment tests', () => {
|
|||
});
|
||||
|
||||
test('studio: reply to comment', async () => {
|
||||
await driver.get(studioUrl);
|
||||
await navigate(studioUrl);
|
||||
|
||||
// find the comment and click reply
|
||||
const commentXpath = `//span[contains(text(), "${studioComment}")]/../..`;
|
||||
|
|
|
@ -6,6 +6,7 @@ const {
|
|||
clickText,
|
||||
buildDriver,
|
||||
findText,
|
||||
navigate,
|
||||
waitUntilDocumentReady
|
||||
} = new SeleniumHelper();
|
||||
|
||||
|
@ -21,7 +22,7 @@ describe('www-integration footer links', () => {
|
|||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
await findText('Create stories, games, and animations');
|
||||
});
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ let driver;
|
|||
describe('www-integration project rows', () => {
|
||||
beforeAll(async () => {
|
||||
driver = await buildDriver('www-integration project rows');
|
||||
// driver.get(rootUrl);
|
||||
// navigate(rootUrl);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
|
|
|
@ -7,9 +7,10 @@ const {
|
|||
clickText,
|
||||
clickXpath,
|
||||
findByXpath,
|
||||
navigate,
|
||||
signIn,
|
||||
waitUntilDocumentReady,
|
||||
urlMatches
|
||||
urlMatches,
|
||||
waitUntilDocumentReady
|
||||
} = new SeleniumHelper();
|
||||
|
||||
const username = `${process.env.SMOKE_USERNAME}1`;
|
||||
|
@ -26,7 +27,7 @@ let driver;
|
|||
describe('www-integration my_stuff', () => {
|
||||
beforeAll(async () => {
|
||||
driver = await buildDriver('www-integration my_stuff');
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
await signIn(username, password);
|
||||
await findByXpath('//span[contains(@class, "profile-name")]');
|
||||
});
|
||||
|
@ -34,7 +35,7 @@ describe('www-integration my_stuff', () => {
|
|||
afterAll(() => driver.quit());
|
||||
|
||||
test('verify My Stuff structure (tabs, title)', async () => {
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
const header = await findByXpath('//div[@class="box-head"]/h2');
|
||||
const headerVisible = await header.isDisplayed();
|
||||
expect(headerVisible).toBe(true);
|
||||
|
@ -56,7 +57,7 @@ describe('www-integration my_stuff', () => {
|
|||
});
|
||||
|
||||
test('clicking a project title should take you to the project page', async () => {
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//span[@class="media-info-item title"]');
|
||||
await waitUntilDocumentReady();
|
||||
const gui = await findByXpath('//div[@class="guiPlayer"]');
|
||||
|
@ -65,7 +66,7 @@ describe('www-integration my_stuff', () => {
|
|||
});
|
||||
|
||||
test('clicking "see inside" should take you to the editor', async () => {
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//a[@data-control="edit"]');
|
||||
await waitUntilDocumentReady();
|
||||
const gf = await findByXpath('//img[@class="green-flag_green-flag_1kiAo"]');
|
||||
|
@ -74,7 +75,7 @@ describe('www-integration my_stuff', () => {
|
|||
});
|
||||
|
||||
test('Add To button should bring up a list of studios', async () => {
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//div[@id="sidebar"]/ul/li[@data-tab="shared"]');
|
||||
await clickXpath('//div[@data-control="add-to"]');
|
||||
const dropDown = await findByXpath('//div[@class="dropdown-menu"]/ul/li');
|
||||
|
@ -83,7 +84,7 @@ describe('www-integration my_stuff', () => {
|
|||
});
|
||||
|
||||
test('+ New Project button should open the editor', async () => {
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickText('+ New Project');
|
||||
await waitUntilDocumentReady();
|
||||
const gf = await findByXpath('//img[@class="green-flag_green-flag_1kiAo"]');
|
||||
|
@ -92,8 +93,8 @@ describe('www-integration my_stuff', () => {
|
|||
});
|
||||
|
||||
test('+ New Studio button should take you to the studio page', async () => {
|
||||
await driver.get(rateLimitCheck);
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(rateLimitCheck);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
|
||||
await waitUntilDocumentReady();
|
||||
const tabs = await findByXpath('//div[@class="studio-tabs"]');
|
||||
|
@ -102,34 +103,34 @@ describe('www-integration my_stuff', () => {
|
|||
});
|
||||
|
||||
test('New studio rate limited to five', async () => {
|
||||
await driver.get(rateLimitCheck);
|
||||
await navigate(rateLimitCheck);
|
||||
// 1st studio
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
|
||||
await urlMatches(/\/studios\//);
|
||||
// 2nd studio
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
|
||||
await urlMatches(/\/studios\//);
|
||||
// 3rd studio
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
|
||||
await urlMatches(/\/studios\//);
|
||||
// 4th studio
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
|
||||
await urlMatches(/\/studios\//);
|
||||
// 5th studio
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
|
||||
await urlMatches(/\/studios\//);
|
||||
// 6th studio should fail
|
||||
await driver.get(myStuffURL);
|
||||
await navigate(myStuffURL);
|
||||
await clickXpath('//form[@id="new_studio"]/button[@type="submit"]');
|
||||
const alertMessage = await findByXpath('//div[contains(@class, "alert-error")]');
|
||||
const errVisible = await alertMessage.isDisplayed();
|
||||
expect(errVisible).toBe(true);
|
||||
|
||||
await driver.get(rateLimitCheck);
|
||||
await navigate(rateLimitCheck);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,8 +4,9 @@ const SeleniumHelper = require('./selenium-helpers.js');
|
|||
|
||||
const {
|
||||
clickXpath,
|
||||
buildDriver,
|
||||
findByXpath,
|
||||
buildDriver
|
||||
navigate
|
||||
} = new SeleniumHelper();
|
||||
|
||||
const rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
||||
|
@ -20,7 +21,7 @@ describe('www-integration navbar links', () => {
|
|||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
});
|
||||
|
||||
afterAll(() => driver.quit());
|
||||
|
|
|
@ -14,6 +14,7 @@ const {
|
|||
findByXpath,
|
||||
isSignedIn,
|
||||
signIn,
|
||||
navigate,
|
||||
waitUntilVisible
|
||||
} = new SeleniumHelper();
|
||||
|
||||
|
@ -54,11 +55,11 @@ describe('www-integration project-page signed out', () => {
|
|||
beforeAll(async () => {
|
||||
// expect(projectUrl).toBe(defined);
|
||||
driver = await buildDriver('www-integration project-page signed out');
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await driver.get(unownedSharedUrl);
|
||||
await navigate(unownedSharedUrl);
|
||||
const gfOverlay = await findByXpath('//div[@class="stage-wrapper_stage-wrapper_2bejr box_box_2jjDp"]');
|
||||
await waitUntilVisible(gfOverlay, driver);
|
||||
});
|
||||
|
@ -105,7 +106,7 @@ describe('www-integration project-page signed out', () => {
|
|||
|
||||
// Load an unshared project while signed out, get error
|
||||
test('Load an ushared project you do not own (error)', async () => {
|
||||
await driver.get(unownedUnsharedUrl);
|
||||
await navigate(unownedUnsharedUrl);
|
||||
const unavailableImage = await findByXpath('//img[@class="not-available-image"]');
|
||||
await waitUntilVisible(unavailableImage, driver);
|
||||
const unavailableVisible = await unavailableImage.isDisplayed();
|
||||
|
@ -123,7 +124,7 @@ describe('www-integration project-page signed in', () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
// The browser may or may not retain cookies between tests, depending on configuration.
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
if (!await isSignedIn()) {
|
||||
await signIn(username, password);
|
||||
}
|
||||
|
@ -135,7 +136,7 @@ describe('www-integration project-page signed in', () => {
|
|||
|
||||
// Load a shared project you own
|
||||
test('Load a shared project you own', async () => {
|
||||
await driver.get(ownedSharedUrl);
|
||||
await navigate(ownedSharedUrl);
|
||||
const gfOverlay = await findByXpath('//div[@class="stage-wrapper_stage-wrapper_2bejr box_box_2jjDp"]');
|
||||
await waitUntilVisible(gfOverlay, driver);
|
||||
const gfVisible = await gfOverlay.isDisplayed();
|
||||
|
@ -144,7 +145,7 @@ describe('www-integration project-page signed in', () => {
|
|||
|
||||
// Load a shared project you don't own
|
||||
test('Load a shared project you do not own', async () => {
|
||||
await driver.get(unownedSharedUrl);
|
||||
await navigate(unownedSharedUrl);
|
||||
const gfOverlay = await findByXpath('//div[@class="stage-wrapper_stage-wrapper_2bejr box_box_2jjDp"]');
|
||||
await waitUntilVisible(gfOverlay, driver);
|
||||
const gfVisible = await gfOverlay.isDisplayed();
|
||||
|
@ -153,7 +154,7 @@ describe('www-integration project-page signed in', () => {
|
|||
|
||||
// Load an unshared project you own
|
||||
test('Load an unshared project you own', async () => {
|
||||
await driver.get(ownedUnsharedUrl);
|
||||
await navigate(ownedUnsharedUrl);
|
||||
const gfOverlay = await findByXpath('//div[@class="stage-wrapper_stage-wrapper_2bejr box_box_2jjDp"]');
|
||||
await waitUntilVisible(gfOverlay, driver);
|
||||
const gfVisible = await gfOverlay.isDisplayed();
|
||||
|
@ -162,7 +163,7 @@ describe('www-integration project-page signed in', () => {
|
|||
|
||||
// Load an unshared project you don't own, get error
|
||||
test('Load an ushared project you do not own (error)', async () => {
|
||||
await driver.get(unownedUnsharedUrl);
|
||||
await navigate(unownedUnsharedUrl);
|
||||
const unavailableImage = await findByXpath('//img[@class="not-available-image"]');
|
||||
await waitUntilVisible(unavailableImage, driver);
|
||||
const unavailableVisible = await unavailableImage.isDisplayed();
|
||||
|
@ -171,7 +172,7 @@ describe('www-integration project-page signed in', () => {
|
|||
|
||||
// Load a shared scratch 2 project you don't own
|
||||
test('Load a shared scratch 2 project you do not own', async () => {
|
||||
await driver.get(unownedSharedScratch2Url);
|
||||
await navigate(unownedSharedScratch2Url);
|
||||
const gfOverlay = await findByXpath('//div[@class="stage-wrapper_stage-wrapper_2bejr box_box_2jjDp"]');
|
||||
await waitUntilVisible(gfOverlay, driver);
|
||||
const gfVisible = await gfOverlay.isDisplayed();
|
||||
|
@ -180,7 +181,7 @@ describe('www-integration project-page signed in', () => {
|
|||
|
||||
// Load an unshared scratch 2 project you own
|
||||
test('Load an unshared scratch 2 project you own', async () => {
|
||||
await driver.get(ownedUnsharedScratch2Url);
|
||||
await navigate(ownedUnsharedScratch2Url);
|
||||
const gfOverlay = await findByXpath('//div[@class="stage-wrapper_stage-wrapper_2bejr box_box_2jjDp"]');
|
||||
await waitUntilVisible(gfOverlay, driver);
|
||||
const gfVisible = await gfOverlay.isDisplayed();
|
||||
|
@ -195,7 +196,7 @@ describe('www-integration project-creation signed in', () => {
|
|||
// SauceLabs doesn't have access to the sb3 used in 'load project from file' test
|
||||
// https://support.saucelabs.com/hc/en-us/articles/115003685593-Uploading-Files-to-a-Sauce-Labs-Virtual-Machine-during-a-Test
|
||||
if (remote) {
|
||||
await driver.get('https://github.com/scratchfoundation/scratch-www/blob/develop/test/fixtures/project1.sb3');
|
||||
await navigate('https://github.com/scratchfoundation/scratch-www/blob/develop/test/fixtures/project1.sb3');
|
||||
await clickXpath('//button[@data-testid="download-raw-button"]');
|
||||
await driver.sleep(3000);
|
||||
}
|
||||
|
@ -203,7 +204,7 @@ describe('www-integration project-creation signed in', () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
// The browser may or may not retain cookies between tests, depending on configuration.
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
if (!await isSignedIn()) {
|
||||
await signIn(username, password);
|
||||
}
|
||||
|
@ -212,7 +213,7 @@ describe('www-integration project-creation signed in', () => {
|
|||
afterAll(() => driver.quit());
|
||||
|
||||
test('make a copy of a project', async () => {
|
||||
await driver.get(`${ownedUnsharedUrl}/editor`);
|
||||
await navigate(`${ownedUnsharedUrl}/editor`);
|
||||
await clickXpath(FILE_MENU_XPATH);
|
||||
await clickText('Save as a copy');
|
||||
const successAlert = await findText('Project saved as a copy.');
|
||||
|
@ -225,7 +226,7 @@ describe('www-integration project-creation signed in', () => {
|
|||
});
|
||||
|
||||
test('remix a project', async () => {
|
||||
await driver.get(unownedSharedUrl);
|
||||
await navigate(unownedSharedUrl);
|
||||
const gfOverlay = await findByXpath('//div[@class="stage-wrapper_stage-wrapper_2bejr box_box_2jjDp"]');
|
||||
await waitUntilVisible(gfOverlay, driver);
|
||||
await clickXpath('//button[@class="button remix-button"]');
|
||||
|
|
|
@ -6,7 +6,8 @@ const {
|
|||
buildDriver,
|
||||
clickXpath,
|
||||
findByXpath,
|
||||
getKey
|
||||
getKey,
|
||||
navigate
|
||||
} = new SeleniumHelper();
|
||||
|
||||
const rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
||||
|
@ -21,7 +22,7 @@ describe('www-integration search', () => {
|
|||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await driver.get(rootUrl);
|
||||
await navigate(rootUrl);
|
||||
});
|
||||
|
||||
afterAll(() => driver.quit());
|
||||
|
|
|
@ -266,7 +266,10 @@ class SeleniumHelper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Navigate to the given URL and wait until the document is ready
|
||||
* Navigate to the given URL and wait until the document is ready.
|
||||
* The Selenium docs say the promise returned by `driver.get()` "will be resolved when the document has finished
|
||||
* loading." In practice, that doesn't mean the page is ready for testing. I suspect it comes down to the
|
||||
* difference between "interactive" and "complete" (or `DOMContentLoaded` and `load`).
|
||||
* @param {string} url The URL to navigate to.
|
||||
* @returns {Promise} A promise that resolves when the document is ready
|
||||
*/
|
||||
|
|
|
@ -9,6 +9,7 @@ const {
|
|||
clickXpath,
|
||||
findByXpath,
|
||||
getKey,
|
||||
navigate,
|
||||
signIn,
|
||||
waitUntilVisible
|
||||
} = new SeleniumHelper();
|
||||
|
@ -34,13 +35,13 @@ describe('www-integration sign-in-and-out', () => {
|
|||
|
||||
describe('sign in', () => {
|
||||
afterEach(async () => {
|
||||
await driver.get(wwwURL);
|
||||
await navigate(wwwURL);
|
||||
await clickXpath('//div[@class="account-nav"]');
|
||||
await clickText('Sign out');
|
||||
});
|
||||
|
||||
test('sign in on www', async () => {
|
||||
await driver.get(wwwURL);
|
||||
await navigate(wwwURL);
|
||||
await driver.sleep(1000);
|
||||
await clickXpath('//li[@class="link right login-item"]/a');
|
||||
const name = await findByXpath('//input[@id="frc-username-1088"]');
|
||||
|
@ -57,7 +58,7 @@ describe('www-integration sign-in-and-out', () => {
|
|||
});
|
||||
|
||||
test('sign in on scratchr2', async () => {
|
||||
await driver.get(scratchr2url);
|
||||
await navigate(scratchr2url);
|
||||
await clickXpath('//li[@class="sign-in dropdown"]/span');
|
||||
const name = await findByXpath('//input[@id="login_dropdown_username"]');
|
||||
await name.sendKeys(username);
|
||||
|
@ -72,7 +73,7 @@ describe('www-integration sign-in-and-out', () => {
|
|||
|
||||
describe('sign out', () => {
|
||||
beforeEach(async () => {
|
||||
await driver.get(wwwURL);
|
||||
await navigate(wwwURL);
|
||||
await signIn(username, password);
|
||||
await driver.sleep(500);
|
||||
});
|
||||
|
@ -86,7 +87,7 @@ describe('www-integration sign-in-and-out', () => {
|
|||
});
|
||||
|
||||
test('sign out on scratchr2', async () => {
|
||||
await driver.get(scratchr2url);
|
||||
await navigate(scratchr2url);
|
||||
await clickXpath('//span[@class="user-name dropdown-toggle"]');
|
||||
await clickXpath('//li[@id="logout"]');
|
||||
const element = await findByXpath('//li[@class="link right login-item"]/a/span');
|
||||
|
@ -101,7 +102,7 @@ describe('www-integration sign-in-and-out', () => {
|
|||
const nonsenseUsername = Math.random().toString(36)
|
||||
.replace(/[^a-z]+/g, '')
|
||||
.substr(0, 5);
|
||||
await driver.get(scratchr2url);
|
||||
await navigate(scratchr2url);
|
||||
await clickXpath('//li[@class="sign-in dropdown"]/span');
|
||||
const name = await findByXpath('//input[@id="login_dropdown_username"]');
|
||||
await name.sendKeys(nonsenseUsername + getKey('ENTER'));
|
||||
|
@ -117,7 +118,7 @@ describe('www-integration sign-in-and-out', () => {
|
|||
const nonsenseUsername = Math.random().toString(36)
|
||||
.replace(/[^a-z]+/g, '')
|
||||
.substr(0, 5);
|
||||
await driver.get(scratchr2url);
|
||||
await navigate(scratchr2url);
|
||||
await clickXpath('//li[@class="sign-in dropdown"]/span');
|
||||
const name = await findByXpath('//input[@id="login_dropdown_username"]');
|
||||
await name.sendKeys(nonsenseUsername);
|
||||
|
@ -135,7 +136,7 @@ describe('www-integration sign-in-and-out', () => {
|
|||
const nonsensePassword = Math.random().toString(36)
|
||||
.replace(/[^a-z]+/g, '')
|
||||
.substr(0, 5);
|
||||
await driver.get(scratchr2url);
|
||||
await navigate(scratchr2url);
|
||||
await clickXpath('//li[@class="sign-in dropdown"]/span');
|
||||
const name = await findByXpath('//input[@id="login_dropdown_username"]');
|
||||
await name.sendKeys(username);
|
||||
|
|
|
@ -6,7 +6,8 @@ const {
|
|||
buildDriver,
|
||||
clickText,
|
||||
containsClass,
|
||||
findByXpath
|
||||
findByXpath,
|
||||
navigate
|
||||
} = new SeleniumHelper();
|
||||
|
||||
const rootUrl = process.env.ROOT_URL || 'https://scratch.ly';
|
||||
|
@ -22,7 +23,7 @@ describe('www-integration statistics page', () => {
|
|||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await driver.get(statisticsPage);
|
||||
await navigate(statisticsPage);
|
||||
});
|
||||
|
||||
afterAll(() => driver.quit());
|
||||
|
|
Loading…
Reference in a new issue