Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up setup #137

Merged
merged 4 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/install-branch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const puppeteerutils = require('./puppeteer-utils');
const interviewConstants = require('./interview-constants.js');

const setup = async () => {
let {page, browser} = await puppeteerutils.login();
try {
await puppeteerutils.createProject(page);
await puppeteerutils.installRepo(page);
await waitForPage(page);
}
catch (e) {
console.log(e);
Expand All @@ -27,5 +29,23 @@ const takedown = async () => {
}
};

const waitForPage = async (page) => {
const tries = 20;

await page.goto(interviewConstants.PETITIONER_URL);

for (i=0; i<tries; i++) {
const element = await page.$('#daMainQuestion');
if (element) {
console.log("found question on page");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to confirm that these statements are intentionally here, and not leftovers from debugging. Otherwise, looks good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I figured they were nice to have when watching the pipeline running

break;
} else {
console.log("question not found");
await page.waitFor(10 * 1000); // 10 seconds
await page.reload();
}
}
};


module.exports = {setup, takedown};
6 changes: 1 addition & 5 deletions tests/puppeteer-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,8 @@ const installRepo = async (page) => {
const pullButton = await page.$('button[name=pull]');
await Promise.all([
pullButton.click(),
page.waitForNavigation({
// Without this, it tries to find the installButton before navigation is over
waitUntil: 'networkidle0',
}),
page.waitForNavigation(),
]);
await page.waitFor(2*60*1000); // wait for 2 minute
}

module.exports = {
Expand Down