Skip to content

Commit

Permalink
fix part of #3954 - LearnerDashboardPage.js (#4138)
Browse files Browse the repository at this point in the history
* fix part of #3954 - Learner Dashboard Page

* fixed lint errors

* removed LEARNER_DASHBOARD_URL from general.js

* fixes to learnerDashboard.js

* some fixes and more functions added

* made the review changes

* changed page object names

* added subscription and feedback sections

* made the review changes
  • Loading branch information
aks681 authored and seanlip committed Dec 4, 2017
1 parent 33c82b5 commit 7928a4d
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 51 deletions.
77 changes: 28 additions & 49 deletions core/tests/protractor/learnerDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,23 @@ var general = require('../protractor_utils/general.js');
var LibraryPage = require('../protractor_utils/LibraryPage.js');
var player = require('../protractor_utils/player.js');
var users = require('../protractor_utils/users.js');
var LearnerDashboardPage =
require('../protractor_utils/LearnerDashboardPage.js');

describe('Learner dashboard functionality', function() {
var creatorDashboardPage = null;
var adminPage = null;
var libraryPage = null;

var learnerDashboardPage = null;

beforeEach(function() {
creatorDashboardPage = new CreatorDashboardPage.CreatorDashboardPage();
libraryPage = new LibraryPage.LibraryPage();
});

beforeAll(function() {
adminPage = new AdminPage.AdminPage();
learnerDashboardPage = new LearnerDashboardPage.LearnerDashboardPage();
// Create a new learner.
users.createUser('learner@learnerDashboard.com', 'learnerlearnerDashboard');
users.createUser(
Expand Down Expand Up @@ -78,7 +82,7 @@ describe('Learner dashboard functionality', function() {
general.openPlayer('3');
player.submitAnswer('Continue', null);
browser.ignoreSynchronization = true;
browser.get(general.LEARNER_DASHBOARD_URL);
learnerDashboardPage.get();
general.acceptAlert();
browser.ignoreSynchronization = false;
browser.waitForAngular();
Expand All @@ -91,10 +95,9 @@ describe('Learner dashboard functionality', function() {
player.submitAnswer(
'MultipleChoiceInput', 'Those were all the questions I had!');
player.submitAnswer('Continue', null);
browser.get(general.LEARNER_DASHBOARD_URL);
browser.waitForAngular();
element(by.css('.protractor-test-completed-section')).click();
learnerDashboardPage.get();
browser.waitForAngular();
learnerDashboardPage.navigateToCompletedSection();
libraryPage.expectExplorationToBeVisible('About Oppia');
users.logout();

Expand All @@ -108,7 +111,7 @@ describe('Learner dashboard functionality', function() {
users.logout();

users.login('learner@learnerDashboard.com');
browser.get(general.LEARNER_DASHBOARD_URL);
learnerDashboardPage.get();
browser.waitForAngular();
libraryPage.expectExplorationToBeHidden('Root Linear Coefficient Theorem');
users.logout();
Expand All @@ -129,17 +132,13 @@ describe('Learner dashboard functionality', function() {
// 'In Progress' section.
player.submitAnswer('Continue', null);
browser.ignoreSynchronization = true;
browser.get(general.LEARNER_DASHBOARD_URL);
learnerDashboardPage.get();
general.acceptAlert();
browser.waitForAngular();
general.waitForSystem();
browser.ignoreSynchronization = false;
element(by.css('.protractor-test-incomplete-collection-section')).click();
browser.waitForAngular();
general.waitForSystem();
expect(element.all(by.css(
'.protractor-test-collection-summary-tile-title')).first(
).getText()).toMatch('Test Collection');
learnerDashboardPage.navigateToIncompleteCollectionsSection();
learnerDashboardPage.expectTitleOfSummaryTileToMatch('Test Collection');

// Go to the test collection.
browser.get('/search/find?q=');
Expand All @@ -157,18 +156,13 @@ describe('Learner dashboard functionality', function() {
player.submitAnswer(
'MultipleChoiceInput', 'Those were all the questions I had!');
player.submitAnswer('Continue', null);
browser.get(general.LEARNER_DASHBOARD_URL);
browser.waitForAngular();
general.waitForSystem();
element(by.css('.protractor-test-completed-section')).click();
learnerDashboardPage.get();
browser.waitForAngular();
general.waitForSystem();
element(by.css('.protractor-test-completed-collection-section')).click();
browser.waitForAngular();
learnerDashboardPage.navigateToCompletedSection();
general.waitForSystem();
expect(element.all(by.css(
'.protractor-test-collection-summary-tile-title')).first(
).getText()).toMatch('Test Collection');
learnerDashboardPage.navigateToCompletedCollectionsSection();
learnerDashboardPage.expectTitleOfSummaryTileToMatch('Test Collection');
users.logout();

users.login('creator1@learnerDashboard.com');
Expand All @@ -192,15 +186,11 @@ describe('Learner dashboard functionality', function() {
users.logout();

users.login('learner@learnerDashboard.com');
browser.get(general.LEARNER_DASHBOARD_URL);
browser.waitForAngular();
general.waitForSystem();
element(by.css('.protractor-test-incomplete-collection-section')).click();
learnerDashboardPage.get();
browser.waitForAngular();
general.waitForSystem();
expect(element.all(by.css(
'.protractor-test-collection-summary-tile-title')).first(
).getText()).toMatch('Test Collection');
learnerDashboardPage.navigateToIncompleteCollectionsSection();
learnerDashboardPage.expectTitleOfSummaryTileToMatch('Test Collection');
users.logout();
});

Expand All @@ -217,17 +207,12 @@ describe('Learner dashboard functionality', function() {

// Both creators should be present in the subscriptions section of the
// dashboard.
browser.get(general.LEARNER_DASHBOARD_URL);
learnerDashboardPage.get();
browser.waitForAngular();
general.waitForSystem();
element(by.css('.protractor-test-subscriptions-section')).click();
browser.waitForAngular();
expect(element.all(by.css(
'.protractor-test-subscription-name')).first().getText()).toMatch(
'creator...');
expect(element.all(by.css(
'.protractor-test-subscription-name')).last().getText()).toMatch(
'creator...');
learnerDashboardPage.navigateToSubscriptionsSection();
learnerDashboardPage.expectSubscriptionFirstNameToMatch('creator...');
learnerDashboardPage.expectSubscriptionLastNameToMatch('creator...');
users.logout();
});

Expand All @@ -242,18 +227,12 @@ describe('Learner dashboard functionality', function() {
'MultipleChoiceInput', 'Those were all the questions I had!');
player.submitAnswer('Continue', null);
player.submitFeedback(feedback);
browser.get(general.LEARNER_DASHBOARD_URL);
browser.waitForAngular();
element(by.css('.protractor-test-feedback-section')).click();
browser.waitForAngular();
expect(element.all(by.css(
'.protractor-test-feedback-exploration')).first().getText()).toMatch(
'About Oppia');
element(by.css('.protractor-test-feedback-thread')).click();
learnerDashboardPage.get();
browser.waitForAngular();
expect(element.all(by.css(
'.protractor-test-feedback-message')).first().getText()).toMatch(
feedback);
learnerDashboardPage.navigateToFeedbackSection();
learnerDashboardPage.expectFeedbackExplorationTitleToMatch('About Oppia');
learnerDashboardPage.navigateToFeedbackThread();
learnerDashboardPage.expectFeedbackMessageToMatch(feedback);
users.logout();
});

Expand Down
112 changes: 112 additions & 0 deletions core/tests/protractor_utils/LearnerDashboardPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright 2017 The Oppia Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @fileoverview Page object for the learner dashboard, for use in Protractor
* tests.
*/

var general = require('./general.js');

var LearnerDashboardPage = function() {
var LEARNER_DASHBOARD_URL = '/learner_dashboard';
var completedSection =
element(by.css('.protractor-test-completed-section'));
var feedbackSection =
element(by.css('.protractor-test-feedback-section'));
var feedbackThread =
element(by.css('.protractor-test-feedback-thread'));
var completedCollectionsSection =
element(by.css('.protractor-test-completed-collection-section'));
var incompleteCollectionsSection =
element(by.css('.protractor-test-incomplete-collection-section'));
var subscriptionsSection =
element(by.css('.protractor-test-subscriptions-section'));
var subscriptionName =
element.all(by.css('.protractor-test-subscription-name'));
var titleOfSummaryTile =
element.all(by.css('.protractor-test-collection-summary-tile-title'));
var feedbackExplorationTitle =
element.all(by.css('.protractor-test-feedback-exploration'));
var feedbackMessage =
element.all(by.css('.protractor-test-feedback-message'));

this.get = function() {
return browser.get(LEARNER_DASHBOARD_URL);
};

this.navigateToCompletedSection = function() {
completedSection.click();
browser.waitForAngular();
};

this.navigateToIncompleteCollectionsSection = function() {
incompleteCollectionsSection.click();
browser.waitForAngular();
general.waitForSystem();
};

this.navigateToCompletedCollectionsSection = function() {
completedCollectionsSection.click();
browser.waitForAngular();
general.waitForSystem();
};

this.navigateToFeedbackSection = function() {
feedbackSection.click();
browser.waitForAngular();
};

this.navigateToFeedbackThread = function() {
feedbackThread.click();
browser.waitForAngular();
};

this.navigateToSubscriptionsSection = function() {
subscriptionsSection.click();
browser.waitForAngular();
};

this.expectTitleOfSummaryTileToMatch = function(title) {
expect(
titleOfSummaryTile.first().getText()
).toMatch(title);
};

this.expectSubscriptionFirstNameToMatch = function(name) {
expect(
subscriptionName.first().getText()
).toMatch(name);
};

this.expectSubscriptionLastNameToMatch = function(name) {
expect(
subscriptionName.last().getText()
).toMatch(name);
};

this.expectFeedbackExplorationTitleToMatch = function(title) {
expect(
feedbackExplorationTitle.first().getText()
).toMatch(title);
};

this.expectFeedbackMessageToMatch = function(message) {
expect(
feedbackMessage.first().getText()
).toMatch(message);
};
};

exports.LearnerDashboardPage = LearnerDashboardPage;
2 changes: 0 additions & 2 deletions core/tests/protractor_utils/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ var checkForConsoleErrors = function(errorsToIgnore) {
var SERVER_URL_PREFIX = 'http://localhost:9001';
var EDITOR_URL_SLICE = '/create/';
var PLAYER_URL_SLICE = '/explore/';
var LEARNER_DASHBOARD_URL = '/learner_dashboard';
var USER_PREFERENCES_URL = '/preferences';
var LOGIN_URL_SUFFIX = '/_ah/login';
var MODERATOR_URL_SUFFIX = '/moderator';
Expand Down Expand Up @@ -165,7 +164,6 @@ exports.scrollToTop = scrollToTop;
exports.checkForConsoleErrors = checkForConsoleErrors;

exports.SERVER_URL_PREFIX = SERVER_URL_PREFIX;
exports.LEARNER_DASHBOARD_URL = LEARNER_DASHBOARD_URL;
exports.USER_PREFERENCES_URL = USER_PREFERENCES_URL;
exports.EDITOR_URL_SLICE = EDITOR_URL_SLICE;
exports.LOGIN_URL_SUFFIX = LOGIN_URL_SUFFIX;
Expand Down

0 comments on commit 7928a4d

Please sign in to comment.