Skip to content

Commit

Permalink
#1431 correct flakey tests, increase fetch upcoming invoices wait tim…
Browse files Browse the repository at this point in the history
…e (to give time for invoices to be created at stripes end
  • Loading branch information
chrisjsimpson committed Jan 7, 2025
1 parent afbb2ae commit 8dfb48e
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ test.describe("Plan Creation tests:", () => {
}
});


test("@264@shop-owner @264_shop_owner_create_plan_with_choice_options", async ({ page }) => {
await admin_login(page);
await set_test_name_cookie(page, "@264_shop_owner_create_plan_with_choice_options")
Expand Down Expand Up @@ -224,44 +223,54 @@ test.describe("Plan Creation tests:", () => {

//Add options and choices
console.log('adding plan options and choices');
await page.goto('/admin/add-choice-group');

//add choice group
await page.goto('/admin/list-choice-groups');
const add_choice_group = await page.textContent('text="Add Choice Group"');
expect(add_choice_group === "Add Choice Group");
await page.fill('.form-control', 'Choices');
await page.click("text='Save'");
await page.textContent('.alert-heading') === "Notification";
console.log("Choice Created");

//add first option
console.log("adding options...")
await page.goto('/admin/list-choice-groups');
await page.getByRole('button', { name: 'Options' }).click();

await page.click("text=Add Option");
await page.fill('.form-control', 'Red');
await page.click("text='Save'");
await page.textContent('.alert-heading') === "Notification";
console.log("First Option added");

//add second option
await page.click("text=Add Option");
await page.fill('.form-control', 'Blue');
await page.click("text='Save'");
await page.textContent('.alert-heading') === "Notification";
console.log("Second Option added");

//assign choice to plan
console.log("Assigning Choice to plan...")
await page.goto('/admin/list-choice-groups');
await page.click("text=Assign Plan");
const assign_choice_to_plan = await page.textContent('text="Choice Group - Assign Plan"');
expect(assign_choice_to_plan === "Choice Group - Assign Plan");
await page.click("text=Plan with choice and options");
await page.click("text='Save'");
await page.textContent('.alert-heading') === "Notification";
console.log("Choice assigned to plan");
// Check if choice group named 'Choices' already exists
try {
const check_choice_group = await page.textContent('text="Choices"', { timeout: 2000 });
if (check_choice_group === "Choices") {
console.log("Choice Group already created.");
}
} catch (e) {
console.log("Choice Group 'Choices' does not exist, continuing with creation");
//add choice group
await page.goto('/admin/add-choice-group');
await page.fill('.form-control', 'Choices');
await page.click("text='Save'");
await page.textContent('.alert-heading') === "Notification";
console.log("Choice Created");

//add first option
console.log("adding options...")
await page.goto('/admin/list-choice-groups');
await page.getByRole('button', { name: 'Options' }).first().click();

await page.click("text=Add Option");
await page.fill('.form-control', 'Red');
await page.click("text='Save'");
await page.textContent('.alert-heading') === "Notification";
console.log("First Option added");

//add second option
await page.click("text=Add Option");
await page.fill('.form-control', 'Blue');
await page.click("text='Save'");
await page.textContent('.alert-heading') === "Notification";
console.log("Second Option added");

//assign choice to plan
console.log("Assigning Choice to plan...")
await page.goto('/admin/list-choice-groups');
await page.click("text=Assign Plan");
const assign_choice_to_plan = await page.textContent('text="Choice Group - Assign Plan"');
expect(assign_choice_to_plan === "Choice Group - Assign Plan");
await page.click("text=Plan with choice and options");
await page.click("text='Save'");
await page.textContent('.alert-heading') === "Notification";
console.log("Choice assigned to plan");
}

//confirm choice and option plan was added
await page.goto('/');
Expand All @@ -280,6 +289,7 @@ test.describe("Plan Creation tests:", () => {
const expand_choice = await page.textContent('text="Choices (2 options)"');
expect(expand_choice === "Choices (2 options)");
console.log("Plan with option and choices shown in homepage");

});

});
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ test("@212@shop-owner@slogan creation @212_shop_owner_slogan_creation", async ({

//verify home page plan creation
await page.goto("/");
await new Promise(x => setTimeout(x, 1000)); // 1 secconds
await page.reload();
const slogan_created = await page.textContent('text=this is a slogan');
expect(slogan_created === 'this is a slogan');
// TODO screenshot cooling off plan
});
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ test("@264@subscriber @264_subscriber_order_plan_with_choice_options_and_require
await page.goto('/admin/upcoming-invoices');
// Fetch Upcoming Invoices
await fetch_upcomming_invoices(page);
await page.reload();
await page.locator('css=span.plan-price-interval', {hasText: "£15.00"}).first().textContent() === '£15.00';

const content_upcoming_invoice_plan_sell_price = await page.textContent('.upcoming-invoices-plan-no-sell_price');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var admin_login = async function (page) {
await page.fill('#email', '[email protected]');
await page.fill('#password', 'password');
await page.click('#login');
await page.goto(process.env['PLAYWRIGHT_HOST'] + '/admin/dashboard');
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var fetch_upcomming_invoices = async function (page) {
// Go to upcoming payments and ensure plan is attached to upcoming invoice
await page.goto('/admin/upcoming-invoices');
await new Promise(x => setTimeout(x, 25000));
await new Promise(x => setTimeout(x, 35000));
await page.click('#fetch_upcoming_invoices');
await new Promise(x => setTimeout(x, 20000));
await new Promise(x => setTimeout(x, 30000));
await page.reload();
}

module.exports.fetch_upcomming_invoices = fetch_upcomming_invoices;

0 comments on commit 8dfb48e

Please sign in to comment.