Skip to content

Commit

Permalink
Development: Fix course messages e2e tests (#9536)
Browse files Browse the repository at this point in the history
  • Loading branch information
asliayk authored Oct 20, 2024
1 parent 7a14167 commit 9d8b398
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
18 changes: 9 additions & 9 deletions src/test/playwright/e2e/course/CourseMessages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test.describe('Course messages', () => {
test.describe('Create channel', () => {
test('Check for pre-created channels', async ({ login, courseMessages }) => {
await login(instructor, `/courses/${course.id}/communication`);
await courseMessages.browseChannelsButton('generalChannels').click();
await courseMessages.browseChannelsButton();
await courseMessages.checkChannelsExists('tech-support');
await courseMessages.checkChannelsExists('organization');
await courseMessages.checkChannelsExists('random');
Expand Down Expand Up @@ -107,24 +107,24 @@ test.describe('Course messages', () => {
await login(admin);
await courseManagementAPIRequests.createLecture(course, 'Test Lecture');
await login(instructor, `/courses/${course.id}/communication`);
await courseMessages.browseChannelsButton('lectureChannels').click();
await courseMessages.checkChannelsExists('lecture-test-lecture');
await courseMessages.browseChannelsButton();
await courseMessages.checkChannelsExists('test-lecture');
});

test('Check that channel is created when an exercise is created', async ({ login, courseMessages, exerciseAPIRequests }) => {
await login(admin);
await exerciseAPIRequests.createTextExercise({ course }, 'Test Exercise');
await login(instructor, `/courses/${course.id}/communication`);
await courseMessages.browseChannelsButton('exerciseChannels').click();
await courseMessages.checkChannelsExists('exercise-test-exercise');
await courseMessages.browseChannelsButton();
await courseMessages.checkChannelsExists('test-exercise');
});

test('Check that channel is created when an exam is created', async ({ login, courseMessages, examAPIRequests }) => {
await login(admin);
const examTitle = 'exam' + generateUUID();
await examAPIRequests.createExam({ course, title: examTitle });
await login(instructor, `/courses/${course.id}/communication`);
await courseMessages.browseChannelsButton('examChannels').click();
await courseMessages.browseChannelsButton();
await courseMessages.checkChannelsExists(titleLowercase(examTitle));
});
});
Expand Down Expand Up @@ -163,7 +163,7 @@ test.describe('Course messages', () => {

test('Student should be joined into pre-created channels automatically', async ({ login, courseMessages }) => {
await login(studentOne, `/courses/${course.id}/communication`);
await courseMessages.browseChannelsButton('generalChannels').click();
await courseMessages.browseChannelsButton();
const techSupportChannelId = Number(await courseMessages.getChannelIdByName('tech-support'));
const techSupportJoinedBadge = courseMessages.getJoinedBadge(techSupportChannelId);
await expect(techSupportJoinedBadge).toBeVisible();
Expand All @@ -187,7 +187,7 @@ test.describe('Course messages', () => {

test('Student should be able to join a public channel', async ({ login, courseMessages }) => {
await login(studentOne, `/courses/${course.id}/communication`);
await courseMessages.browseChannelsButton('generalChannels').click();
await courseMessages.browseChannelsButton();
await courseMessages.joinChannel(channel.id!);
const joinedBadge = courseMessages.getJoinedBadge(channel.id!);
await expect(joinedBadge).toBeVisible();
Expand All @@ -197,7 +197,7 @@ test.describe('Course messages', () => {
test('Student should be able to leave a public channel', async ({ login, courseMessages, communicationAPIRequests }) => {
await login(studentOne, `/courses/${course.id}/communication`);
await communicationAPIRequests.joinUserIntoChannel(course, channel.id!, studentOne);
await courseMessages.browseChannelsButton('generalChannels').click();
await courseMessages.browseChannelsButton();
await courseMessages.leaveChannel(channel.id!);
await expect(courseMessages.getJoinedBadge(channel.id!)).toBeHidden();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ export class CourseMessagesPage {
* Clicks the button to initiate channel creation.
*/
async createChannelButton() {
await this.page.locator('#plusButton-generalChannels').click();
await this.page.locator('.modal-content #createChannel').click();
await this.page.click('.square-button > .ng-fa-icon');
await this.page.click('text=Create channel');
}

/**
* Navigates to the channel overview section.
*/
browseChannelsButton(channelGroup: string) {
return this.page.locator(`#plusButton-${channelGroup}`);
async browseChannelsButton() {
await this.page.locator('.btn-primary.btn-sm.square-button').click();
await this.page.locator('button', { hasText: 'Browse Channels' }).click();
}

/**
Expand Down Expand Up @@ -288,7 +289,8 @@ export class CourseMessagesPage {
* Clicks the button to initiate group chat creation.
*/
async createGroupChatButton() {
await this.page.locator('#plusButton-groupChats').click();
await this.page.locator('.btn-primary.btn-sm.square-button').click();
await this.page.locator('button', { hasText: 'Create Group Chat' }).click();
}

/**
Expand Down

0 comments on commit 9d8b398

Please sign in to comment.