Skip to content

Commit

Permalink
Development: Remove race condition in faky playwright test (#10013)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonEntholzer authored Dec 16, 2024
1 parent 64a0d1e commit 5449cc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/test/playwright/e2e/course/CourseMessages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ test.describe('Course messages', { tag: '@fast' }, () => {
await login(instructor, `/courses/${course.id}/communication?conversationId=${channel.id}`);
const newName = 'new-test-name';
const topic = 'test-topic';
await courseMessages.getName().click();

// each edit action triggers an update to the server, on multinode this can lead to a race condition
await courseMessages.editName(newName);
await courseMessages.editTopic(topic);
await courseMessages.editDescription('New Description');
await courseMessages.closeEditPanel();

await page.reload();
await page.locator('jhi-conversation-header').waitFor({ state: 'visible', timeout: 10000 });
await expect(courseMessages.getName()).toContainText(newName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,35 +170,47 @@ export class CourseMessagesPage {
* @param newName - The new name for the conversation.
*/
async editName(newName: string) {
await this.getName().click();
await this.page.locator('#name-section .action-button').click();
const nameField = this.page.locator('.channels-overview #name');
await nameField.clear();
await nameField.fill(newName);
await this.page.locator('#submitButton').click();
await expect(this.page.locator('#name-section textarea')).toHaveValue(newName);
await this.closeEditPanel();
await this.page.waitForTimeout(200);
}

/**
* Edits the topic of the conversation to a new topic.
* @param newTopic - The new topic for the conversation.
*/
async editTopic(newTopic: string) {
await this.getName().click();
await this.page.locator('#topic-section .action-button').click();
const topicField = this.page.locator('.channels-overview #topic');
await topicField.clear();
await topicField.fill(newTopic);
await this.page.locator('#submitButton').click();
await expect(this.page.locator('#topic-section textarea')).toHaveValue(newTopic);
await this.closeEditPanel();
await this.page.waitForTimeout(200);
}

/**
* Edits the description of the conversation to a new description.
* @param newDescription - The new description for the conversation.
*/
async editDescription(newDescription: string) {
await this.getName().click();
await this.page.locator('#description-section .action-button').click();
const descriptionField = this.page.locator('.channels-overview #description');
await descriptionField.clear();
await descriptionField.fill(newDescription);
await this.page.locator('#submitButton').click();
await expect(this.page.locator('#description-section textarea')).toHaveValue(newDescription);
await this.closeEditPanel();
await this.page.waitForTimeout(200);
}

/**
Expand Down

0 comments on commit 5449cc4

Please sign in to comment.