Skip to content

Commit

Permalink
Adding tests for the company type field. (#353)
Browse files Browse the repository at this point in the history
Co-authored-by: Dennis Li <[email protected]>
  • Loading branch information
Dli3 and Dennis Li authored May 28, 2024
1 parent e2eb9d6 commit 34ecfc0
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 105 deletions.
18 changes: 15 additions & 3 deletions features/milo/marketo.block.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,26 @@ module.exports = {
},
{
tcid: '8',
name: '@marketo full template',
path: '/drafts/nala/blocks/marketo/full-with-company-type',
tags: '@marketo @marketoFullTemplate @milo @smoke @regression',
},
{
tcid: '9',
name: '@marketo expanded template',
path: '/drafts/nala/blocks/marketo/expanded',
path: [
'/drafts/nala/blocks/marketo/expanded',
'/drafts/nala/blocks/marketo/expanded-with-company-type',
],
tags: '@marketo @marketoExpandedTemplate @milo @smoke @regression',
},
{
tcid: '9',
tcid: '10',
name: '@marketo essential template',
path: '/drafts/nala/blocks/marketo/essential',
path: [
'/drafts/nala/blocks/marketo/essential',
'/drafts/nala/blocks/marketo/essential-with-company-type',
],
tags: '@marketo @marketoEssentialTemplate @milo @smoke @regression',
},
],
Expand Down
191 changes: 105 additions & 86 deletions selectors/milo/marketo.block.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const POSTAL_CODE = '94111';
const JOB_TITLE = 'Other';
const PRIMARY_PRODUCT_INTEREST = 'Digital marketing';
const FUNCTIONAL_AREA = 'Other';
const COMPANY_TYPE = 'Other';

export default class Marketo {
constructor(page) {
Expand All @@ -27,6 +28,7 @@ export default class Marketo {
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.submitButton = this.marketo.locator('#mktoButton_new');
}

Expand All @@ -47,127 +49,144 @@ export default class Marketo {
* @description Form ID: MCZ Production (2277)
*/
async submitProductionForm() {
await this.country.selectOption(`${COUNTRY}`);
await this.functionalArea.selectOption(`${FUNCTIONAL_AREA}`);
await this.jobTitle.selectOption(`${JOB_TITLE}`);
await this.primaryProductInterest.selectOption(`${PRIMARY_PRODUCT_INTEREST}`);
await this.state.selectOption(`${STATE}`);
await this.firstName.fill(`${FIRST_NAME}`);
await this.lastName.fill(`${LAST_NAME}`);
await this.email.fill(`${EMAIL}`);
await this.phone.fill(`${PHONE}`);
await this.company.fill(`${COMPANY}`);
await this.postalCode.fill(`${POSTAL_CODE}`);
await this.country.selectOption(COUNTRY);
await this.functionalArea.selectOption(FUNCTIONAL_AREA);
await this.jobTitle.selectOption(JOB_TITLE);
await this.primaryProductInterest.selectOption(PRIMARY_PRODUCT_INTEREST);
await this.state.selectOption(STATE);
await this.firstName.fill(FIRST_NAME);
await this.lastName.fill(LAST_NAME);
await this.email.fill(EMAIL);
await this.phone.fill(PHONE);
await this.company.fill(COMPANY);
await this.postalCode.fill(POSTAL_CODE);
await this.submitButton.click();
}

async submitRFITemplateForm() {
await this.country.selectOption(`${COUNTRY}`);
await this.functionalArea.selectOption(`${FUNCTIONAL_AREA}`);
await this.jobTitle.selectOption(`${JOB_TITLE}`);
await this.primaryProductInterest.selectOption(`${PRIMARY_PRODUCT_INTEREST}`);
await this.state.selectOption(`${STATE}`);
await this.company.fill(`${COMPANY}`);
await this.firstName.fill(`${FIRST_NAME}`);
await this.lastName.fill(`${LAST_NAME}`);
await this.email.fill(`${EMAIL}`);
await this.phone.fill(`${PHONE}`);
await this.postalCode.fill(`${POSTAL_CODE}`);
await this.country.selectOption(COUNTRY);
await this.functionalArea.selectOption(FUNCTIONAL_AREA);
await this.jobTitle.selectOption(JOB_TITLE);
await this.primaryProductInterest.selectOption(PRIMARY_PRODUCT_INTEREST);
await this.state.selectOption(STATE);
await this.company.fill(COMPANY);
await this.firstName.fill(FIRST_NAME);
await this.lastName.fill(LAST_NAME);
await this.email.fill(EMAIL);
await this.phone.fill(PHONE);
await this.postalCode.fill(POSTAL_CODE);
await this.submitButton.click();
}

async submitDiscoverTemplateForm() {
await this.country.selectOption(`${COUNTRY}`);
await this.email.fill(`${EMAIL}`);
await this.company.fill(`${COMPANY}`);
await this.country.selectOption(COUNTRY);
await this.email.fill(EMAIL);
await this.company.fill(COMPANY);
await this.submitButton.click();
}

async submitExploreTemplateForm() {
await this.country.selectOption(`${COUNTRY}`);
await this.functionalArea.selectOption(`${FUNCTIONAL_AREA}`);
await this.jobTitle.selectOption(`${JOB_TITLE}`);
await this.firstName.fill(`${FIRST_NAME}`);
await this.lastName.fill(`${LAST_NAME}`);
await this.email.fill(`${EMAIL}`);
await this.company.fill(`${COMPANY}`);
await this.country.selectOption(COUNTRY);
await this.functionalArea.selectOption(FUNCTIONAL_AREA);
await this.jobTitle.selectOption(JOB_TITLE);
await this.firstName.fill(FIRST_NAME);
await this.lastName.fill(LAST_NAME);
await this.email.fill(EMAIL);
await this.company.fill(COMPANY);
await this.submitButton.click();
}

async submitEvaluateTemplateForm() {
await this.country.selectOption(`${COUNTRY}`);
await this.functionalArea.selectOption(`${FUNCTIONAL_AREA}`);
await this.jobTitle.selectOption(`${JOB_TITLE}`);
await this.state.selectOption(`${STATE}`);
await this.firstName.fill(`${FIRST_NAME}`);
await this.lastName.fill(`${LAST_NAME}`);
await this.email.fill(`${EMAIL}`);
await this.company.fill(`${COMPANY}`);
await this.phone.fill(`${PHONE}`);
await this.postalCode.fill(`${POSTAL_CODE}`);
await this.country.selectOption(COUNTRY);
await this.functionalArea.selectOption(FUNCTIONAL_AREA);
await this.jobTitle.selectOption(JOB_TITLE);
await this.state.selectOption(STATE);
await this.firstName.fill(FIRST_NAME);
await this.lastName.fill(LAST_NAME);
await this.email.fill(EMAIL);
await this.company.fill(COMPANY);
await this.phone.fill(PHONE);
await this.postalCode.fill(POSTAL_CODE);
await this.submitButton.click();
}

async submitWebinarTemplateForm() {
await this.country.selectOption(`${COUNTRY}`);
await this.functionalArea.selectOption(`${FUNCTIONAL_AREA}`);
await this.jobTitle.selectOption(`${JOB_TITLE}`);
await this.state.selectOption(`${STATE}`);
await this.firstName.fill(`${FIRST_NAME}`);
await this.lastName.fill(`${LAST_NAME}`);
await this.email.fill(`${EMAIL}`);
await this.phone.fill(`${PHONE}`);
await this.company.fill(`${COMPANY}`);
await this.postalCode.fill(`${POSTAL_CODE}`);
await this.country.selectOption(COUNTRY);
await this.functionalArea.selectOption(FUNCTIONAL_AREA);
await this.jobTitle.selectOption(JOB_TITLE);
await this.state.selectOption(STATE);
await this.firstName.fill(FIRST_NAME);
await this.lastName.fill(LAST_NAME);
await this.email.fill(EMAIL);
await this.phone.fill(PHONE);
await this.company.fill(COMPANY);
await this.postalCode.fill(POSTAL_CODE);
await this.submitButton.click();
}

async submitTrialTemplateForm() {
await this.functionalArea.selectOption(`${FUNCTIONAL_AREA}`);
await this.country.selectOption(`${COUNTRY}`);
await this.jobTitle.selectOption(`${JOB_TITLE}`);
await this.state.selectOption(`${STATE}`);
await this.firstName.fill(`${FIRST_NAME}`);
await this.lastName.fill(`${LAST_NAME}`);
await this.email.fill(`${EMAIL}`);
await this.phone.fill(`${PHONE}`);
await this.company.fill(`${COMPANY}`);
await this.postalCode.fill(`${POSTAL_CODE}`);
await this.functionalArea.selectOption(FUNCTIONAL_AREA);
await this.country.selectOption(COUNTRY);
await this.jobTitle.selectOption(JOB_TITLE);
await this.state.selectOption(STATE);
await this.firstName.fill(FIRST_NAME);
await this.lastName.fill(LAST_NAME);
await this.email.fill(EMAIL);
await this.phone.fill(PHONE);
await this.company.fill(COMPANY);
await this.postalCode.fill(POSTAL_CODE);
await this.submitButton.click();
}

async submitFullTemplateForm() {
await this.country.selectOption(`${COUNTRY}`);
await this.functionalArea.selectOption(`${FUNCTIONAL_AREA}`);
await this.jobTitle.selectOption(`${JOB_TITLE}`);
await this.primaryProductInterest.selectOption(`${PRIMARY_PRODUCT_INTEREST}`);
await this.state.selectOption(`${STATE}`);
await this.company.fill(`${COMPANY}`);
await this.firstName.fill(`${FIRST_NAME}`);
await this.lastName.fill(`${LAST_NAME}`);
await this.email.fill(`${EMAIL}`);
await this.phone.fill(`${PHONE}`);
await this.postalCode.fill(`${POSTAL_CODE}`);
async submitFullTemplateForm(poi = PRIMARY_PRODUCT_INTEREST) {
await this.country.selectOption(COUNTRY);
await this.functionalArea.selectOption(FUNCTIONAL_AREA);
await this.jobTitle.selectOption(JOB_TITLE);
await this.primaryProductInterest.selectOption(poi);
await this.state.selectOption(STATE);
await this.company.fill(COMPANY);
await this.firstName.fill(FIRST_NAME);
await this.lastName.fill(LAST_NAME);
await this.email.fill(EMAIL);
await this.phone.fill(PHONE);
await this.postalCode.fill(POSTAL_CODE);
await this.selectCompanyType();
await this.submitButton.click();
}

async submitExpandedTemplateForm() {
await this.country.selectOption(`${COUNTRY}`);
await this.functionalArea.selectOption(`${FUNCTIONAL_AREA}`);
await this.jobTitle.selectOption(`${JOB_TITLE}`);
await this.firstName.fill(`${FIRST_NAME}`);
await this.lastName.fill(`${LAST_NAME}`);
await this.email.fill(`${EMAIL}`);
await this.company.fill(`${COMPANY}`);
await this.country.selectOption(COUNTRY);
await this.functionalArea.selectOption(FUNCTIONAL_AREA);
await this.jobTitle.selectOption(JOB_TITLE);
await this.firstName.fill(FIRST_NAME);
await this.lastName.fill(LAST_NAME);
await this.email.fill(EMAIL);
await this.company.fill(COMPANY);
await this.selectCompanyType();
await this.submitButton.click();
}

async submitEssentialTemplateForm() {
await this.country.selectOption(`${COUNTRY}`);
await this.firstName.fill(`${FIRST_NAME}`);
await this.lastName.fill(`${LAST_NAME}`);
await this.email.fill(`${EMAIL}`);
await this.company.fill(`${COMPANY}`);
await this.country.selectOption(COUNTRY);
await this.firstName.fill(FIRST_NAME);
await this.lastName.fill(LAST_NAME);
await this.email.fill(EMAIL);
await this.company.fill(COMPANY);
await this.selectCompanyType();
await this.submitButton.click();
}

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

async selectCompanyType() {
// The company type field will display if the poi is one of the below
const expectedPOI = ['Commerce', 'ADOBEADVERTISINGCLOUD'];

if (expectedPOI.includes(await this.getPOI())) {
this.companyType.selectOption(COMPANY_TYPE);
}
}
}
56 changes: 40 additions & 16 deletions tests/milo/marketo.block.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,43 +175,67 @@ test.describe('Marketo block test suite', () => {
});
});

test(`8: @marketo expanded template, ${features[8].tags}`, async ({ page, baseURL }) => {
test(`8: @marketo full template with company type, ${features[8].tags}`, async ({ page, baseURL }) => {
const testPage = `${baseURL}${features[8].path}${miloLibs}`;
console.info(`[Test Page]: ${testPage}`);

await test.step('step-1: Go to the Marketo block expanded template test page', async () => {
await test.step('step-1: Go to the Marketo block full template test page', async () => {
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 () => {
await page.waitForTimeout(WAIT_TIME);
await marketoBlock.submitExpandedTemplateForm();
await marketoBlock.submitFullTemplateForm('Adobe Advertising Cloud');
});

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

test(`9: @marketo essential template, ${features[9].tags}`, async ({ page, baseURL }) => {
const testPage = `${baseURL}${features[9].path}${miloLibs}`;
console.info(`[Test Page]: ${testPage}`);
features[9].path.forEach((path) => {
test(`9: @marketo expanded template, ${features[9].tags}}, path: ${path}`, async ({ page, baseURL }) => {
const testPage = `${baseURL}${path}${miloLibs}`;
console.info(`[Test Page]: ${testPage}`);

await test.step('step-1: Go to the Marketo block essential template test page', async () => {
await page.goto(testPage);
await page.waitForLoadState('domcontentloaded');
await expect(page).toHaveURL(testPage);
});
await test.step('step-1: Go to the Marketo block expanded template test page', async () => {
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 () => {
await page.waitForTimeout(WAIT_TIME);
await marketoBlock.submitEssentialTemplateForm();
await test.step('step-2: Submit the form with valid inputs', async () => {
await page.waitForTimeout(WAIT_TIME);
await marketoBlock.submitExpandedTemplateForm();
});

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

await test.step('step-3: Verify the form submission redirect', async () => {
await expect(page).not.toHaveURL(testPage, { timeout: 15000 });
features[10].path.forEach((path) => {
test(`10: @marketo essential template, ${features[10].tags}, path: ${path}`, async ({ page, baseURL }) => {
const testPage = `${baseURL}${path}${miloLibs}`;
console.info(`[Test Page]: ${testPage}`);

await test.step('step-1: Go to the Marketo block essential template test page', async () => {
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 () => {
await page.waitForTimeout(WAIT_TIME);
await marketoBlock.submitEssentialTemplateForm();
});

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

0 comments on commit 34ecfc0

Please sign in to comment.