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

fix part of #3954 - LearnerDashboardPage.js #4138

Merged
merged 9 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix part of #3954 - Learner Dashboard Page
  • Loading branch information
aks681 committed Dec 1, 2017
commit 3eb5ecdc36078f36280d3fcd122541614a3cc293
48 changes: 18 additions & 30 deletions core/tests/protractor/learnerDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ 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();
learnerDashboardPage = new LearnerDashboardPage.LearnerDashboardPage();
});

beforeAll(function() {
Expand All @@ -50,23 +54,11 @@ describe('Learner dashboard functionality', function() {
adminPage.reloadAllExplorations();
adminPage.updateRole(USERNAME, 'collection editor');
browser.get(general.SERVER_URL_PREFIX);
var dropdown = element(by.css('.protractor-test-profile-dropdown'));
browser.actions().mouseMove(dropdown).perform();
dropdown.element(by.css('.protractor-test-dashboard-link')).click();
browser.waitForAngular();
learnerDashboard.selectDropdown();
element(by.css('.protractor-test-create-activity')).click();
// Create new collection.
element(by.css('.protractor-test-create-collection')).click();
browser.waitForAngular();
collectionEditor.addExistingExploration('14');
collectionEditor.saveDraft();
collectionEditor.closeSaveModal();
collectionEditor.publishCollection();
collectionEditor.setTitle('Test Collection');
collectionEditor.setObjective('This is a test collection.');
collectionEditor.setCategory('Algebra');
collectionEditor.saveChanges();
browser.waitForAngular();
learnerDashboard.createExploration();
learnerDashboard.publishExploration();
users.logout();
});

Expand All @@ -78,7 +70,7 @@ describe('Learner dashboard functionality', function() {
general.openPlayer('3');
player.submitAnswer('Continue', null);
browser.ignoreSynchronization = true;
browser.get(general.LEARNER_DASHBOARD_URL);
learnerDashboard.get();
general.acceptAlert();
browser.ignoreSynchronization = false;
browser.waitForAngular();
Expand All @@ -91,7 +83,7 @@ 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);
learnerDashboard.get();
browser.waitForAngular();
element(by.css('.protractor-test-completed-section')).click();
browser.waitForAngular();
Expand All @@ -108,7 +100,7 @@ describe('Learner dashboard functionality', function() {
users.logout();

users.login('learner@learnerDashboard.com');
browser.get(general.LEARNER_DASHBOARD_URL);
learnerDashboard.get();
browser.waitForAngular();
libraryPage.expectExplorationToBeHidden('Root Linear Coefficient Theorem');
users.logout();
Expand All @@ -129,7 +121,7 @@ describe('Learner dashboard functionality', function() {
// 'In Progress' section.
player.submitAnswer('Continue', null);
browser.ignoreSynchronization = true;
browser.get(general.LEARNER_DASHBOARD_URL);
learnerDashboard.get();
general.acceptAlert();
browser.waitForAngular();
general.waitForSystem();
Expand Down Expand Up @@ -157,7 +149,7 @@ 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);
learnerDashboard.get();
browser.waitForAngular();
general.waitForSystem();
element(by.css('.protractor-test-completed-section')).click();
Expand Down Expand Up @@ -192,7 +184,7 @@ describe('Learner dashboard functionality', function() {
users.logout();

users.login('learner@learnerDashboard.com');
browser.get(general.LEARNER_DASHBOARD_URL);
learnerDashboard.get();
browser.waitForAngular();
general.waitForSystem();
element(by.css('.protractor-test-incomplete-collection-section')).click();
Expand All @@ -208,16 +200,12 @@ describe('Learner dashboard functionality', function() {
users.login('learner@learnerDashboard.com');

// Subscribe to both the creators.
browser.get('/profile/creator1learnerDashboard');
browser.waitForAngular();
element(by.css('.protractor-test-subscription-button')).click();
browser.get('/profile/creator2learnerDashboard');
browser.waitForAngular();
element(by.css('.protractor-test-subscription-button')).click();
learnerDashboard.subscribeCreatorOne();
learnerDashboard.subscribeCreatorTwo();

// Both creators should be present in the subscriptions section of the
// dashboard.
browser.get(general.LEARNER_DASHBOARD_URL);
learnerDashboard.get();
browser.waitForAngular();
general.waitForSystem();
element(by.css('.protractor-test-subscriptions-section')).click();
Expand All @@ -242,7 +230,7 @@ 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);
learnerDashboard.get();
browser.waitForAngular();
element(by.css('.protractor-test-feedback-section')).click();
browser.waitForAngular();
Expand Down
70 changes: 70 additions & 0 deletions core/tests/protractor_utils/LearnerDashboardPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// 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 collectionEditor = require('./collectionEditor.js');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was there as I was calling it before. Forgot to remove it. Will change that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


var LearnerDashboardPage = function() {
var LEARNER_DASHBOARD_URL = '/learner_dashboard';
var dropdown = element(by.css('.protractor-test-profile-dropdown'));
var subscriptionButton =
element(by.css('.protractor-test-subscription-button'));
var createCollection = element(by.css('.protractor-test-create-collection'));

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

this.subscribeCreatorOne = function() {
browser.get('/profile/creator1learnerDashboard');
browser.waitForAngular();
subscriptionButton.click();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolons, here and below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, didn't see those. Will add them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


this.subscribeCreatorOne = function() {
browser.get('/profile/creator2learnerDashboard');
browser.waitForAngular();
subscriptionButton.click();
}

this.selectDropdown = function() {
browser.actions().mouseMove(dropdown).perform();
dropdown.element(by.css('.protractor-test-dashboard-link')).click();
browser.waitForAngular();
}

this.createExploration = function() {
createCollection.click();
browser.waitForAngular();
}

this.publishExploration = function() {
collectionEditor.addExistingExploration('14');
collectionEditor.saveDraft();
collectionEditor.closeSaveModal();
collectionEditor.publishCollection();
collectionEditor.setTitle('Test Collection');
collectionEditor.setObjective('This is a test collection.');
collectionEditor.setCategory('Algebra');
collectionEditor.saveChanges();
browser.waitForAngular();
};

};

exports.LearnerDashboardPage = LearnerDashboardPage;