From b1022f2d35e424d41ab313297d9438d2b61da084 Mon Sep 17 00:00:00 2001 From: entholzer Date: Sun, 20 Oct 2024 10:25:26 +0200 Subject: [PATCH 1/2] fixed channel creation --- src/test/playwright/e2e/course/CourseMessages.spec.ts | 4 ++-- .../support/pageobjects/course/CourseMessagesPage.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/playwright/e2e/course/CourseMessages.spec.ts b/src/test/playwright/e2e/course/CourseMessages.spec.ts index 8a3026a9a931..d97af8037363 100644 --- a/src/test/playwright/e2e/course/CourseMessages.spec.ts +++ b/src/test/playwright/e2e/course/CourseMessages.spec.ts @@ -108,7 +108,7 @@ test.describe('Course messages', () => { 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.checkChannelsExists('test-lecture'); }); test('Check that channel is created when an exercise is created', async ({ login, courseMessages, exerciseAPIRequests }) => { @@ -116,7 +116,7 @@ test.describe('Course messages', () => { 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.checkChannelsExists('test-exercise'); }); test('Check that channel is created when an exam is created', async ({ login, courseMessages, examAPIRequests }) => { diff --git a/src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts b/src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts index 49f5f3854db8..0e23652c3b9a 100644 --- a/src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts +++ b/src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts @@ -18,15 +18,15 @@ 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}`); + return this.page.locator(`#test-accordion-item-header-${channelGroup} > .my-2`); } /** @@ -34,7 +34,7 @@ export class CourseMessagesPage { * @param name - The name of the channel to check for existence. */ async checkChannelsExists(name: string) { - await expect(this.page.locator('.channels-overview .list-group-item').getByText(name)).toBeVisible(); + await expect(this.page.locator('#test-sidebar-card-title').getByText(name)).toBeVisible(); } /** @@ -43,7 +43,7 @@ export class CourseMessagesPage { * @returns The ID of the channel. */ async getChannelIdByName(name: string) { - const channelElement = this.page.locator('.channels-overview .list-group-item', { hasText: name }); + const channelElement = this.page.locator('#test-sidebar-card-title', { hasText: name }); const id = await channelElement.getAttribute('id'); return id?.replace('channel-', ''); } From f22616b22f2d0b96ac63eafbe0dcdc45d61a49c7 Mon Sep 17 00:00:00 2001 From: Asli Aykan Date: Sun, 20 Oct 2024 20:06:33 +0200 Subject: [PATCH 2/2] updated tests --- .../playwright/e2e/course/CourseMessages.spec.ts | 14 +++++++------- .../pageobjects/course/CourseMessagesPage.ts | 12 +++++++----- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/test/playwright/e2e/course/CourseMessages.spec.ts b/src/test/playwright/e2e/course/CourseMessages.spec.ts index d97af8037363..b75773522eaf 100644 --- a/src/test/playwright/e2e/course/CourseMessages.spec.ts +++ b/src/test/playwright/e2e/course/CourseMessages.spec.ts @@ -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'); @@ -107,7 +107,7 @@ 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.browseChannelsButton(); await courseMessages.checkChannelsExists('test-lecture'); }); @@ -115,7 +115,7 @@ test.describe('Course messages', () => { await login(admin); await exerciseAPIRequests.createTextExercise({ course }, 'Test Exercise'); await login(instructor, `/courses/${course.id}/communication`); - await courseMessages.browseChannelsButton('exerciseChannels').click(); + await courseMessages.browseChannelsButton(); await courseMessages.checkChannelsExists('test-exercise'); }); @@ -124,7 +124,7 @@ test.describe('Course messages', () => { 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)); }); }); @@ -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(); @@ -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(); @@ -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(); }); diff --git a/src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts b/src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts index 0e23652c3b9a..5102f126c235 100644 --- a/src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts +++ b/src/test/playwright/support/pageobjects/course/CourseMessagesPage.ts @@ -25,8 +25,9 @@ export class CourseMessagesPage { /** * Navigates to the channel overview section. */ - browseChannelsButton(channelGroup: string) { - return this.page.locator(`#test-accordion-item-header-${channelGroup} > .my-2`); + async browseChannelsButton() { + await this.page.locator('.btn-primary.btn-sm.square-button').click(); + await this.page.locator('button', { hasText: 'Browse Channels' }).click(); } /** @@ -34,7 +35,7 @@ export class CourseMessagesPage { * @param name - The name of the channel to check for existence. */ async checkChannelsExists(name: string) { - await expect(this.page.locator('#test-sidebar-card-title').getByText(name)).toBeVisible(); + await expect(this.page.locator('.channels-overview .list-group-item').getByText(name)).toBeVisible(); } /** @@ -43,7 +44,7 @@ export class CourseMessagesPage { * @returns The ID of the channel. */ async getChannelIdByName(name: string) { - const channelElement = this.page.locator('#test-sidebar-card-title', { hasText: name }); + const channelElement = this.page.locator('.channels-overview .list-group-item', { hasText: name }); const id = await channelElement.getAttribute('id'); return id?.replace('channel-', ''); } @@ -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(); } /**