This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
20 add popups handling #117
Open
JelenaRy
wants to merge
6
commits into
master
Choose a base branch
from
20-add-popups-handling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8ae7105
[20] Updated Helpers to handle popups. Added tests
5ddaa1a
[20] Updated Element to use page or use global one by default
fbbb198
[20] Updated test selector for test
047152e
[20] Updating interceptor class and tests to contain page
af0b429
[20] Removed unused import, empty line
5a19cc1
[20] Updated initialization of child Element
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,30 @@ import { Element, Interceptor } from "test-juggler"; | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3 tests are failing in interceptor suite:
|
||
const DemoQaSite = "https://demoqa.com/books"; | ||
const DemoOpenCartSite = "https://demo.opencart.com/"; | ||
const successMessage = new Element(".alert-success"); | ||
const addToCartButton = new Element(".product-layout:nth-child(1) > div button:nth-child(1)"); | ||
const loadingWrapper = new Element("#loading-wrapper"); | ||
const booksWrapper = new Element(".books-wrapper"); | ||
let page; | ||
let successMessage; | ||
let addToCartButton; | ||
let loadingWrapper; | ||
let booksWrapper; | ||
let interceptor; | ||
|
||
describe("Interceptor", () => { | ||
beforeEach(async () => { | ||
console.log(`Running test: '${jasmine["currentTest"].fullName}'`); | ||
//this is workaraound to avoid 'Request is already handled!' error. Shoud be removed when https://github.com/smooth-code/jest-puppeteer/issues/308 defect is fixed. | ||
const context = await browser.newContext(); | ||
page = await context.newPage(); | ||
successMessage = new Element(".alert-success", page); | ||
addToCartButton = new Element(".product-layout:nth-child(1) > div button:nth-child(1)", page); | ||
loadingWrapper = new Element("#loading-wrapper", page); | ||
booksWrapper = new Element(".books-wrapper", page); | ||
interceptor = new Interceptor(page); | ||
}); | ||
|
||
it("should block requests by any url fragment using Regex pattern while test case running", async () => { | ||
//Arrange | ||
const requestUrlRegex = /BookStore/; | ||
await Interceptor.abortRequests(requestUrlRegex); | ||
await interceptor.abortRequests(requestUrlRegex); | ||
|
||
//Act | ||
await page.goto(DemoQaSite); | ||
|
@@ -41,13 +48,13 @@ describe("Interceptor", () => { | |
|
||
//Act | ||
await page.goto(DemoQaSite); | ||
await loadingWrapper.waitUntilInvisible(); | ||
await booksWrapper.waitUntilVisible(); | ||
|
||
//Assert | ||
await expect(booksWrapper.exists()).resolves.toBeTruthy(); | ||
|
||
//Act | ||
await Interceptor.abortRequests(requestUrlGlob); | ||
await interceptor.abortRequests(requestUrlGlob); | ||
await page.reload(); | ||
await loadingWrapper.waitUntilVisible(); | ||
|
||
|
@@ -59,7 +66,7 @@ describe("Interceptor", () => { | |
//Arrange | ||
|
||
const requestUrlGlob = "**/BookStore/**"; | ||
await Interceptor.abortRequestsAfterAction(page.goto(DemoQaSite), requestUrlGlob); | ||
await interceptor.abortRequestsAfterAction(page.goto(DemoQaSite), requestUrlGlob); | ||
|
||
//Assert | ||
await loadingWrapper.waitUntilVisible(); | ||
|
@@ -69,7 +76,7 @@ describe("Interceptor", () => { | |
|
||
//Act | ||
await page.reload(); | ||
await loadingWrapper.waitUntilInvisible(); | ||
await booksWrapper.waitUntilVisible(); | ||
|
||
//Assert | ||
await expect(booksWrapper.exists()).resolves.toBeTruthy(); | ||
|
@@ -86,7 +93,7 @@ describe("Interceptor", () => { | |
}); | ||
|
||
//Act | ||
await Interceptor.abortRequestsAfterAction(addToCartButton.click()); | ||
await interceptor.abortRequestsAfterAction(addToCartButton.click()); | ||
|
||
//Assert | ||
await expect(successMessage.isVisible()).resolves.toBeFalsy(); | ||
|
@@ -95,7 +102,7 @@ describe("Interceptor", () => { | |
|
||
it("should count all requests", async () => { | ||
//Act | ||
var totalRequests = await Interceptor.getAllRequestsData(page.goto(DemoOpenCartSite)); | ||
var totalRequests = await interceptor.getAllRequestsData(page.goto(DemoOpenCartSite)); | ||
|
||
//Assert | ||
expect(totalRequests.length > 0).toBeTruthy(); | ||
|
@@ -108,7 +115,7 @@ describe("Interceptor", () => { | |
await page.goto(DemoOpenCartSite); | ||
|
||
//Act | ||
var responseAfterAction = await Interceptor.waitForResponseAfterAction(addToCartButton.click(), responseUrlFragment); | ||
var responseAfterAction = await interceptor.waitForResponseAfterAction(addToCartButton.click(), responseUrlFragment); | ||
|
||
//Assert | ||
await expect(successMessage.isVisible()).resolves.toBeTruthy(); | ||
|
@@ -122,7 +129,7 @@ describe("Interceptor", () => { | |
await page.goto(DemoOpenCartSite); | ||
|
||
//Act | ||
var requestAfterAction = await Interceptor.waitForRequestAfterAction(addToCartButton.click()); | ||
var requestAfterAction = await interceptor.waitForRequestAfterAction(addToCartButton.click()); | ||
|
||
//Assert | ||
await expect(successMessage.isVisible()).resolves.toBeTruthy(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two lint issues:
C:\source\test-juggler\example\tests\helpers.test.js
107:1 error Mixed spaces and tabs no-mixed-spaces-and-tabs
122:1 error Mixed spaces and tabs no-mixed-spaces-and-tabs
✖ 2 problems (2 errors, 0 warnings)