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
Prev Previous commit
Next Next commit
added subscription and feedback sections
  • Loading branch information
aks681 committed Dec 4, 2017
commit 00ced47eec688c8e3b225cff2c948f34e08b2d13
30 changes: 8 additions & 22 deletions core/tests/protractor/learnerDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ describe('Learner dashboard functionality', function() {
learnerDashboardPage.navigateToIncompleteCollectionsSection();
browser.waitForAngular();
Copy link
Member

Choose a reason for hiding this comment

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

It might be better to put these browser.waitForAngular() calls at the end of their respective functions in the page object, if they're always going to be called. This will also help simplify the main protractor test.

Ditto for general.waitForSystem(), where relevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there are are other calls to learnerDashboardPage that are repeating for all such instances, shall I put it inside page object also?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I don't understand. Could you elaborate / give an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after both instances of navigateToIncompleteCollectionsSection(), expectTitleOfSummaryTileToMatch() is called, so can I put this call as this.expectTitleOfSummaryTileToMatch() inside the navigateToIncompleteCollectionsSection() function?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. No, don't do that.

The way to think about this is that these are the actions a user would do. A user wouldn't really be doing stuff at the level of "wait for angular". But they may take the actions "navigate" and "expect title to match" independently, so these should be independent actions in the page object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thanks.

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

general.waitForSystem();
expect(
learnerDashboardPage.getTitleOfSummaryTile()
).toMatch('Test Collection');
learnerDashboardPage.expectTitleOfSummaryTileToMatch('Test Collection');

// Go to the test collection.
browser.get('/search/find?q=');
Expand All @@ -170,9 +168,7 @@ describe('Learner dashboard functionality', function() {
learnerDashboardPage.navigateToCompletedCollectionsSection();
browser.waitForAngular();
general.waitForSystem();
expect(
learnerDashboardPage.getTitleOfSummaryTile()
).toMatch('Test Collection');
learnerDashboardPage.expectTitleOfSummaryTileToMatch('Test Collection');
users.logout();

users.login('creator1@learnerDashboard.com');
Expand Down Expand Up @@ -202,9 +198,7 @@ describe('Learner dashboard functionality', function() {
learnerDashboardPage.navigateToIncompleteCollectionsSection();
browser.waitForAngular();
general.waitForSystem();
expect(
learnerDashboardPage.getTitleOfSummaryTile()
).toMatch('Test Collection');
learnerDashboardPage.expectTitleOfSummaryTileToMatch('Test Collection');
users.logout();
});

Expand All @@ -226,12 +220,8 @@ describe('Learner dashboard functionality', function() {
general.waitForSystem();
learnerDashboardPage.navigateToSubscriptionsSection();
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.expectSubscriptionFirstNameToMatch('creator...');
learnerDashboardPage.expectSubscriptionLastNameToMatch('creator...');
users.logout();
});

Expand All @@ -250,14 +240,10 @@ describe('Learner dashboard functionality', function() {
browser.waitForAngular();
learnerDashboardPage.navigateToFeedbackSection();
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.expectFeedbackExplorationTitleToMatch('About Oppia');
learnerDashboardPage.navigateToFeedbackThread();
browser.waitForAngular();
expect(element.all(by.css(
'.protractor-test-feedback-message')).first().getText()).toMatch(
feedback);
learnerDashboardPage.expectFeedbackMessageToMatch(feedback);
users.logout();
});

Expand Down
42 changes: 40 additions & 2 deletions core/tests/protractor_utils/LearnerDashboardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@ var LearnerDashboardPage = function() {
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);
Expand All @@ -54,12 +62,42 @@ var LearnerDashboardPage = function() {
feedbackSection.click();
};

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

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

this.getTitleOfSummaryTile = function() {
return titleOfSummaryTile.first().getText();
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);
};
};

Expand Down