Skip to content

Commit

Permalink
Adds exam working time POM functions
Browse files Browse the repository at this point in the history
  • Loading branch information
muradium committed May 10, 2024
1 parent 556b6d6 commit 08e7d09
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<button class="btn btn-md btn-warning" [disabled]="!workingTimeChangeAllowed" (click)="openDialog($event)">
<button id="edit-working-time-button" class="btn btn-md btn-warning" [disabled]="!workingTimeChangeAllowed" (click)="openDialog($event)">
<fa-icon [icon]="faHourglassHalf" />
<span class="d-none d-md-inline">{{ 'artemisApp.examManagement.editWorkingTime.title' | artemisTranslate }}</span>
</button>
2 changes: 1 addition & 1 deletion src/test/playwright/e2e/exam/ExamParticipation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ test.describe('Exam participation', () => {
}

const announcement = 'Important announcement!';
await examManagement.openAnnouncementPopup();
await examManagement.openAnnouncementDialog();
const announcementTypingTime = dayjs();
await examManagement.typeAnnouncementMessage(announcement);
await examManagement.verifyAnnouncementContent(announcementTypingTime, announcement, instructor.username);
Expand Down
38 changes: 33 additions & 5 deletions src/test/playwright/support/pageobjects/exam/ExamManagementPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class ExamManagementPage {
await expect(this.page.locator('#exercise-result-score')).toHaveText(score);
}

async openAnnouncementPopup() {
async openAnnouncementDialog() {
await this.page.locator('#announcement-create-button').click();
}

Expand All @@ -118,19 +118,47 @@ export class ExamManagementPage {
}

async verifyAnnouncementContent(announcementTime: Dayjs, message: string, authorUsername: string) {
const announcementPopup = this.page.locator('.modal-content');
const announcementDialog = this.page.locator('.modal-content');
const timeFormat = 'MMM D, YYYY HH:mm';
const announcementTimeFormatted = announcementTime.format(timeFormat);
const announcementTimeAfterMinute = announcementTime.add(1, 'minute').format(timeFormat);
await expect(announcementPopup.locator('.date').getByText(new RegExp(`(${announcementTimeFormatted}|${announcementTimeAfterMinute})`))).toBeVisible();
await expect(announcementPopup.locator('.content').getByText(message)).toBeVisible();
await expect(announcementPopup.locator('.author').getByText(authorUsername)).toBeVisible();
await expect(announcementDialog.locator('.date').getByText(new RegExp(`(${announcementTimeFormatted}|${announcementTimeAfterMinute})`))).toBeVisible();
await expect(announcementDialog.locator('.content').getByText(message)).toBeVisible();
await expect(announcementDialog.locator('.author').getByText(authorUsername)).toBeVisible();
}

async sendAnnouncement() {
await this.page.locator('button', { hasText: 'Send Announcement' }).click();
}

async openEditWorkingTimeDialog() {
await this.page.locator('#edit-working-time-button').click();
}

async changeExamWorkingTime(newWorkingTime: any) {
if (newWorkingTime.hours) {
await this.page.locator('#workingTimeHours').fill(newWorkingTime.hours.toString());
}
if (newWorkingTime.minutes) {
await this.page.locator('#workingTimeMinutes').fill(newWorkingTime.minutes.toString());
}
if (newWorkingTime.seconds) {
await this.page.locator('#workingTimeSeconds').fill(newWorkingTime.seconds.toString());
}
}

async verifyExamWorkingTimeChange(previousWorkingTime: any, newWorkingTime: any) {
const previousWorkingTimeString = `${previousWorkingTime.days}d ${previousWorkingTime.hours}h ${previousWorkingTime.minutes}min`;
const newWorkingTimeString = `${newWorkingTime.days}d ${newWorkingTime.hours}h ${newWorkingTime.minutes}min`;
await expect(this.page.locator('[data-testid="old-time"]').getByText(previousWorkingTimeString)).toBeVisible();
await expect(this.page.locator('[data-testid="new-time"]').getByText(newWorkingTimeString)).toBeVisible();
}

async confirmWorkingTimeChange(examTitle: string) {
await this.page.locator('#confirm-entity-name').fill(examTitle);
await this.page.locator('#confirm').click();
}

async clickEdit() {
await this.page.locator('#editButton').click();
}
Expand Down

0 comments on commit 08e7d09

Please sign in to comment.