Skip to content

Instantly share code, notes, and snippets.

@wlsf82
Created January 9, 2017 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wlsf82/ceb3bc8cda5ab46d75dfea2a43270e67 to your computer and use it in GitHub Desktop.
Save wlsf82/ceb3bc8cda5ab46d75dfea2a43270e67 to your computer and use it in GitHub Desktop.
"use strict";
const AppearInRoom = require("../page-objects/appearInRoom");
const Helper = require("../helper");
const RoomActivity = require("../page-objects/roomActivity");
const shortid = require("shortid");
describe("Activity list", () => {
const appearInRoom = new AppearInRoom();
const helper = new Helper();
const roomActivity = new RoomActivity();
let randomRoomName;
beforeEach(() => {
randomRoomName = shortid.generate();
appearInRoom.visit(randomRoomName);
helper.clickWhenClickable(roomActivity.refreshButton);
helper.sleepForNSeconds(3);
});
it("should arrive with opened activity list and closes it", () => {
const attribute = "class";
const value = "ng-scope ng-isolate-scope open";
expect(roomActivity.activityList.getAttribute(attribute)).toEqual(value);
roomActivity.roomActivityButton.click();
helper.waitForElementWithAttributeNotToHaveValue(roomActivity.activityList, attribute, value);
expect(roomActivity.activityList.getAttribute(attribute)).not.toContain(value);
});
it("should access a room from the activity list", () => {
browser.getCurrentUrl().then((url) => {
const secondRandomRoomName = shortid.generate();
const lowerCasedUrl = url.toLowerCase();
appearInRoom.visit(secondRandomRoomName);
helper.clickWhenClickable(roomActivity.refreshButton);
helper.sleepForNSeconds(3);
roomActivity.listItems.filter((elem) => {
return elem.getText().then((text) => {
return text === randomRoomName.toLowerCase();
});
}).click();
helper.waitForUrlToBeEqualTo(lowerCasedUrl);
const currentUrl = browser.getCurrentUrl();
expect(currentUrl).toEqual(lowerCasedUrl);
});
});
it("should remove item from the activity list", () => {
roomActivity.listItems.count().then((numberOfItemsBeforeRemoval) => {
roomActivity.removeFirstItem();
roomActivity.waitForActivityListToHaveSpecificNumberOfItems(roomActivity.listItems, numberOfItemsBeforeRemoval - 1);
roomActivity.listItems.count().then((numberOfItemsAfterRemoval) => {
roomActivity.waitForActivityListToHaveSpecificNumberOfItems(numberOfItemsBeforeRemoval - 1);
expect(numberOfItemsAfterRemoval).toEqual(numberOfItemsBeforeRemoval - 1);
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment