Skip to content

Commit 2169aab

Browse files
committed
fix test
1 parent 67c1b29 commit 2169aab

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

env.d/development/backend.e2e

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@ EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
3232

3333
# Debug
3434
DJANGO_DEBUG=True
35+
36+
# Max recipients per message settings for E2E tests
37+
MAX_RECIPIENTS_PER_MESSAGE=200
38+
MAX_DEFAULT_RECIPIENTS_PER_MESSAGE=150

src/e2e/src/__tests__/message-max-recipients-admin.spec.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ test.describe("Message Max Recipients Per Message", () => {
2020
await page.getByRole("heading", { name: "Maildomains management" }).waitFor({ state: "visible" });
2121

2222
// Update max recipients per message
23-
const tuneLimitsButton = page.getByRole('button', { name: 'tune Limits' });
23+
const tuneLimitsButton = page.getByRole('button', { name: 'tune Settings' });
2424
await tuneLimitsButton.click();
2525
const maxRecipientsPerMessageInput = page.getByLabel("Maximum recipients per message");
26-
await maxRecipientsPerMessageInput.fill("100");
26+
await maxRecipientsPerMessageInput.fill("50");
2727
const saveButton = page.getByRole('button', { name: 'Save' });
2828
await saveButton.click();
29-
await page.getByText('The domain limits have been').waitFor({ state: "visible" });
29+
await page.getByText('The domain settings have been updated!').waitFor({ state: "visible" });
3030

3131
// Go back to the maildomain list
3232
const backToMaildomainsButton = page.getByRole('link', { name: 'mail', exact: true });
@@ -43,42 +43,47 @@ test.describe("Message Max Recipients Per Message", () => {
4343
const helpText = await page.locator('text=/maximum.*recipients/i').textContent();
4444
const limitMatch = helpText?.match(/\d+/);
4545
const limit = limitMatch ? parseInt(limitMatch[0]) : null;
46-
console.log(limitMatch);
47-
console.log(limit);
48-
expect(limit).toBe(100);
46+
expect(limit).toBe(50);
4947
});
5048

51-
test("should super user can customize domain max recipients per message more than the global limit", async ({ page, browserName }) => {
52-
// Get the current limit from help text
49+
test("should reject domain limit exceeding global maximum", async ({ page, browserName }) => {
50+
// Login as super_admin
5351
await page.goto("/");
5452
await signInKeycloakIfNeeded({ page, username: `super_admin.e2e.${browserName}` });
55-
// Navigate to new message form
53+
54+
// Navigate to domain admin
5655
const moreOptionsButton = page.getByRole('button', { name: 'More options' });
5756
await moreOptionsButton.click();
5857
const manageMaildomainButton = page.getByRole('menuitem', { name: 'Domain admin' });
5958
await manageMaildomainButton.click();
6059
await page.waitForURL("/domain");
6160
await page.getByRole("heading", { name: "Maildomains management" }).waitFor({ state: "visible" });
62-
// Update max recipients per message
63-
const tuneLimitsButton = page.getByRole('button', { name: 'tune Limits' });
64-
await tuneLimitsButton.click();
61+
62+
// Open settings modal
63+
const tuneSettingsButton = page.getByRole('button', { name: 'tune Settings' });
64+
await tuneSettingsButton.click();
6565
await page.waitForTimeout(50);
6666
const maxRecipientsPerMessageInput = page.getByLabel("Maximum recipients per message");
67-
expect(maxRecipientsPerMessageInput).toBeVisible({ timeout: 5000 });
68-
console.log(maxRecipientsPerMessageInput);
67+
await expect(maxRecipientsPerMessageInput).toBeVisible({ timeout: 5000 });
68+
69+
// Store current value to verify it's unchanged after failed save
70+
const initialValue = await maxRecipientsPerMessageInput.inputValue();
71+
72+
// Try to set a limit exceeding global maximum (200)
6973
await maxRecipientsPerMessageInput.fill("250");
7074
const saveButton = page.getByRole('button', { name: 'Save' });
7175
await saveButton.click();
7276
await page.getByText('The limit cannot exceed the global maximum of 200 recipients.').waitFor({ state: "visible" });
73-
// close the modal
77+
78+
// Close the modal
7479
await page.getByRole('button', { name: 'close' }).click();
7580

76-
// check limit is still 100
77-
await tuneLimitsButton.click();
81+
// Verify the limit was not changed
82+
await tuneSettingsButton.click();
7883
await page.waitForTimeout(50);
79-
expect(maxRecipientsPerMessageInput).toBeVisible({ timeout: 5000 });
80-
const inputValue = await maxRecipientsPerMessageInput.inputValue();
81-
expect(parseInt(inputValue)).toBe(100);
84+
await expect(maxRecipientsPerMessageInput).toBeVisible({ timeout: 5000 });
85+
const finalValue = await maxRecipientsPerMessageInput.inputValue();
86+
expect(finalValue).toBe(initialValue);
8287
});
8388

8489
test("should domain admin can customize mailbox max recipients per message ", async ({ page, browserName }) => {

src/e2e/src/__tests__/message-max-recipients.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ test.describe("Message Recipients Limit", () => {
2727
const limitMatch = helpText?.match(/\d+/);
2828
expect(limitMatch).toBeTruthy();
2929
const limit = parseInt(limitMatch![0]);
30-
expect(limit).toBe(100);
30+
// FIXME: this is value set in message-max-recipients-admin.spec.ts
31+
expect(limit).toBe(50);
3132
});
3233

3334
});

0 commit comments

Comments
 (0)