|
| 1 | +// Copyright 2025 The Oppia Authors. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS-IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +/** |
| 16 | + * @fileoverview Acceptance Test for checking if a user can edit avatar |
| 17 | + * and view created and edited lessons in the profile page. |
| 18 | + */ |
| 19 | + |
| 20 | +import {UserFactory} from '../../utilities/common/user-factory'; |
| 21 | +import testConstants from '../../utilities/common/test-constants'; |
| 22 | +import {LoggedInUser} from '../../utilities/user/logged-in-user'; |
| 23 | + |
| 24 | +const DEFAULT_SPEC_TIMEOUT_MSECS = testConstants.DEFAULT_SPEC_TIMEOUT_MSECS; |
| 25 | +const PROFILE_PICTURE = testConstants.data.profilePicture; |
| 26 | + |
| 27 | +describe('Logged-in User', function () { |
| 28 | + let loggedInUser: LoggedInUser; |
| 29 | + const TEST_EXPLORATION = { |
| 30 | + title: 'Test Exploration', |
| 31 | + editedTitle: 'Edited Exploration', |
| 32 | + category: 'Algebra', |
| 33 | + }; |
| 34 | + |
| 35 | + beforeAll(async function () { |
| 36 | + loggedInUser = await UserFactory.createNewUser( |
| 37 | + 'loggedInUser', |
| 38 | + 'logged_in_user@example.com' |
| 39 | + ); |
| 40 | + |
| 41 | + // Create and publish exploration. |
| 42 | + await loggedInUser.createAndPublishAMinimalExplorationWithTitle( |
| 43 | + TEST_EXPLORATION.title, |
| 44 | + TEST_EXPLORATION.category |
| 45 | + ); |
| 46 | + }, DEFAULT_SPEC_TIMEOUT_MSECS); |
| 47 | + |
| 48 | + // The logged-in user can edit their profile avatar via preferences. |
| 49 | + it( |
| 50 | + 'should edit profile avatar via preferences', |
| 51 | + async function () { |
| 52 | + await loggedInUser.navigateToPreferencesPageUsingProfileDropdown(); |
| 53 | + await loggedInUser.updateProfilePicture(PROFILE_PICTURE); |
| 54 | + await loggedInUser.saveChanges(); |
| 55 | + await loggedInUser.navigateToProfilePageUsingProfileDropdown(); |
| 56 | + await loggedInUser.verifyProfilePicUpdate(); |
| 57 | + }, |
| 58 | + DEFAULT_SPEC_TIMEOUT_MSECS |
| 59 | + ); |
| 60 | + |
| 61 | + // The logged-in user can view created explorations in their profile page. |
| 62 | + it( |
| 63 | + 'should display created explorations on profile page', |
| 64 | + async function () { |
| 65 | + await loggedInUser.navigateToProfilePageUsingProfileDropdown(); |
| 66 | + await loggedInUser.expectExplorationToBePresentInProfilePageWithTitle( |
| 67 | + TEST_EXPLORATION.title |
| 68 | + ); |
| 69 | + }, |
| 70 | + DEFAULT_SPEC_TIMEOUT_MSECS |
| 71 | + ); |
| 72 | + |
| 73 | + // The logged-in user can view edited explorations in their profile page. |
| 74 | + it( |
| 75 | + 'should display edited explorations on profile page', |
| 76 | + async function () { |
| 77 | + await loggedInUser.navigateToCreatorDashboardPage(); |
| 78 | + await loggedInUser.openExplorationInExplorationEditor( |
| 79 | + TEST_EXPLORATION.title |
| 80 | + ); |
| 81 | + await loggedInUser.dismissWelcomeModal(); |
| 82 | + await loggedInUser.navigateToSettingsTab(); |
| 83 | + await loggedInUser.updateTitleTo(TEST_EXPLORATION.editedTitle); |
| 84 | + |
| 85 | + await loggedInUser.saveExplorationDraft(); |
| 86 | + |
| 87 | + await loggedInUser.navigateToProfilePageUsingProfileDropdown(); |
| 88 | + await loggedInUser.expectExplorationToBePresentInProfilePageWithTitle( |
| 89 | + TEST_EXPLORATION.editedTitle |
| 90 | + ); |
| 91 | + }, |
| 92 | + DEFAULT_SPEC_TIMEOUT_MSECS |
| 93 | + ); |
| 94 | + |
| 95 | + afterAll(async function () { |
| 96 | + await UserFactory.closeAllBrowsers(); |
| 97 | + }); |
| 98 | +}); |
0 commit comments