Skip to content

Commit

Permalink
[GSoC'24] M1.3 and M1.6: Add acceptance test for curriculum admin and…
Browse files Browse the repository at this point in the history
… logged-out user CUJ (oppia#20584)

* Fix part of oppia#19849: Add acceptance test for classroom admin and classrooms

* fix test

* fix test

* minor fixes

* add topic with name

* remove extra module

* remove duplicate e2e test

* add test for M1.6

* fix test

* fix test

* fix mapping

* fix test

* fix linter

* fix test

* fix mapping

* fix linter

* remove 2 test case

* fix linter

* remove unused code

* fix classroom test

* fix goto
  • Loading branch information
AFZL210 authored Jul 4, 2024
1 parent 0b56085 commit 9eaed52
Show file tree
Hide file tree
Showing 22 changed files with 528 additions and 152 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"additionalPlayerFeatures.js",
"adminTabFeatures.js",
"classroomPage.js",
"classroomPageFileUploadFeatures.js",
"collections.js",
"contributorDashboard.js",
"coreEditorAndPlayerFeatures.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h3>Classroom details</h3>
<div *ngFor="let classroom of classroomIdToClassroomName | keyvalue">
<div class="oppia-classroom-tile e2e-test-classroom-tile"
(click)="getClassroomData(classroom.key)">
<span *ngIf="!(classroomEditorMode && classroom.key === tempClassroomData.getClassroomId())">
<span *ngIf="!(classroomEditorMode && classroom.key === tempClassroomData.getClassroomId())" class="e2e-test-classroom-tile-name">
{{ classroom.value }}
</span>
<span *ngIf="classroomEditorMode && classroom.key === tempClassroomData.getClassroomId() && tempClassroomData.getClassroomName().length > 0" class="classroom-tile-name">
Expand All @@ -27,6 +27,7 @@ <h3>Classroom details</h3>
[New Classroom]
</span>
<button mat-button matSuffix mat-icon-button
class="e2e-test-delete-classroom-button"
aria-label="Clear"
*ngIf="!classroomEditorMode"
(click)="deleteClassroom(classroom.key); $event.stopPropagation()">
Expand Down Expand Up @@ -248,7 +249,7 @@ <h3>Classroom details</h3>
<mat-form-field appearance="fill" class="topics-selector-form-field e2e-test-classroom-topics-modal">
<mat-label for="explorationCategory" class="d-block">Select a topic</mat-label>
<mat-select (selectionChange)="onNewTopicInputModelChange($event.value)" class="e2e-test-classroom-category-dropdown">
<mat-option class="e2e-test-exploration-new-category-add">
<mat-option class="e2e-test-classroom-new-topic-add">
<ngx-mat-select-search
ngModel
(ngModelChange)="filterTopicsByName($event)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="modal-header">
<div class="modal-header e2e-test-create-new-classroom-modal">
<h3>
Add new classroom
</h3>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="modal-header">
<div class="modal-header e2e-test-delete-classroom-modal">
<h3>Are you sure to delete the classroom?</h3>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" (click)="cancel()">Cancel</button>
<button class="btn btn-danger" (click)="close()">
<button class="btn btn-danger e2e-test-confirm-delete-classroom" (click)="close()">
<span>Delete Classroom</span>
</button>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="modal-header">
<div class="modal-header e2e-test-topic-dependency-graph-container">
<h3>Graph visualization</h3>
</div>
<div class="modal-body">
Expand All @@ -8,7 +8,7 @@ <h3>Graph visualization</h3>
<path class="link" *ngIf="link.d" [attr.d]="link.d" marker-end="url(#arrowhead)">
</path>
</g>
<g class="node" *ngFor="let node of nodeList">
<g class="node e2e-test-topic-node" *ngFor="let node of nodeList">
<rect [attr.rx]="2" [attr.ry]="2" [attr.height]="node.height" [attr.width]="node.width"
[attr.x]="node.x0" [attr.y]="node.y0"
[ngClass]="{'clickable': false}"
Expand All @@ -30,7 +30,7 @@ <h3>Graph visualization</h3>
</svg>
</div>
<div class="modal-footer">
<button class="btn btn-secondary"
<button class="btn btn-secondary e2e-test-close-topic-dependency-modal"
(click)="cancel()">
Cancel
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<div class="classroom-information-container">
<div class="classroom-text-container">
<span>{{ 'I18N_CLASSROOM_HEADING' | translate:{ classroomName: classroomData.getName() } }}</span>
<h1 *ngIf="!isHackyClassroomTranslationDisplayed('name')" [ngStyle]="{'text-align': isLanguageRTL() ? 'right' : 'left'}">{{classroomData.getName()}}</h1>
<h1 *ngIf="isHackyClassroomTranslationDisplayed('name')" [ngStyle]="{'text-align': isLanguageRTL() ? 'right' : 'left'}">{{classroomTranslationKeys.name | translate}}</h1>
<h1 *ngIf="!isHackyClassroomTranslationDisplayed('name')" [ngStyle]="{'text-align': isLanguageRTL() ? 'right' : 'left'}" class="e2e-test-classroom-name">{{classroomData.getName()}}</h1>
<h1 *ngIf="isHackyClassroomTranslationDisplayed('name')" [ngStyle]="{'text-align': isLanguageRTL() ? 'right' : 'left'}" class="e2e-test-classroom-name">{{classroomTranslationKeys.name | translate}}</h1>
</div>
<div class="classroom-thumbnail-container">
<img class="classroom-thumbnail" alt="Classroom thumbnail image" [src]="classroomThumbnail">
Expand Down
8 changes: 4 additions & 4 deletions core/templates/pages/error-pages/error-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
<div class="oppia-wide-panel-content e2e-test-error-container">
<h1 class="oppia-error-h1">
<div *ngIf="getStatusCode() === 400">
<span [innerHTML]="'I18N_ERROR_HEADER_400' | translate"></span>
<span [innerHTML]="'I18N_ERROR_HEADER_400' | translate" class="e2e-test-error-page-heading"></span>
- Bad Request
</div>
<div *ngIf="getStatusCode() === 401">
<span [innerHTML]="'I18N_ERROR_HEADER_401' | translate"></span>
<span [innerHTML]="'I18N_ERROR_HEADER_401' | translate" class="e2e-test-error-page-heading"></span>
- Unauthorized
</div>
<div *ngIf="getStatusCode() === 404">
<span [innerHTML]="'I18N_ERROR_HEADER_404' | translate"></span>
<span [innerHTML]="'I18N_ERROR_HEADER_404' | translate" class="e2e-test-error-page-heading"></span>
- Page Not Found
</div>
<div *ngIf="getStatusCode() === 500">
<span [innerHTML]="'I18N_ERROR_HEADER_500' | translate"></span>
<span [innerHTML]="'I18N_ERROR_HEADER_500' | translate" class="e2e-test-error-page-heading"></span>
- System Error
</div>
</h1>
Expand Down
8 changes: 8 additions & 0 deletions core/tests/ci-test-suite-configs/acceptance.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"name": "blog-editor/try-to-publish-a-duplicate-blog-post-and-get-blocked",
"module": "core/tests/puppeteer-acceptance-tests/specs/blog-editor/try-to-publish-a-duplicate-blog-post-and-get-blocked.spec.ts"
},
{
"name": "curriculum-admin/create-edit-and-delete-classroom",
"module": "core/tests/puppeteer-acceptance-tests/specs/curriculum-admin/create-edit-and-delete-classroom.spec.ts"
},
{
"name": "curriculum-admin/create-publish-unpublish-and-delete-topic-and-skill",
"module": "core/tests/puppeteer-acceptance-tests/specs/curriculum-admin/create-publish-unpublish-and-delete-topic-and-skill.spec.ts"
Expand Down Expand Up @@ -104,6 +108,10 @@
"name": "logged-out-user/click-all-buttons-on-donate-page",
"module": "core/tests/puppeteer-acceptance-tests/specs/logged-out-user/click-all-buttons-on-donate-page.spec.ts"
},
{
"name": "logged-out-user/visit-classroom-index-page",
"module": "core/tests/puppeteer-acceptance-tests/specs/logged-out-user/visit-classroom-index-page.spec.ts"
},
{
"name": "moderator/edit-featured-activities-list",
"module": "core/tests/puppeteer-acceptance-tests/specs/moderator/edit-featured-activities-list.spec.ts"
Expand Down
4 changes: 0 additions & 4 deletions core/tests/ci-test-suite-configs/e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
"name": "classroomPage",
"module": "core/tests/webdriverio_desktop/classroomPage.js"
},
{
"name": "classroomPageFileUploadFeatures",
"module": "core/tests/webdriverio_desktop/classroomPageFileUploadFeatures.js"
},
{
"name": "collections",
"module": "core/tests/webdriverio_desktop/collections.js"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// 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 Creating, Updating, Publishing, and Deleting a Classroom by a Curriculum Admin.
*/

import {UserFactory} from '../../utilities/common/user-factory';
import testConstants from '../../utilities/common/test-constants';
import {CurriculumAdmin} from '../../utilities/user/curriculum-admin';
import {LoggedOutUser} from '../../utilities/user/logged-out-user';
import {ConsoleReporter} from '../../utilities/common/console-reporter';

const DEFAULT_SPEC_TIMEOUT_MSECS = testConstants.DEFAULT_SPEC_TIMEOUT_MSECS;
const ROLES = testConstants.Roles;

ConsoleReporter.setConsoleErrorsToIgnore([/[\s\S]*/]);

describe('Curriculum Admin', function () {
let curriculumAdmin: CurriculumAdmin;
let loggedOutUser: LoggedOutUser;

beforeAll(async function () {
curriculumAdmin = await UserFactory.createNewUser(
'curriculumAdm',
'[email protected]',
[ROLES.CURRICULUM_ADMIN]
);

loggedOutUser = await UserFactory.createLoggedOutUser();

await curriculumAdmin.navigateToTopicAndSkillsDashboardPage();
await curriculumAdmin.createTopic('Test Topic 1', 'test-topic-one');
await curriculumAdmin.createSubtopicForTopic(
'Test Subtopic 1',
'test-subtopic-one',
'Test Topic 1'
);

await curriculumAdmin.createSkillForTopic('Test Skill 1', 'Test Topic 1');
await curriculumAdmin.createQuestionsForSkill('Test Skill 1', 3);
await curriculumAdmin.assignSkillToSubtopicInTopicEditor(
'Test Skill 1',
'Test Subtopic 1',
'Test Topic 1'
);
await curriculumAdmin.addSkillToDiagnosticTest(
'Test Skill 1',
'Test Topic 1'
);

await curriculumAdmin.publishDraftTopic('Test Topic 1');
}, DEFAULT_SPEC_TIMEOUT_MSECS);

it(
'should create, publish and delete a classroom.',
async function () {
await curriculumAdmin.expectNumberOfClassroomsToBe(0);
await curriculumAdmin.createNewClassroom('Math', 'math');
await curriculumAdmin.expectNumberOfClassroomsToBe(1);
await curriculumAdmin.updateClassroom(
'Math',
'Teaser text',
'Course details',
'Topic list intro'
);
await curriculumAdmin.addTopicToClassroom('Math', 'Test Topic 1');
await curriculumAdmin.publishClassroom('Math');
await curriculumAdmin.expectNumberOfTopicsInTopicDependencyGraphToBe(
'Math',
1
);

await loggedOutUser.navigateToClassroomPage('math');
await loggedOutUser.expectToBeOnClassroomPage('Math');

await curriculumAdmin.deleteClassroom('Math');
await curriculumAdmin.expectNumberOfClassroomsToBe(0);
},

DEFAULT_SPEC_TIMEOUT_MSECS
);

afterAll(async function () {
await UserFactory.closeAllBrowsers();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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 checking the behavior of the classroom index page
* for 0 classrooms, 1 classroom, and more than 1 classroom.
*/

import {UserFactory} from '../../utilities/common/user-factory';
import testConstants from '../../utilities/common/test-constants';
import {LoggedOutUser} from '../../utilities/user/logged-out-user';
import {ConsoleReporter} from '../../utilities/common/console-reporter';

const DEFAULT_SPEC_TIMEOUT_MSECS = testConstants.DEFAULT_SPEC_TIMEOUT_MSECS;

ConsoleReporter.setConsoleErrorsToIgnore([
/http:\/\/localhost:8181\/access_validation_handler\/can_access_classrooms_page Failed to load resource: the server responded with a status of 404 \(Not Found\)/,
]);

describe('Logged-out User', function () {
let loggedOutUser: LoggedOutUser;

beforeAll(async function () {
loggedOutUser = await UserFactory.createLoggedOutUser();
}, DEFAULT_SPEC_TIMEOUT_MSECS);

it(
'should be redirected to a 404 error page if no classrooms are present.',
async function () {
await loggedOutUser.navigateToClassroomsPage();
await loggedOutUser.expectToBeOnErrorPage(404);
},
DEFAULT_SPEC_TIMEOUT_MSECS
);

// TODO (#20610): Add test for one and more than one classroom.
// Once issue with relase coordinator user is fixed.

afterAll(async function () {
await UserFactory.closeAllBrowsers();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
'in-summer-school-0q6r28fzsrwc',
CCLicense: 'https://creativecommons.org/licenses/by-sa/4.0/legalcode',
ClassroomAdmin: 'http://localhost:8181/classroom-admin',
ClassroomsPage: 'http://localhost:8181/learn',
CommunityLibrary: 'http://localhost:8181/community-library',
Contact: 'http://localhost:8181/contact',
ContributorDashboard: 'http://localhost:8181/contributor-dashboard',
Expand Down Expand Up @@ -150,6 +151,10 @@ export default {
__dirname,
'../../data/curriculum-admin-thumbnail.svg'
),
classroomBannerImage: path.resolve(
__dirname,
'../../data/classroom-banner.png'
),
},
OppiaSocials: {
YouTube: {
Expand Down
Loading

0 comments on commit 9eaed52

Please sign in to comment.