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

Implement part of #17712 : Acceptance tests for Exploration Creator Section(CUJ 10). #20203

Merged
merged 65 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
60e18a2
saveDraft spec
rahat2134 Apr 23, 2024
35fd534
change
rahat2134 Apr 23, 2024
8acdeb1
change
rahat2134 Apr 23, 2024
e892a74
change
rahat2134 Apr 23, 2024
dc9bdf8
Merge branch 'develop' into ExplorationEditor_
rahat2134 Apr 23, 2024
940a919
Merge branch 'develop' into ExplorationEditor_
rahat2134 Apr 24, 2024
d129dd7
changes
rahat2134 Apr 24, 2024
5679fba
changes
rahat2134 Apr 24, 2024
1694b1f
Merge branch 'develop' of https://github.com/oppia/oppia into Explora…
rahat2134 Apr 24, 2024
6646a83
Merge branch 'ExplorationEditor_' of https://github.com/rahat2134/opp…
rahat2134 Apr 24, 2024
87e718a
changes
rahat2134 Apr 24, 2024
db62083
changes
rahat2134 Apr 24, 2024
7e27a5e
Merge branch 'develop' into ExplorationEditor_
rahat2134 Apr 25, 2024
41993cc
Merge branch 'develop' into ExplorationEditor_
rahat2134 Apr 25, 2024
ee7a5ac
changes-> waitForPageToFullyLoad,...
rahat2134 Apr 26, 2024
cc09bd6
Merge branch 'develop' of https://github.com/oppia/oppia into Explora…
rahat2134 Apr 26, 2024
5a4b699
Merge branch 'ExplorationEditor_' of https://github.com/rahat2134/opp…
rahat2134 Apr 26, 2024
b3336ca
resolve merge conflict
rahat2134 Apr 27, 2024
92c6bda
correct function name in new PR
rahat2134 Apr 27, 2024
6cb4377
Merge branch 'develop' into ExplorationEditor_
rahat2134 Apr 27, 2024
96055da
Merge branch 'develop' into ExplorationEditor_
rahat2134 Apr 27, 2024
2b0696b
Merge branch 'develop' into ExplorationEditor_
rahat2134 Apr 27, 2024
2f3ce5c
Merge branch 'develop' into ExplorationEditor_
rahat2134 Apr 30, 2024
33cd472
Merge branch 'develop' into ExplorationEditor_
rahat2134 May 1, 2024
563badb
Merge branch 'develop' into ExplorationEditor_
rahat2134 May 6, 2024
2342c99
Merge branch 'develop' of https://github.com/oppia/oppia into Explora…
rahat2134 May 8, 2024
86f6696
Merge branch 'develop' into ExplorationEditor_
rahat2134 May 8, 2024
c03be55
removed timeout
rahat2134 May 8, 2024
ae0dca2
Merge branch 'ExplorationEditor_' of https://github.com/rahat2134/opp…
rahat2134 May 8, 2024
ee3eab4
Merge branch 'develop' into ExplorationEditor_
rahat2134 May 15, 2024
dbf8ad9
Merge branch 'develop' of https://github.com/oppia/oppia into Explora…
rahat2134 May 19, 2024
c9b86e2
Merge branch 'develop' into ExplorationEditor_
rahat2134 May 21, 2024
4b0771d
Merge branch 'develop' of https://github.com/oppia/oppia into Explora…
rahat2134 May 22, 2024
e99c3a0
div -> button
rahat2134 May 22, 2024
421ef21
change
rahat2134 May 22, 2024
94d8192
Merge branch 'ExplorationEditor_' of https://github.com/rahat2134/opp…
rahat2134 May 22, 2024
fc23f6d
Merge branch 'develop' into ExplorationEditor_
rahat2134 May 27, 2024
30809ea
Merge branch 'develop' of https://github.com/oppia/oppia into Explora…
rahat2134 May 28, 2024
0af42ef
Merge branch 'ExplorationEditor_' of https://github.com/rahat2134/opp…
rahat2134 May 28, 2024
292ab19
remove-extra-regex
rahat2134 May 28, 2024
09a9265
merge conflict
rahat2134 May 31, 2024
5a0d3be
Merge branch 'develop' into ExplorationEditor_
rahat2134 May 31, 2024
b56a41b
Merge branch 'develop' of https://github.com/oppia/oppia into Explora…
rahat2134 Jun 2, 2024
50de4ff
Merge branch 'ExplorationEditor_' of https://github.com/rahat2134/opp…
rahat2134 Jun 2, 2024
3975bc9
changes
rahat2134 Jun 2, 2024
82d976a
changes
rahat2134 Jun 2, 2024
450220e
changes
rahat2134 Jun 2, 2024
ddb3ee7
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 4, 2024
c01317e
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 4, 2024
fec2046
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 5, 2024
a07dd38
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 6, 2024
e77d313
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 10, 2024
77c3504
Merge branch 'develop' of https://github.com/oppia/oppia into Explora…
rahat2134 Jun 10, 2024
7c5634e
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 10, 2024
0d20eb7
autosave indicator to a variable
rahat2134 Jun 10, 2024
39dad78
Merge branch 'ExplorationEditor_' of https://github.com/rahat2134/opp…
rahat2134 Jun 10, 2024
d1117a6
changes
rahat2134 Jun 10, 2024
901149e
merge conflict
rahat2134 Jun 11, 2024
cf492ed
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 11, 2024
93da30b
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 12, 2024
2781f9b
Merge branch 'develop' of https://github.com/oppia/oppia into Explora…
rahat2134 Jun 12, 2024
e9986b9
Merge branch 'ExplorationEditor_' of https://github.com/rahat2134/opp…
rahat2134 Jun 12, 2024
a36bb00
corrected the doc string
rahat2134 Jun 12, 2024
399d31f
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 12, 2024
98b2932
Merge branch 'develop' into ExplorationEditor_
rahat2134 Jun 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ jobs:
suite:
- blog-admin-tests/assign-roles-to-users-and-change-tag-properties
- blog-editor-tests/try-to-publish-a-duplicate-blog-post-and-get-blocked
- exploration-editor-tests/load-complete-and-restart-exploration-preview
- exploration-editor-tests/create-exploration-and-change-basic-settings
- exploration-editor-tests/load-complete-and-restart-exploration-preview
- exploration-editor-tests/savedraft-publish-and-discard-the-changes
StephenYu2018 marked this conversation as resolved.
Show resolved Hide resolved
- logged-in-user-tests/click-all-buttons-on-about-page
- logged-in-user-tests/click-all-buttons-on-about-foundation-page
- logged-in-user-tests/click-all-buttons-on-thanks-for-donating-page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

/**
* @fileoverview Acceptance Test for Exploration Creator and Exploration Manager
* @fileoverview Acceptance Test for settings tab in exploration editor.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for catching this! :)

*/

import {ConsoleReporter} from '../../puppeteer-testing-utilities/console-reporter';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright 2024 The Oppia Authors. All Rights Reserved.
StephenYu2018 marked this conversation as resolved.
Show resolved Hide resolved
//
// 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 Acceptance Test for savedraft, publish and discard the changes.
*/

import {showMessage} from '../../puppeteer-testing-utilities/show-message-utils';
import testConstants from '../../puppeteer-testing-utilities/test-constants';
import {UserFactory} from '../../puppeteer-testing-utilities/user-factory';
import {ExplorationEditor} from '../../user-utilities/exploration-editor-utils';

const DEFAULT_SPEC_TIMEOUT_MSECS = testConstants.DEFAULT_SPEC_TIMEOUT_MSECS;
enum INTERACTION_TYPES {
END_EXPLORATION = 'End Exploration',
}

describe('Exploration Creator', function () {
let explorationEditor: ExplorationEditor;
let explorationVisitor: ExplorationEditor;
let explorationId: string | null;
beforeAll(async function () {
explorationEditor = await UserFactory.createNewUser(
'explorationEditor',
'exploration_editor@example.com'
);
showMessage('explorationEditor is signed up successfully.');

explorationVisitor = await UserFactory.createNewUser(
'explorationVisitor',
'exploration_visitor@example.com'
);
showMessage('explorationVisitor is signed up successfully.');
}, DEFAULT_SPEC_TIMEOUT_MSECS);

it(
'should draft, discard and publish the changes',
async function () {
await explorationEditor.navigateToCreatorDashboardPage();
await explorationEditor.navigateToExplorationEditorPage();
await explorationEditor.dismissWelcomeModal();

await explorationEditor.createExplorationWithMinimumContent(
'Exploration intro text',
INTERACTION_TYPES.END_EXPLORATION
);

await explorationEditor.saveExplorationDraft();
explorationId = await explorationEditor.publishExplorationWithContent(
'Old Title',
'OppiaAcceptanceTestsCheck',
'Algebra'
);

await explorationEditor.navigateToSettingsTab();

await explorationEditor.updateTitleTo('New Title');
await explorationEditor.discardCurrentChanges();
await explorationEditor.expectTitleToBe('Old Title');

await explorationEditor.updateTitleTo('New Title');
await explorationEditor.saveExplorationDraft();
await explorationEditor.expectTitleToBe('New Title');

await explorationVisitor.expectExplorationToBeAccessibleByUrl(
explorationId
);
StephenYu2018 marked this conversation as resolved.
Show resolved Hide resolved
},
DEFAULT_SPEC_TIMEOUT_MSECS
);

afterAll(async function () {
await UserFactory.closeAllBrowsers();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const saveChangesButton = 'button.e2e-test-save-changes';
// Settings Tab elements.
const settingsTab = 'a.e2e-test-exploration-settings-tab';
const addTitleBar = 'input#explorationTitle';
const explorationTitleSelector = '.e2e-test-exploration-title-input';
const addGoalInputBox = '.e2e-test-exploration-objective-input';
const categoryDropdown = 'mat-select.e2e-test-exploration-category-dropdown';
const languageUpdateDropdown =
Expand Down Expand Up @@ -150,8 +151,14 @@ export class ExplorationEditor extends BaseUser {
*/
async navigateToSettingsTab(): Promise<void> {
if (this.isViewportAtMobileWidth()) {
await this.page.waitForSelector(mobileOptionsButton, {visible: true});
await this.clickOn(mobileOptionsButton);
const element = await this.page.$(mobileNavbarDropdown);
// If the element is not present, it means the mobile navigation bar is not expanded.
// The option to settings tab appears only in the mobile view after clicking on the mobile options button,
// which expands the mobile navigation bar.
if (!element) {
await this.page.waitForSelector(mobileOptionsButton, {visible: true});
await this.clickOn(mobileOptionsButton);
}
await this.clickOn(mobileNavbarDropdown);
await this.clickOn(mobileSettingsBar);

Expand Down Expand Up @@ -262,18 +269,35 @@ export class ExplorationEditor extends BaseUser {
* Deletes the previous written title and updates the new title.
*/
async updateTitleTo(title: string): Promise<void> {
await this.page.waitForSelector(explorationTitleSelector);
const titleInput = await this.page.$(explorationTitleSelector);
const oldTitle = await this.page.evaluate(input => input.value, titleInput);
await this.clearAllTextFrom(addTitleBar);
await this.type(addTitleBar, title);
await this.page.keyboard.press('Tab');
if (oldTitle !== title) {
Copy link
Member

Choose a reason for hiding this comment

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

Please explain in a comment why this if condition is needed.

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

if (this.isViewportAtMobileWidth()) {
// Navbar text is hidden in mobile view port due to less screen so there is no visible
// change in UI after we update the input bar. Hence we need to explicitly wait for 2 sec.
await this.page.waitForTimeout(2000);
Copy link
Member

Choose a reason for hiding this comment

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

I cannot approve a PR that has waitForTimeout in it. Please fix before submitting.

/cc @StephenYu2018

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seanlip I have already raised a PR #20231 and trying to get it merge.

} else {
await this.page.waitForSelector('span.e2e-test-autosave-indicator', {
visible: true,
});
await this.page.waitForSelector('span.e2e-test-autosave-indicator', {
hidden: true,
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

}
}
showMessage(`Title has been updated to ${title}`);
}

/**
* Matches the expected title with current title.
*/
async expectTitleToBe(expectedTitle: string): Promise<void> {
await this.page.waitForSelector('.e2e-test-exploration-title-input');
const titleInput = await this.page.$('.e2e-test-exploration-title-input');
await this.page.waitForSelector(explorationTitleSelector);
const titleInput = await this.page.$(explorationTitleSelector);
const currentTitle = await this.page.evaluate(
input => input.value,
titleInput
Expand Down Expand Up @@ -650,8 +674,9 @@ export class ExplorationEditor extends BaseUser {
});
await Promise.all([
this.clickOn(confirmDiscardButton),
this.page.waitForNavigation(),
this.page.waitForNavigation({waitUntil: 'networkidle0'}),
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to have waitForNavigation() always wait until the network is idle, by default? (Not sure -- what do you think?)

Copy link
Contributor Author

@rahat2134 rahat2134 Apr 24, 2024

Choose a reason for hiding this comment

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

I think they both have their specific use cases -
Here are some scenarios where waitForNavigation() might be preferred over {waitUntil: 'networkidle0'}:

Quick Navigation: If you want to wait for navigation to complete without waiting for all network activity to stop, waitForNavigation() without specifying {waitUntil: 'networkidle0'} is more appropriate. This is useful for scenarios where you don't need to ensure that all resources are fully loaded before proceeding.

Non-Standard Navigation: There may be cases where navigation doesn't involve standard network requests/responses, such as navigating within a single-page application (SPA) where content is loaded dynamically. In such cases, waiting for network idleness might not accurately reflect when navigation is complete, and waitForNavigation() provides a more general solution.

Specific Timing Requirements: If you have specific timing requirements for waiting for navigation, such as waiting until DOMContentLoaded or load events, you might prefer using waitForNavigation() with the appropriate waitUntil option (e.g., 'domcontentloaded', 'load') rather than relying solely on network idleness.

By defaulting to {waitUntil: 'networkidle0'}, you're essentially making your navigation waits more conservative, ensuring that the page is fully loaded and has minimal network activity before proceeding. While this can be suitable for many scenarios, there may still be cases where you prefer the flexibility or specificity offered by waitForNavigation() without specifying network idleness.

Copy link
Member

Choose a reason for hiding this comment

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

OK, thanks -- I guess we're moving towards an SPA so let's leave it as you have it for now.

]);
await this.page.waitForFunction('document.readyState === "complete"');
Copy link
Member

Choose a reason for hiding this comment

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

Can you abstract this to a utility function like waitForPageToFullyLoad() or something like 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

if (this.isViewportAtMobileWidth()) {
await this.clickOn(mobileOptionsButton);
await this.clickOn(basicSettingsDropdown);
Expand Down
1 change: 1 addition & 0 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
'blog-editor-tests/try-to-publish-a-duplicate-blog-post-and-get-blocked',
'exploration-editor-tests/create-exploration-and-change-basic-settings',
'exploration-editor-tests/load-complete-and-restart-exploration-preview',
'exploration-editor-tests/savedraft-publish-and-discard-the-changes',
StephenYu2018 marked this conversation as resolved.
Show resolved Hide resolved
'logged-in-user-tests/click-all-buttons-on-about-page',
'logged-in-user-tests/click-all-buttons-on-about-foundation-page',
'logged-in-user-tests/click-all-buttons-on-thanks-for-donating-page',
Expand Down