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

Development: Fix course messages e2e tests #9536

Merged
merged 2 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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() {
Comment on lines 18 to 20
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest the name openChannelCreation here

await this.page.locator('#plusButton-generalChannels').click();
await this.page.locator('.modal-content #createChannel').click();
await this.page.click('.square-button > .ng-fa-icon');
Copy link
Contributor

Choose a reason for hiding this comment

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

As I see it, all three buttons (create channel, browse channels, create group chat) are under the same menu and can be accessed via the same button.

Why do you use this.page.click('.square-button > .ng-fa-icon'); here but this.page.locator('.btn-primary.btn-sm.square-button').click() in the other methods? Could we simply assign an ID to the button that opens the dropdown and use that to find it?

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();
Comment on lines -28 to +30
Copy link
Contributor

Choose a reason for hiding this comment

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

The method name is not super intuitive to me - I'd expect the method to return a locator to the browse button (like it did in the old implementation). Could we rename it to openBrowseChannelModal or something similar?

}

/**
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();
Comment on lines 291 to +293
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe openGroupChatCreation?

}

/**
Expand Down
Loading