Skip to content

Commit

Permalink
Add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tonidero committed Jan 18, 2024
1 parent b42061b commit 63033fb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/rcbilling-demo/src/tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ beforeAll(() => {
test(
"Can purchase a product",
async () => {
console.log("TEST 1");
const { browser, page } = await setupTest();
console.log("TEST 1.5");
const userId = `rc_billing_demo_test_${Date.now()}`;
await changeUserId(page, userId);
console.log("TEST 2");

// Perform purchase
const weeklyPackageCard = (await getPackageCards(page))[1];
Expand All @@ -34,33 +37,44 @@ test(
await waitMilliseconds(2000);
await enterCreditCardDetailsAndContinue(page);
await waitMilliseconds(2000);
console.log("TEST 3");

// Go back to main page
const rcbRoot = await page.$(".rcb-ui-root");
expect(rcbRoot).not.toBeNull();
console.log("TEST 4");
await page.screenshot({ path: "artifacts/screenshot.png" });
console.log("TEST 5");
// await expectElementContainsText(rcbRoot!, "Purchase Successful");
const returnHomeButton = await rcbRoot?.$(".intent-secondary");
expect(returnHomeButton).not.toBeNull();
console.log("TEST 6");
await returnHomeButton?.click();
await page.waitForNavigation();
console.log("TEST 7");

// Needed since there is an animation after tapping on the button
// to go back to main page.
await waitMilliseconds(5000);
expect(await page.$(`::-p-text(Success!)`)).not.toBeNull();
await browser.close();
console.log("TEST 8");
},
{ timeout: 30000, retry: 3 },
);

async function setupTest(): Promise<{ browser: Browser; page: Page }> {
console.log("TEST setupTest 1");
const browser = await puppeteer.launch({
headless: "new",
});
console.log("TEST setupTest 2");
const page = await browser.newPage();
console.log("TEST setupTest 3");
await navigateToUrl(page);
console.log("TEST setupTest 4");
await page.waitForSelector(_CARD_CLASS);
console.log("TEST setupTest 5");
return { browser, page };
}

Expand Down

0 comments on commit 63033fb

Please sign in to comment.