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

Adding Marketo placeholder tests #354

Merged
merged 3 commits into from
May 31, 2024
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
29 changes: 25 additions & 4 deletions selectors/milo/marketo.block.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ export default class Marketo {
this.email = this.marketo.locator('input[name="Email"]');
this.phone = this.marketo.locator('input[name="Phone"]');
this.company = this.marketo.locator('input[name="mktoFormsCompany"]');
this.functionalArea = this.marketo.locator('select[name="mktoFormsFunctionalArea"]');
this.functionalArea = this.marketo.locator(
'select[name="mktoFormsFunctionalArea"]',
);
this.country = this.marketo.locator('select[name="Country"]');
this.state = this.marketo.locator('select[name="State"]');
this.postalCode = this.marketo.locator('input[name="PostalCode"]');
this.jobTitle = this.marketo.locator('select[name="mktoFormsJobTitle"]');
this.primaryProductInterest = this.marketo.locator('select[name="mktoFormsPrimaryProductInterest"]');
this.companyType = this.marketo.locator('select[name="mktoFormsCompanyType"]');
this.primaryProductInterest = this.marketo.locator(
'select[name="mktoFormsPrimaryProductInterest"]',
);
this.companyType = this.marketo.locator(
'select[name="mktoFormsCompanyType"]',
);
this.submitButton = this.marketo.locator('#mktoButton_new');
}

Expand Down Expand Up @@ -177,7 +183,9 @@ export default class Marketo {
}

async getPOI() {
const poi = await this.page.evaluate('window.mcz_marketoForm_pref.program.poi');
const poi = await this.page.evaluate(
'window.mcz_marketoForm_pref.program.poi',
);
return poi;
}

Expand All @@ -189,4 +197,17 @@ export default class Marketo {
this.companyType.selectOption(COMPANY_TYPE);
}
}

/**
* @description Checks that the input fields have the placeholder attribute
* and that the value isn't empty.
* @param {...any} inputFields the input fields of the form being tested.
*/
static async checkInputPlaceholders(...inputFields) {
inputFields.forEach(async (el) => {
expect(el).toHaveAttribute('placeholder');
const placeholder = await el.getAttribute('placeholder');
expect(placeholder.length).toBeGreaterThan(1);
});
}
}
72 changes: 60 additions & 12 deletions tests/milo/marketo.block.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,27 @@ test.describe('Marketo block test suite', () => {
await page.goto(testPage);
await page.waitForLoadState('domcontentloaded');
await expect(page).toHaveURL(testPage);
});

await test.step('step-2: Submit the form with valid inputs', async () => {
// Need this wait to avoid failed form submission during parallel runs
await page.waitForTimeout(WAIT_TIME);
});

await test.step('step-2: check the input field placeholders', async () => {
await MarketoBlock.checkInputPlaceholders(
marketoBlock.firstName,
marketoBlock.lastName,
marketoBlock.email,
marketoBlock.company,
marketoBlock.phone,
marketoBlock.postalCode,
);
});

await test.step('step-3: Submit the form with valid inputs', async () => {
await marketoBlock.submitFullTemplateForm();
});

await test.step('step-3: Verify the form submission redirect', async () => {
await test.step('step-4: Verify the form submission redirect', async () => {
await expect(page).not.toHaveURL(testPage, { timeout: 15000 });
});
});
Expand All @@ -183,14 +196,27 @@ test.describe('Marketo block test suite', () => {
await page.goto(testPage);
await page.waitForLoadState('domcontentloaded');
await expect(page).toHaveURL(testPage);
});

await test.step('step-2: Submit the form with valid inputs', async () => {
// Need this wait to avoid failed form submission during parallel runs
await page.waitForTimeout(WAIT_TIME);
});

await test.step('step-2: check the input field placeholders', async () => {
await MarketoBlock.checkInputPlaceholders(
marketoBlock.firstName,
marketoBlock.lastName,
marketoBlock.email,
marketoBlock.company,
marketoBlock.phone,
marketoBlock.postalCode,
);
});

await test.step('step-3: Submit the form with valid inputs', async () => {
await marketoBlock.submitFullTemplateForm('Adobe Advertising Cloud');
});

await test.step('step-3: Verify the form submission redirect', async () => {
await test.step('step-4: Verify the form submission redirect', async () => {
await expect(page).not.toHaveURL(testPage, { timeout: 15000 });
});
});
Expand All @@ -204,14 +230,25 @@ test.describe('Marketo block test suite', () => {
await page.goto(testPage);
await page.waitForLoadState('domcontentloaded');
await expect(page).toHaveURL(testPage);
});

await test.step('step-2: Submit the form with valid inputs', async () => {
// Need this wait to avoid failed form submission during parallel runs
await page.waitForTimeout(WAIT_TIME);
});

await test.step('step-2: check the input field placeholders', async () => {
await MarketoBlock.checkInputPlaceholders(
marketoBlock.firstName,
marketoBlock.lastName,
marketoBlock.email,
marketoBlock.company,
);
});

await test.step('step-3: Submit the form with valid inputs', async () => {
await marketoBlock.submitExpandedTemplateForm();
});

await test.step('step-3: Verify the form submission redirect', async () => {
await test.step('step-4: Verify the form submission redirect', async () => {
await expect(page).not.toHaveURL(testPage, { timeout: 15000 });
});
});
Expand All @@ -226,14 +263,25 @@ test.describe('Marketo block test suite', () => {
await page.goto(testPage);
await page.waitForLoadState('domcontentloaded');
await expect(page).toHaveURL(testPage);
});

await test.step('step-2: Submit the form with valid inputs', async () => {
// Need this wait to avoid failed form submission during parallel runs
await page.waitForTimeout(WAIT_TIME);
});

await test.step('step-2: check the input field placeholders', async () => {
await MarketoBlock.checkInputPlaceholders(
marketoBlock.firstName,
marketoBlock.lastName,
marketoBlock.email,
marketoBlock.company,
);
});

await test.step('step-3: Submit the form with valid inputs', async () => {
await marketoBlock.submitEssentialTemplateForm();
});

await test.step('step-3: Verify the form submission redirect', async () => {
await test.step('step-4: Verify the form submission redirect', async () => {
await expect(page).not.toHaveURL(testPage, { timeout: 15000 });
});
});
Expand Down
Loading