Created
January 4, 2017 11:06
-
-
Save wlsf82/e53aa443c7ead2f23d0bf0370a557e44 to your computer and use it in GitHub Desktop.
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
// helper.js file | |
"use strict"; | |
const expectedConditionTimeout = 10000; | |
function elementWithAttributeHasValue(htmlElement, attribute, value) { | |
return htmlElement.getAttribute(attribute).then((elementAttribute) => { | |
return elementAttribute.includes(value); | |
}); | |
} | |
function elementWithAttributeHasNotValue(htmlElement, attribute, value) { | |
return htmlElement.getAttribute(attribute).then((elementAttribute) => { | |
return !elementAttribute.includes(value); | |
}); | |
} | |
class Helper { | |
waitForElementWithAttributeToHaveValue(htmlElement, attribute, value, timeout = expectedConditionTimeout) { | |
browser.wait(elementWithAttributeHasValue(htmlElement, attribute, value), timeout); | |
} | |
waitForElementWithAttributeNotToHaveValue(htmlElement, attribute, value, timeout = expectedConditionTimeout) { | |
browser.wait(elementWithAttributeHasNotValue(htmlElement, attribute, value), timeout); | |
} | |
} | |
---------------------------------------------------------------------------------------------------------------- | |
// spec.js file | |
"use strict"; | |
const AppearInRoom = require("../page-objects/appearInRoom"); | |
const ClaimRoom = require("../page-objects/claimRoom"); | |
const Helper = require("../helper"); | |
const shortid = require("shortid"); | |
const UserLoggedIn = require("../page-objects/userLoggedIn"); | |
describe("Logged in user", () => { | |
const appearInRoom = new AppearInRoom(); | |
const claimRoom = new ClaimRoom(); | |
const helper = new Helper(); | |
const userLoggedIn = new UserLoggedIn(); | |
beforeAll(() => { | |
const randomRoomName = shortid.generate(); | |
const randomEmail = helper.getRandomEmailForSignUp(); | |
const type = "email"; | |
appearInRoom.visit(randomRoomName); | |
helper.signUp(randomRoomName, randomEmail, type); | |
}); | |
beforeEach(() => { | |
const randomRoomName = shortid.generate(); | |
appearInRoom.visit(randomRoomName); | |
helper.waitForElementVisibility(userLoggedIn.avatar); | |
}); | |
afterAll(() => { | |
helper.logout(); | |
}); | |
it("should open and close claim room modal", () => { | |
const attribute = "class"; | |
const value = "ng-hide"; | |
helper.clickWhenClickable(appearInRoom.topBarClaimButton); | |
helper.waitForElementWithAttributeNotToHaveValue(claimRoom.modal, attribute, value); | |
expect(claimRoom.modal.getAttribute(attribute)).not.toContain(value); | |
claimRoom.closeButton.click(); | |
helper.waitForElementWithAttributeToHaveValue(claimRoom.modal, attribute, value); | |
expect(claimRoom.modal.getAttribute(attribute)).toContain(value); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment