Skip to content
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
17 changes: 11 additions & 6 deletions apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,14 @@ describe('LIVECHAT - rooms', () => {
expect(body.rooms.some((room: IOmnichannelRoom) => room._id === expectedRoom._id)).to.be.true;
expect(body.rooms.some((room: IOmnichannelRoom) => room._id === expectedRoom2._id)).to.be.true;

await closeOmnichannelRoom(expectedRoom._id);
await closeOmnichannelRoom(expectedRoom2._id);
await deleteVisitor(expectedVisitor.token);
await deleteVisitor(expectedVisitor2.token);
await Promise.all([deleteDepartment(department._id), deleteDepartment(department2._id)]);
// close both rooms before removing visitors/departments (deleting a department with an open room fails)
Comment thread
KevLehman marked this conversation as resolved.
await Promise.all([closeOmnichannelRoom(expectedRoom._id), closeOmnichannelRoom(expectedRoom2._id)]);
await Promise.all([
deleteVisitor(expectedVisitor.token),
deleteVisitor(expectedVisitor2.token),
deleteDepartment(department._id),
deleteDepartment(department2._id),
]);
});
(IS_EE ? it : it.skip)('should return only rooms with the given tags', async () => {
const tag = await saveTags();
Expand Down Expand Up @@ -1787,10 +1790,12 @@ describe('LIVECHAT - rooms', () => {
expect(inquiry).to.have.property('department', targetDepartment._id);
expect(inquiry).to.have.property('status', 'queued');

// the room ends queued (never taken), so close it as the visitor — room.closeByUser rejects a room that is not being served
await request.post(api('livechat/room.close')).send({ rid: newRoom._id, token: newVisitor.token }).expect(200);
Comment on lines +1793 to +1794

@coderabbitai coderabbitai Bot Jul 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the implementation comment.

The API call is correct, but this TypeScript test adds an implementation comment despite the repository guideline to avoid code comments. Remove it and keep the behavior self-documenting through the API call and test structure.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts` around lines 1790 -
1791, Remove the implementation comment immediately above the livechat
room.close API request, leaving the request and its assertions unchanged.

Source: Coding guidelines

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fair — a silent "dev-secret" fallback on a security-critical value is exactly the kind of slip that bites in production. Fixed in the latest push.

The CLI now requires BETTER_AUTH_SECRET alongside DATABASE_URL: it's added to the usage guard (fail-fast, non-zero exit) and named in the usage string, with an explicit "refusing to use a default" error when the DB is set but the secret isn't. No fallback literal remains.

Verified both paths: with the secret exported it creates the admin; with it unset it prints the usage + error and exits 1 without touching the DB.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mzuniga84, thanks for the detailed verification. That addresses the BETTER_AUTH_SECRET fallback concern, but it appears to belong to a different review thread.

This thread is specifically about removing the implementation comment above the livechat/room.close request in apps/meteor/tests/end-to-end/api/livechat/00-rooms.ts.


await Promise.all([
deleteDepartment(initialDepartment._id),
deleteDepartment(targetDepartment._id),
closeOmnichannelRoom(newRoom._id),
deleteVisitor(newVisitor.token),
deleteUser(manager),
updateSetting('Livechat_waiting_queue', false),
Expand Down
12 changes: 12 additions & 0 deletions apps/meteor/tests/end-to-end/api/livechat/19-business-hours.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { password } from '../../../data/user';
import type { TestUser } from '../../../data/users.helper';
import { setUserActiveStatus, createUser, deleteUser, getMe, getUserByUsername, login } from '../../../data/users.helper';
import { IS_EE } from '../../../e2e/config/constants';
import { retry } from '../helpers/retry';

describe('LIVECHAT - business hours', () => {
before((done) => getCredentials(done));
Expand Down Expand Up @@ -962,6 +963,17 @@ describe('LIVECHAT - business hours', () => {
it('should create a new agent and verify if it is assigned to the default business hour which is closed', async () => {
await openOrCloseBusinessHour(defaultBH, false);

// the BH close recalculates agent statuses asynchronously; wait for it to propagate (existing agent loses the
// BH assignment) before creating the new agent, otherwise it is created while the BH still counts as open
await retry(
'BH close propagation is async, so the existing agent may still be assigned on the first fetch',
async () => {
const current: ILivechatAgent = await getMe(agentCredentials);
expect(current.openBusinessHours ?? []).to.have.lengthOf(0);
},
{ retries: 20, delayMs: 250 },
);

const newUser: ILivechatAgent = await createUser();
const newUserCredentials = await login(newUser.username, password);
await createAgent(newUser.username);
Expand Down
Loading