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 22 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ jobs:
- blog-admin-tests/assign-roles-to-users-and-change-tag-properties
- blog-editor-tests/try-to-publish-a-duplicate-blog-post-and-get-blocked
- curriculum-admin-tests/create-and-publish-topics-and-stories
- 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/save-draft-publish-and-discard-the-changes
- 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 @@ -20,8 +20,10 @@ import puppeteer, {Page, Browser, Viewport, ElementHandle} from 'puppeteer';
import testConstants from './test-constants';
import isElementClickable from '../functions/is-element-clickable';
import {ConsoleReporter} from './console-reporter';
import {showMessage} from './show-message-utils';

const VIEWPORT_WIDTH_BREAKPOINTS = testConstants.ViewportWidthBreakpoints;
const baseURL = testConstants.URLs.BaseURL;

const LABEL_FOR_SUBMIT_BUTTON = 'Submit and start contributing';
/** We accept the empty message because this is what is sent on
Expand Down Expand Up @@ -289,6 +291,46 @@ export class BaseUser {
getCurrentUrlWithoutParameters(): string {
return this.page.url().split('?')[0];
}

/**
* This function checks the exploration accessibility with help of explorationID.
*/
async expectExplorationToBeAccessibleByUrl(
explorationId: string | null
): Promise<void> {
if (!explorationId) {
throw new Error('ExplorationId is null');
}
const explorationUrlAfterPublished = `${baseURL}/create/${explorationId}#/gui/Introduction`;
try {
await this.page.goto(explorationUrlAfterPublished);
showMessage('Exploration is accessible with the URL, i.e. published.');
} catch (error) {
throw new Error('The exploration is not public.');
}
}

async expectExplorationToBeNotAccessibleByUrl(
explorationId: string | null
): Promise<void> {
if (!explorationId) {
throw new Error('ExplorationId is null');
}
const explorationUrlAfterPublished = `${baseURL}/create/${explorationId}#/gui/Introduction`;
try {
await this.page.goto(explorationUrlAfterPublished);
throw new Error('The exploration is still public.');
} catch (error) {
showMessage('The exploration is not accessible with the URL.');
}
}

/**
* Waits for the page to fully load by checking the document's ready state.
*/
async waitForPageToFullyLoad(): Promise<void> {
await this.page.waitForFunction('document.readyState === "complete"');
}
}

export const BaseUserFactory = (): BaseUser => new BaseUser();
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ describe('Curriculum Admin', function () {
await curriculumAdmin.navigateToCreatorDashboardPage();
await curriculumAdmin.navigateToExplorationEditorPage();
await curriculumAdmin.dismissWelcomeModal();
await curriculumAdmin.createExplorationWithMinimumContent(
await curriculumAdmin.createMinimalExploration(
'Test Exploration',
'End Exploration'
);
await curriculumAdmin.saveExplorationDraft();
explorationId = await curriculumAdmin.publishExplorationWithContent(
explorationId = await curriculumAdmin.publishExplorationWithMetadata(
'Test Exploration Title 1',
'Test Exploration Goal',
'Algebra'
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
Member

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 All @@ -22,6 +22,7 @@ import testConstants from '../../puppeteer-testing-utilities/test-constants';
import {UserFactory} from '../../puppeteer-testing-utilities/user-factory';
import {CurriculumAdmin} from '../../user-utilities/curriculum-admin-utils';
import {ExplorationEditor} from '../../user-utilities/exploration-editor-utils';
import {LoggedInUser} from '../../user-utilities/logged-in-users-utils';
import {VoiceoverAdmin} from '../../user-utilities/voiceover-admin-utils';

const DEFAULT_SPEC_TIMEOUT_MSECS = testConstants.DEFAULT_SPEC_TIMEOUT_MSECS;
Expand All @@ -38,54 +39,62 @@ ConsoleReporter.setConsoleErrorsToIgnore([
/Error: Could not find the resource http:\/\/localhost:8181\/explorehandler\/features\/[a-zA-Z0-9]+\.?/,
/Could not find the resource http:\/\/localhost:8181\/createhandler\/permissions\/[a-zA-Z0-9]+\.?/,
/http:\/\/localhost:8181\/build\/webpack_bundles\/exploration_editor\.[a-f0-9]+\.bundle\.js/,
/http:\/\/localhost:8181\/create\/[a-zA-Z0-9]+#\/gui\/Introduction Failed to load resource: the server responded with a status of 404 \(Not Found\)/,
Copy link
Member

Choose a reason for hiding this comment

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

If these errors are unexpected, these should be linked to issues, and we should drop the statement here when the issue is fixed.

In any case a comment should be left to explain the context of each error and the reason we exclude it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I have already added a statement before all these errors.
These errors occurred when we deleted the exploration and then tried to access it. Most of these are not found type issues.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, I think that's a problem. Each console error should have its own comment (because otherwise, if we add new console errors and functionality in future, the comment won't apply to it). Secondly, only a single 404 console error should arise in cases like this, so it's probably worth filing a bug to fix that -- we shouldn't even get to the point of loading the rest of the page once the initial 404 is received.

]);

describe('Exploration Creator', function () {
let explorationEditor: ExplorationEditor;
let voiceoverAdmin: VoiceoverAdmin;
let curriculumAdmin: CurriculumAdmin;
let explorationVisitor: LoggedInUser;
let explorationId: string | null;

beforeAll(async function () {
explorationEditor = await UserFactory.createNewUser(
'explorationEditor',
'exploration_editor@example.com'
);
showMessage('explorationEditor is signed up successfully.');
showMessage('explorationEditor has signed up successfully.');

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

voiceoverAdmin = await UserFactory.createNewUser(
'voiceoverAdm',
'voiceover_admin@example.com',
[ROLES.VOICEOVER_ADMIN]
);
showMessage('Voiceover admin is signed up successfully.');
showMessage('Voiceover admin has signed up successfully.');

curriculumAdmin = await UserFactory.createNewUser(
'curriculumAdm',
'curriculum_admin@example.com',
[ROLES.CURRICULUM_ADMIN]
);
showMessage('Curriculum admin is signed up successfully.');
showMessage('Curriculum admin has signed up successfully.');

const guestUser1 = await UserFactory.createNewUser(
'guestUser1',
'guest_user1@example.com'
);
showMessage('guestUser1 is signed up successfully.');
showMessage('guestUser1 has signed up successfully.');
await guestUser1.closeBrowser();

const guestUser2 = await UserFactory.createNewUser(
'guestUser2',
'guest_user2@example.com'
);
showMessage('guestUser2 is signed up successfully.');
showMessage('guestUser2 has signed up successfully.');
await guestUser2.closeBrowser();

const guestUser3 = await UserFactory.createNewUser(
'guestUser3',
'guest_user3@example.com'
);
showMessage('guestUser3 is signed up successfully.');
showMessage('guestUser3 has signed up successfully.');
await guestUser3.closeBrowser();
}, DEFAULT_SPEC_TIMEOUT_MSECS);

Expand All @@ -98,7 +107,7 @@ describe('Exploration Creator', function () {

await explorationEditor.dismissWelcomeModal();

await explorationEditor.createExplorationWithMinimumContent(
await explorationEditor.createMinimalExploration(
'Exploration intro text',
INTERACTION_TYPES.END_EXPLORATION
);
Expand Down Expand Up @@ -155,7 +164,7 @@ describe('Exploration Creator', function () {
await curriculumAdmin.openExplorationControlDropdown();
await curriculumAdmin.deleteExplorationPermanently();

await explorationEditor.expectExplorationToBeNotAccessibleByUrl(
await explorationVisitor.expectExplorationToBeNotAccessibleByUrl(
explorationId
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright 2024 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 Acceptance Test for saving drafts, publishing, and discarding 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';
import {LoggedInUser} from '../../user-utilities/logged-in-users-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: LoggedInUser;
let explorationId: string | null;

beforeAll(async function () {
explorationEditor = await UserFactory.createNewUser(
'explorationEditor',
'exploration_editor@example.com'
);
showMessage('explorationEditor has signed up successfully.');

explorationVisitor = await UserFactory.createNewUser(
'explorationVisitor',
'exploration_visitor@example.com'
);
showMessage('explorationVisitor has 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.createMinimalExploration(
'Exploration intro text',
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering that the function receives both content and interaction parameters and not just content, it might be more appropriate to use createMinimalExploration(). What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems reasonable. 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

INTERACTION_TYPES.END_EXPLORATION
);

await explorationEditor.saveExplorationDraft();
explorationId = await explorationEditor.publishExplorationWithMetadata(
'Old Title',
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, while publishing exploration, we don't really pass any content, what we pass is a title (if it's not already set in the settings tab), objective and category. so maybe we can use publishExplorationWithMetadata()? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although the previous name was clear. But this is more specific. Thanks for suggestion :)

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 is the goal of exploration.',
'Algebra'
);

await explorationVisitor.expectExplorationToBeAccessibleByUrl(
explorationId
);

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');
},
DEFAULT_SPEC_TIMEOUT_MSECS
);

afterAll(async function () {
await UserFactory.closeAllBrowsers();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ describe('Voiceover Admin', function () {
await explorationEditor.navigateToExplorationEditorPage();
await explorationEditor.dismissWelcomeModal();

await explorationEditor.createExplorationWithMinimumContent(
await explorationEditor.createMinimalExploration(
'Exploration one',
INTERACTION_TYPES.END_EXPLORATION
);
await explorationEditor.saveExplorationDraft();
explorationId = await explorationEditor.publishExplorationWithContent(
explorationId = await explorationEditor.publishExplorationWithMetadata(
'Exploration one',
'Exploration one',
'Algebra'
Expand Down Expand Up @@ -106,12 +106,12 @@ describe('Voiceover Admin', function () {
await explorationEditor.navigateToCreatorDashboardPage();
await explorationEditor.navigateToExplorationEditorPage();

await explorationEditor.createExplorationWithMinimumContent(
await explorationEditor.createMinimalExploration(
'Exploration two',
INTERACTION_TYPES.END_EXPLORATION
);
await explorationEditor.saveExplorationDraft();
explorationId = await explorationEditor.publishExplorationWithContent(
explorationId = await explorationEditor.publishExplorationWithMetadata(
'Exploration one',
'Exploration one',
'Algebra'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ export class CurriculumAdmin extends BaseUser {
* Function to navigate to exploration settings tab
*/
async navigateToExplorationSettingsTab(): Promise<void> {
await this.page.waitForFunction('document.readyState === "complete"');
await this.waitForPageToFullyLoad();
if (this.isViewportAtMobileWidth()) {
await this.clickOn(mobileNavToggelbutton);
await this.clickOn(mobileOptionsDropdown);
Expand All @@ -780,7 +780,7 @@ export class CurriculumAdmin extends BaseUser {
* Note: This action requires Curriculum Admin role.
*/
async deleteExplorationPermanently(): Promise<void> {
await this.page.waitForFunction('document.readyState === "complete"');
await this.waitForPageToFullyLoad();
await this.clickOn(deleteExplorationButton);
await this.clickOn(confirmDeletionButton);
}
Expand Down
Loading
Loading