diff --git a/package.json b/package.json index 6c240fa..bddb136 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tab-e2e", - "version": "2.0.2", + "version": "2.0.5", "description": "", "main": "build/index.js", "scripts": { @@ -56,7 +56,7 @@ "webpack-node-externals": "^2.5.2" }, "dependencies": { - "chromedriver": "^93.0.0", + "chromedriver": "^95.0.0", "mailosaur": "^7.2.1", "node-fetch": "^2.6.1", "promise-retry": "^2.0.1", diff --git a/src/tab-legacy/userSignup.js b/src/tab-legacy/userSignup.js index 044f0fb..517fa2c 100644 --- a/src/tab-legacy/userSignup.js +++ b/src/tab-legacy/userSignup.js @@ -7,6 +7,9 @@ import { setValue, click, waitAndClick, + setCause, + completeIntroFlow, + logOut, } from '../utils/driver-mgr' import EmailClient from '../utils/mailosaurClient' @@ -42,10 +45,6 @@ const getUserSignupTests = (getDriver) => { MAILOSAUR_API_KEY, MAILOSAUR_SERVER_ID, }) - const backgroundImages = await driver.findElements( - By.css(`[data-test-id='cats-background']`) - ) - expect(backgroundImages.length).toEqual(0) await signUp(driver, mailClient.email, mailClient.password) const link = await mailClient.getLink() await driver.navigate().to(link) @@ -107,10 +106,6 @@ const getUserSignupTests = (getDriver) => { MAILOSAUR_API_KEY, MAILOSAUR_SERVER_ID, }) - const backgroundImages = await driver.findElements( - By.css(`[data-test-id='cats-background']`) - ) - expect(backgroundImages.length).toEqual(0) await signUp(driver, mailClient.email, mailClient.password) const link = await mailClient.getLink() await driver.navigate().to(link) @@ -147,86 +142,26 @@ const getUserSignupTests = (getDriver) => { testTimeout: testTimeoutdefault, }, { - description: 'should successfully sign up and create a user in Chrome v4', + description: + 'should successfully sign up and create a user in Chrome v4 cats', test: async () => { const { driver, config: { mailosaur: { MAILOSAUR_API_KEY, MAILOSAUR_SERVER_ID } = {}, }, - } = getDriver('Tab: acceptance tests: should sign up v4') + } = getDriver( + 'Tab: acceptance tests: should successfully sign up and create a user in Chrome v4 cats' + ) try { - await navigateTo(driver, '/cats/') - await waitAndClick(driver, By.css('button')) - await waitForElementExistsByCustomSelector( - driver, - By.css(`[aria-label='Add to Chrome'`) - ) - await navigateTo(driver, '/newtab/first-tab') - await waitForElementExistsByCustomSelector( - driver, - By.xpath('//span[text()="Sign in with email"]') - ) - const backgroundImages = await driver.findElements( - By.css(`[data-test-id='cats-background']`) - ) - expect(backgroundImages.length).toEqual(1) - const mailClient = await EmailClient.build({ + const user1 = await EmailClient.build({ MAILOSAUR_API_KEY, MAILOSAUR_SERVER_ID, }) - - await signUp(driver, mailClient.email, mailClient.password) - const link = await mailClient.getLink() - await driver.navigate().to(link) - await waitForElementExistsByCustomSelector( - driver, - By.xpath('//button[text()="Continue"]') - ) - await click(driver, By.xpath('//button[text()="Continue"]')) - await waitForElementExistsByCustomSelector( - driver, - By.id('username-input') - ) - await setValue( - driver, - By.id('username-input'), - mailClient.email.split('@')[0] - ) - await click(driver, By.xpath('//span[text()="Next"]')) - await waitForElementExistsByCustomSelector( - driver, - By.xpath('//span[text()="Next"]') - ) - await waitForElementExistsByCustomSelector( - driver, - By.xpath('//h5[text()="Your tabs are doing great things"]') - ) - const firstTitle = await driver.findElements( - By.xpath('//h5[text()="Your tabs are doing great things"]') - ) - expect(firstTitle.length).toEqual(1) - await click(driver, By.xpath('//span[text()="Next"]')) - await waitForElementExistsByCustomSelector( - driver, - By.xpath(`//h5[text()="It doesn't cost you a thing"]`) - ) - const thirdTitle = await driver.findElements( - By.xpath(`//h5[text()="It doesn't cost you a thing"]`) - ) - expect(thirdTitle.length).toEqual(1) - await click(driver, By.xpath('//span[text()="Next"]')) - await waitAndClick(driver, By.xpath(`//span[text()="I'M READY!"]`)) - await new Promise((res) => setTimeout(() => res(), 1000)) - await navigateTo(driver, '/newtab') - const iconPath = '//a[@href="/newtab/account/"]' - await waitAndClick(driver, By.xpath(iconPath)) - await waitForElementExistsByCustomSelector( - driver, - By.xpath(`//p[text()="${mailClient.email}"]`) - ) - await waitAndClick(driver, By.xpath('//span[text()="Log Out"]')) - await signIn(driver, mailClient.email, mailClient.password) + await setCause(driver, '/cats/') + await signUp(driver, user1.email, user1.password) + await completeIntroFlow(driver, user1) + await logOut(driver, user1) } finally { await driver.quit() } @@ -235,100 +170,89 @@ const getUserSignupTests = (getDriver) => { }, { description: - 'should successfully sign up and create a user in Chrome v4 referral', + 'should successfully sign up and create a user in Chrome v4 referral cats', test: async () => { const { driver, config: { mailosaur: { MAILOSAUR_API_KEY, MAILOSAUR_SERVER_ID } = {}, }, - } = getDriver('Tab: acceptance tests: should sign up v4 referral ') + } = getDriver( + 'Tab: acceptance tests: should successfully sign up and create a user in Chrome v4 referral cats' + ) try { - await navigateTo(driver, '/cats/?u=wgcuq') - await waitForElementExistsByCustomSelector( - driver, - By.xpath('//div[text()="Your friend sent you a gift"]') - ) - const referralText = await driver.findElements( - By.xpath('//div[text()="Your friend sent you a gift"]') - ) - expect(referralText.length).toEqual(1) - await waitAndClick(driver, By.css('button')) - await waitForElementExistsByCustomSelector( - driver, - By.css(`[aria-label='Add to Chrome'`) - ) - await navigateTo(driver, '/newtab/first-tab') - await waitForElementExistsByCustomSelector( - driver, - By.xpath('//span[text()="Sign in with email"]') - ) - const backgroundImages = await driver.findElements( - By.css(`[data-test-id='cats-background']`) - ) - expect(backgroundImages.length).toEqual(1) - const mailClient = await EmailClient.build({ + const user1 = await EmailClient.build({ MAILOSAUR_API_KEY, MAILOSAUR_SERVER_ID, }) - - await signUp(driver, mailClient.email, mailClient.password) - const link = (await mailClient.getLink()).replace('dev-', 'test-') - await driver.navigate().to(link) - await waitForElementExistsByCustomSelector( + await setCause(driver, '/cats/?u=test1', true) + await signUp(driver, user1.email, user1.password) + await completeIntroFlow( driver, - By.xpath('//button[text()="Continue"]') + user1, + false, + "Your friend started you off with 5 cat treats, which are crucial to getting shelter cats adopted. Open a new tab now to earn your 6th treat! We'll track how many treats you've given on the top of the page:" ) - await click(driver, By.xpath('//button[text()="Continue"]')) - await waitForElementExistsByCustomSelector( - driver, - By.id('username-input') - ) - await setValue( - driver, - By.id('username-input'), - mailClient.email.split('@')[0] - ) - await click(driver, By.xpath('//span[text()="Next"]')) - await waitForElementExistsByCustomSelector( - driver, - By.xpath('//span[text()="Next"]') - ) - await waitForElementExistsByCustomSelector( - driver, - By.xpath('//h5[text()="Your tabs are doing great things"]') - ) - const firstTitle = await driver.findElements( - By.xpath('//h5[text()="Your tabs are doing great things"]') - ) - expect(firstTitle.length).toEqual(1) - await click(driver, By.xpath('//span[text()="Next"]')) - await waitForElementExistsByCustomSelector( - driver, - By.xpath(`//h5[text()="It doesn't cost you a thing"]`) - ) - const thirdTitle = await driver.findElements( - By.xpath(`//h5[text()="It doesn't cost you a thing"]`) - ) - expect(thirdTitle.length).toEqual(1) - await click(driver, By.xpath('//span[text()="Next"]')) - await waitAndClick(driver, By.xpath(`//span[text()="I'M READY!"]`)) - await new Promise((res) => setTimeout(() => res(), 1000)) - const referralImpactText = await driver.findElements( - By.xpath( - `//p[text()="Your friend started you off with 5 cat treats, which are crucial to getting shelter cats adopted. Open a new tab now to earn your 6th treat! We'll track how many treats you've given on the top of the page:"]` - ) - ) - expect(referralImpactText.length).toEqual(1) - await navigateTo(driver, '/newtab') - const iconPath = '//a[@href="/newtab/account/"]' - await waitAndClick(driver, By.xpath(iconPath)) - await waitForElementExistsByCustomSelector( + await logOut(driver, user1) + } finally { + await driver.quit() + } + }, + testTimeout: testTimeoutdefault, + }, + { + description: + 'should successfully sign up and create a user in Chrome v4 for teamseas', + test: async () => { + const { + driver, + config: { + mailosaur: { MAILOSAUR_API_KEY, MAILOSAUR_SERVER_ID } = {}, + }, + } = getDriver( + 'Tab: acceptance tests: should successfully sign up and create a user in Chrome v4 for teamseas' + ) + try { + const user1 = await EmailClient.build({ + MAILOSAUR_API_KEY, + MAILOSAUR_SERVER_ID, + }) + await setCause(driver, '/teamseas/') + await signUp(driver, user1.email, user1.password) + await completeIntroFlow(driver, user1) + await logOut(driver, user1) + } finally { + await driver.quit() + } + }, + testTimeout: testTimeoutdefault, + }, + { + description: + 'should successfully sign up and create a Referral user in Chrome v4 for teamseas', + test: async () => { + const { + driver, + config: { + mailosaur: { MAILOSAUR_API_KEY, MAILOSAUR_SERVER_ID } = {}, + }, + } = getDriver( + 'Tab: acceptance tests: should successfully sign up and create a Referral user in Chrome v4 for teamseas' + ) + try { + const user1 = await EmailClient.build({ + MAILOSAUR_API_KEY, + MAILOSAUR_SERVER_ID, + }) + await setCause(driver, '/teamseas/?u=test1') + await signUp(driver, user1.email, user1.password) + await completeIntroFlow( driver, - By.xpath(`//p[text()="${mailClient.email}"]`) + user1, + false, + "Your friend gave you a boost: you've already removed 5 plastic water bottles' worth of trash from our rivers and oceans! Open a new tab now to clean up your 6th water bottle. We'll track how many water bottles' worth of trash you've helped clean up on the top of the page:" ) - await waitAndClick(driver, By.xpath('//span[text()="Log Out"]')) - await signIn(driver, mailClient.email, mailClient.password) + await logOut(driver, user1) } finally { await driver.quit() } diff --git a/src/utils/driver-mgr.js b/src/utils/driver-mgr.js index 380666a..0f6f5cb 100644 --- a/src/utils/driver-mgr.js +++ b/src/utils/driver-mgr.js @@ -191,8 +191,33 @@ export const setCats = async (driver) => { By.xpath('//span[text()="Sign in with email"]') ) } +export const setCause = async (driver, landingPath, isReferral = false) => { + await navigateTo(driver, landingPath) + if (isReferral) { + await waitForElementExistsByCustomSelector( + driver, + By.xpath('//div[text()="Your friend sent you a gift"]') + ) + } + await waitAndClick(driver, By.css('button')) + await waitForElementExistsByCustomSelector( + driver, + By.css(`[aria-label='Add to Chrome'`) + ) + await navigateTo(driver, '/newtab/first-tab') + await waitForElementExistsByCustomSelector( + driver, + By.xpath('//span[text()="Sign in with email"]') + ) +} -export const completeIntroFlow = async (driver, mailClient, squads = false) => { +export const completeIntroFlow = async ( + driver, + mailClient, + squads = false, + referralText = null, + text = 'Help more cats with squads' +) => { const link = (await mailClient.getLink()).replace('dev-', 'test-') await driver.navigate().to(link) await waitForElementExistsByCustomSelector( @@ -220,7 +245,7 @@ export const completeIntroFlow = async (driver, mailClient, squads = false) => { ) await waitForElementExistsByCustomSelector( driver, - By.xpath('//h5[text()="Help more cats with squads"]') + By.xpath(`//h5[text()="${text}"]`) ) await click(driver, By.xpath('//span[text()="Next"]')) } @@ -231,6 +256,9 @@ export const completeIntroFlow = async (driver, mailClient, squads = false) => { await click(driver, By.xpath('//span[text()="Next"]')) await waitAndClick(driver, By.xpath(`//span[text()="I'M READY!"]`)) await new Promise((res) => setTimeout(() => res(), 1000)) + if (referralText) { + await driver.findElements(By.xpath(`//h5[text()="${referralText}"]`)) + } await navigateTo(driver, '/newtab') } diff --git a/yarn.lock b/yarn.lock index 206dc02..c977d9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2328,10 +2328,10 @@ chrome-trace-event@^1.0.2: resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== -chromedriver@^93.0.0: - version "93.0.1" - resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-93.0.1.tgz#3ed1f7baa98a754fc1788c42ac8e4bb1ab27db32" - integrity sha512-KDzbW34CvQLF5aTkm3b5VdlTrvdIt4wEpCzT2p4XJIQWQZEPco5pNce7Lu9UqZQGkhQ4mpZt4Ky6NKVyIS2N8A== +chromedriver@^95.0.0: + version "95.0.0" + resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-95.0.0.tgz#ecf854cac6df5137a651dcc132edf55612d3db7f" + integrity sha512-HwSg7S0ZZYsHTjULwxFHrrUqEpz1+ljDudJM3eOquvqD5QKnR5pSe/GlBTY9UU2tVFRYz8bEHYC4Y8qxciQiLQ== dependencies: "@testim/chrome-version" "^1.0.7" axios "^0.21.2"