This commit is contained in:
mozrokafor 2023-09-28 09:00:00 -04:00
Родитель 770a56711f
Коммит 43fd96ee7a
6 изменённых файлов: 68 добавлений и 78 удалений

Просмотреть файл

@ -17,15 +17,16 @@ export const getVerificationCode = async (testEmail: string, page: Page, attempt
throw new Error('Unable to retrieve restmail data');
}
const context = await request.newContext();
const context = await request.newContext();
const res = await context.get(
`http://restmail.net/mail/${testEmail}`,
{
failOnStatusCode: false
}
);
const resJson = await res.json();
const resJson = await res.json();
if (resJson.length) {
console.log('something returned: ', resJson);
const verificationCode = resJson[0].headers['x-verify-short-code']
return verificationCode;
}
@ -42,16 +43,16 @@ export const deleteEmailAddressMessages = async (req: APIRequestContext, testEma
}
};
const setYourPassword = async (page: Page) => {
const setYourPassword = async (page: Page) => {
await page.locator('#password').fill(process.env.E2E_TEST_ACCOUNT_PASSWORD as string)
await page.locator('#vpassword').fill(process.env.E2E_TEST_ACCOUNT_PASSWORD as string)
await page.locator('#age').fill('31');
await page.locator('button:has-text("Create account")').click({force: true})
await page.waitForTimeout(500)
await checkAuthState(page)
await checkAuthState(page)
}
const enterConfirmationCode = async (page: Page) => {
const enterConfirmationCode = async (page: Page) => {
const maybeVerificationCodeInput = 'div.card input'
await page.waitForSelector(maybeVerificationCodeInput, { timeout: 2000 })
const confirmButton = page.locator('#submit-btn')
@ -89,16 +90,16 @@ const enterYourPassword = async (page: Page) => {
await checkAuthState(page)
}
export const generateRandomEmail = async () => {
export const generateRandomEmail = async () => {
return `${Date.now()}_tstact@restmail.net`;
};
export const setEnvVariables = async (email: string) => {
export const setEnvVariables = async (email: string) => {
// set env variables
// stage will currently be the default
process.env['E2E_TEST_ENV'] = process.env.E2E_TEST_ENV || 'stage';
// stage will currently be the default
process.env['E2E_TEST_ENV'] = process.env.E2E_TEST_ENV as string ?? 'stage';
process.env['E2E_TEST_ACCOUNT_FREE'] = email;
process.env['E2E_TEST_BASE_URL'] = ENV_URLS[process.env.E2E_TEST_ENV as string] || 'https://stage.fxprivaterelay.nonprod.cloudops.mozgcp.net'
process.env['E2E_TEST_BASE_URL'] = ENV_URLS[process.env.E2E_TEST_ENV as string] ?? 'https://stage.fxprivaterelay.nonprod.cloudops.mozgcp.net'
}
interface DefaultScreenshotOpts {
@ -111,9 +112,12 @@ export const defaultScreenshotOpts: Partial<DefaultScreenshotOpts> = {
maxDiffPixelRatio: 0.04
};
export const EXPECT_TIMEOUT_MS = 2000
export const checkAuthState = async (page: Page) => {
console.log('should come through here, line');
try {
const authStateTitleString = await page.locator('h1').textContent({ timeout: 4000 })
const authStateTitleString = await page.locator('h1').first()?.textContent({ timeout: 4000 })
const checkIfTitleContains = (potentialTitle: string) => {
return authStateTitleString?.includes(potentialTitle)
}

Просмотреть файл

@ -24,7 +24,7 @@ async function globalSetup() {
// get verification code from restmail
const verificationCode = await getVerificationCode(randomEmail, page)
await authPage.enterVerificationCode(verificationCode)
await page.context().storageState({ path: 'state.json' });
await browser.close();
}

Просмотреть файл

@ -25,7 +25,8 @@ export class DashboardPage {
readonly emailsForwardedAmount: Locator
readonly emailsBlockedAmount: Locator
readonly emailMasksUsedAmount: Locator
readonly maskCard: string
readonly maskCard: Locator
readonly maskCardString: string
readonly maskCardExpanded: Locator
readonly maskCardExpandButton: Locator
readonly maskCardHeader: Locator
@ -77,7 +78,8 @@ export class DashboardPage {
this.dashBoardWithoutMasksEmail = page.locator('//section[starts-with(@class, "profile_no-premium-header")]')
// mask card elements
this.maskCard = '//div[starts-with(@class, "MaskCard_card")]'
this.maskCard = page.getByRole('button', { name: 'Generate new mask' })
this.maskCardString = '//div[starts-with(@class, "MaskCard_card")]'
this.maskCardExpanded = page.locator('//button[starts-with(@class, "MaskCard_expand")]')
this.maskCardExpandButton = page.locator('//button[starts-with(@class, "MaskCard_expand")]')
this.maskCardHeader = page.locator('//div[starts-with(@class, "MaskCard_summary")]')
@ -108,7 +110,7 @@ export class DashboardPage {
// generate a new mask and confirm
await this.generateNewMaskButton.click()
await this.page.waitForSelector(this.maskCard, { timeout: 3000 })
await this.page.waitForSelector(this.maskCardString, { timeout: 3000 })
// randomize between 1.5-2.5 secs between each generate to deal with issue of multiple quick clicks
await this.page.waitForTimeout((Math.random() * 2500) + 1500)
@ -142,7 +144,7 @@ export class DashboardPage {
let isExpanded = false
try {
numberOfMasks = await this.page.locator(this.maskCard).count()
numberOfMasks = await this.page.locator(this.maskCardString).count()
} catch(err){}
// check number of masks available
@ -153,7 +155,7 @@ export class DashboardPage {
// if clear all, check if there's an expanded mask card
if(clearAll){
try {
await this.page.waitForSelector(this.maskCard, { timeout: 3000 })
await this.page.waitForSelector(this.maskCardString, { timeout: 3000 })
} catch (error) {
console.error('There are no masks to delete')
return
@ -196,26 +198,22 @@ export class DashboardPage {
// TODO: Replace with a page under control of Relay team
await this.page.goto("https://monitor.firefox.com/", { waitUntil: 'networkidle' })
await this.page.locator('#scan-email-address').fill(generatedMaskEmail as string)
await this.page.locator('button.primary').click()
await this.page.waitForURL('**/scan**')
const monitorEmailInput = this.page.locator('#scan-email-address')
const submitButton = this.page.locator('button.primary')
await monitorEmailInput.fill(generatedMaskEmail as string)
await submitButton.click()
await this.page.getByRole('link', {name: 'Get alerts about new breaches'}).click()
const signupButton = this.page.locator('button.primary')
await signupButton.click()
await this.page.locator('input[name=email]').fill(generatedMaskEmail as string)
await this.page.locator('#submit-btn').click()
const passwordInputField = this.page.locator('#password');
const passwordConfirmInputField = this.page.locator('#vpassword');
const ageInputField = this.page.locator('#age');
const createAccountButton = this.page.locator('#submit-btn');
await this.page.locator('#password').fill(process.env.E2E_TEST_ACCOUNT_PASSWORD as string);
await this.page.locator('#vpassword').fill(process.env.E2E_TEST_ACCOUNT_PASSWORD as string);
await this.page.locator('#age').fill('31');
await this.page.locator('#submit-btn').click()
await this.page.waitForURL('**/confirm_signup_code**')
await passwordInputField.fill(process.env.E2E_TEST_ACCOUNT_PASSWORD as string);
await passwordConfirmInputField.fill(process.env.E2E_TEST_ACCOUNT_PASSWORD as string);
await ageInputField.fill('31');
await createAccountButton.click()
// wait for email to be forward to restmail
// verification email from fxa to generatedMaskEmail should be forwardedd to E2E_TEST_ACCOUNT_FREE
await getVerificationCode(process.env.E2E_TEST_ACCOUNT_FREE as string, this.page)
}

Просмотреть файл

@ -10,37 +10,37 @@ export class LandingPage {
readonly planPricingSignUpButton: Locator
readonly signInButton: Locator
readonly firefoxAppsServices: Locator
readonly firefoxAppsServicesExpanded: Locator
readonly firefoxAppsServicesHeading: Locator
readonly firefoxLogo: Locator
constructor(page: Page){
this.page = page
this.header = page.locator('#overlayProvider header')
this.FAQButton = page.locator('header >> text=FAQ')
this.homeButton = page.locator('header >> text=Home')
this.FAQButton = page.getByRole('link', { name: 'FAQ', exact: true })
this.homeButton = page.getByRole('link', { name: 'Home', exact: true })
this.signUpButton = page.locator('a:has-text("Sign Up")').first()
this.planPricingSignUpButton = page.locator('//a[contains(@class, "Plans_premium-plan")]/div')
this.subscriptionTitle = page.locator('[data-testid="subscription-create-title"]')
this.signInButton = page.locator('a:has-text("Sign In")')
this.firefoxAppsServices = page.locator('#react-aria-1')
this.firefoxAppsServicesExpanded = page.locator('#react-aria-2')
this.firefoxAppsServices = page.getByRole('button', { name: 'Firefox apps and services' })
this.firefoxAppsServicesHeading = page.getByRole('heading', { name: 'Firefox is tech that fights for your online privacy.' })
this.firefoxLogo = page.locator('//a[starts-with(@class, "Layout_logo")]')
}
async open(){
await this.page.goto(process.env.E2E_TEST_BASE_URL as string)
}
async goHome(){
await Promise.all([
this.page.waitForNavigation(),
this.page.waitForLoadState("networkidle"),
this.homeButton.click()
]);
}
async goToFAQ(){
async goToFAQ(){
await Promise.all([
this.page.waitForNavigation(),
this.page.waitForURL(/faq/),
this.FAQButton.click()
]);
}
@ -61,11 +61,11 @@ export class LandingPage {
}
async openFirefoxAppsServices(){
await this.firefoxAppsServices.click()
await this.page.waitForLoadState("networkidle")
await this.firefoxAppsServices.click({ force: true })
}
async clickFirefoxLogo(){
await this.firefoxLogo.click()
}
}

Просмотреть файл

@ -1,5 +1,5 @@
import test, { expect } from '../fixtures/basePages'
import { checkAuthState, defaultScreenshotOpts, ENV_DOMAINS } from '../e2eTestUtils/helpers';
import { checkAuthState, defaultScreenshotOpts } from '../e2eTestUtils/helpers';
// using logged in state outside of describe block will cover state for all tests in file
test.use({ storageState: 'state.json' })
@ -15,7 +15,7 @@ test.describe('Free - General Functionalities, Desktop', () => {
test.slow()
await expect(async () => {
await dashboardPage.generateMask(5)
expect(await page.locator(dashboardPage.maskCard).count() === 5)
expect(await page.locator(dashboardPage.maskCardString).count() === 5)
}).toPass()
@ -25,12 +25,10 @@ test.describe('Free - General Functionalities, Desktop', () => {
test('Check that when generating a new mask, its card is automatically opened, C1686210, C1553075, C1553064', async ({ dashboardPage, page }) => {
await expect(async () => {
await dashboardPage.generateMask(1)
expect(await page.locator(dashboardPage.maskCard).count() === 1)
expect(await page.locator(dashboardPage.maskCardString).count() === 1)
await expect(dashboardPage.maskCardExpandButton).toHaveAttribute("aria-expanded", "true")
}).toPass()
await expect(dashboardPage.maskCardExpandButton).toHaveAttribute("aria-expanded", "true")
expect(await dashboardPage.maskCardHeader.textContent()).toContain(ENV_DOMAINS[process.env.E2E_TEST_ENV as string])
})
})
@ -68,10 +66,10 @@ test.describe.skip('Free - General Functionalities, Desktop - Visual Regression'
test('Verify that opened mask cards are displayed correctly to a Free user, C1553070', async ({ dashboardPage, page }) => {
await expect(async () => {
await dashboardPage.generateMask(1)
expect(await page.locator(dashboardPage.maskCard).count() === 1)
expect(await page.locator(dashboardPage.maskCardString).count() === 1)
}).toPass()
await expect(page.locator(dashboardPage.maskCard)).toHaveScreenshot(`${process.env.E2E_TEST_ENV}-maskCard.png`,
await expect(page.locator(dashboardPage.maskCardString)).toHaveScreenshot(`${process.env.E2E_TEST_ENV}-maskCard.png`,
{...defaultScreenshotOpts, mask: [
dashboardPage.maskCardForwardEmail,
dashboardPage.maskCardGeneratedEmail,
@ -82,7 +80,7 @@ test.describe.skip('Free - General Functionalities, Desktop - Visual Regression'
test.skip('Check that the user can delete an mask, and is prompted to confirm before they delete, C1553071', async ({ dashboardPage, page }) => {
await expect(async () => {
await dashboardPage.generateMask(1)
expect(await page.locator(dashboardPage.maskCard).count() === 1)
expect(await page.locator(dashboardPage.maskCardString).count() === 1)
await dashboardPage.maskCardDeleteButton.click()
}).toPass()

Просмотреть файл

@ -14,46 +14,36 @@ test.describe('Firefox Relay - Landing Page - Visual Regression', () => {
defaultScreenshotOpts
);
});
test('Verify firefox apps and service', async ({ landingPage }) => {
await landingPage.openFirefoxAppsServices()
await expect(landingPage.firefoxAppsServicesExpanded).toHaveScreenshot(
`${process.env.E2E_TEST_ENV}-firefoxAppsServicesExpanded.png`,
defaultScreenshotOpts
);
})
});
test.describe('Check header buttons and their redirects, C1812638', () => {
test.beforeEach(async ({ landingPage }) => {
await landingPage.open()
});
});
test('Verify home FAQ button redirect', async ({ landingPage, page }) => {
await landingPage.goToFAQ()
expect(page.url()).toContain(`${process.env.E2E_TEST_BASE_URL}/faq/`)
test('Verify home FAQ button redirect', async ({ landingPage }) => {
const FAQRedirectLink = await landingPage.FAQButton.getAttribute('href')
expect(FAQRedirectLink).toEqual("/faq/")
})
test('Verify home button redirect', async ({ landingPage, page }) => {
await landingPage.goToFAQ()
await landingPage.goHome()
expect(page.url()).toContain(process.env.E2E_TEST_BASE_URL)
})
test('Verify home firefox logo redirect', async ({ landingPage, page }) => {
await landingPage.goToFAQ()
await landingPage.clickFirefoxLogo()
expect(page.url()).toEqual(`${process.env.E2E_TEST_BASE_URL}/`)
})
test('Verify home button redirect', async ({ landingPage }) => {
const homeRedirectLink = await landingPage.homeButton.getAttribute('href')
expect(homeRedirectLink).toEqual("/")
})
test('Verify home firefox logo redirect', async ({ landingPage }) => {
const firefoxLogoRedirectLink = await landingPage.firefoxLogo.getAttribute('href')
expect(firefoxLogoRedirectLink).toEqual("/")
})
test('Verify sign in button authentication flow, C1818784', async ({ landingPage, authPage }) => {
await landingPage.goToSignIn()
expect(authPage.emailInputField.isVisible()).toBeTruthy()
})
test('Verify sign up button authentication flow, C1818782', async ({ landingPage, authPage }) => {
test('Verify sign up button authentication flow, C1818782', async ({ landingPage, authPage }) => {
await landingPage.goToSignUp()
expect(authPage.emailInputField.isVisible()).toBeTruthy()
})
})
});