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

Resolution/Mateus F Torres #1

Closed
wants to merge 11 commits into from
5 changes: 5 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
["@babel/preset-env", {"useBuiltIns": "usage", "corejs": "3.6"}]
]
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.idea
.yarn/*
! .yarn/cache
! .yarn/releases
! .yarn/plugins
! .yarn/sdks
! .yarn/versions
17,087 changes: 17,087 additions & 0 deletions .pnp.js

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions .yarn/releases/yarn-berry.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
yarnPath: ".yarn/releases/yarn-berry.js"

packageExtensions:
"jest-environment-puppeteer@*":
peerDependencies:
puppeteer: "*"
dependencies:
jest-environment-node: "*"
50 changes: 50 additions & 0 deletions __tests__/demo.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import {expectToBeVisible, expectToBeHidden} from "./helpers";

/** Provide longer timeout for Jest async test runs
* or Jest will close before Puppeteer can run
*/
const TIMEOUT = 10000

/* DOM Selector Queries */
const SEARCH_FORM = 'form[name="gbqf"]'
const SEARCH_FORM_INPUT = 'input[name="q"]'
const READ_MORE_BUTTON = 'div[jsname="xBmnf"]'

describe('Google Play | PEPapp - PepsiCo', () => {
test('Load Google Play store', async () => {
await page.goto(URL, {waitUntil: 'networkidle0'});
const url = await page.url()
const title = await page.title()

expect(url).toMatch('play.google.com/store')
expect(title).toMatch('Google Play')
}, TIMEOUT)

test('Search for "pepapp"', async () => {
const form = await page.waitForSelector(SEARCH_FORM)
await expect(form).toFill(SEARCH_FORM_INPUT, 'pepapp', {delay: 100})
await form.press('Enter')

await page.waitFor(500)
await expect(page).toMatch('PEPapp - PepsiCo')
}, TIMEOUT)

test('Open PEPapp - PepsiCo details page', async () => {
await expect(page).toClick('a', {text: /PEPapp/})
await page.waitFor(500)
const url = await page.url()

expect(url).toMatch(/details\?id=br\.com\.eusoupepsico/)
}, TIMEOUT)

test('Toggle Read More description', async () => {
await expectToBeVisible(READ_MORE_BUTTON)

const button = await page.$(READ_MORE_BUTTON)
await expect(button).toClick('*')

await page.waitFor(500)

await expectToBeHidden(READ_MORE_BUTTON)
}, TIMEOUT)
})
7 changes: 7 additions & 0 deletions __tests__/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export async function expectToBeVisible(query) {
await expect(page.waitForSelector(query, {visible: true})).resolves
}

export async function expectToBeHidden(query) {
await expect(page.waitForSelector(query, {hidden: true})).resolves
}
3 changes: 3 additions & 0 deletions __tests__/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'expect-puppeteer'

global.URL = "https://play.google.com/"
9 changes: 9 additions & 0 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
launch: {
headless: false,
slowMo: false,
devtools: false
},
browserContext: "default",
};

5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: 'jest-puppeteer',
setupFilesAfterEnv: ['<rootDir>/__tests__/setup.js'],
testMatch: ['<rootDir>/__tests__/*.spec.js']
}
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "dialog-e2e-test",
"version": "0.0.1",
"main": "index.js",
"repository": "git@github.com:mateus-f-torres/dialog-e2e-test",
"author": "mateus-f-torres <mateusfigtorres@gmail.com>",
"license": "MIT",
"private": true,
"scripts": {
"test": "jest -i"
},
"devDependencies": {
"@babel/core": "^7.11.4",
"@babel/preset-env": "^7.11.0",
"babel-jest": "^26.3.0",
"core-js": "^3.6.5",
"expect-puppeteer": "^4.4.0",
"jest": "^26.4.2",
"jest-environment-puppeteer": "^4.4.0",
"jest-puppeteer": "^4.4.0",
"puppeteer": "^5.2.1",
"regenerator-runtime": "^0.13.7"
}
}