Skip to content

Fix tests msg deletion types#70

Open
Bilb wants to merge 6 commits intomainfrom
fix-tests-msg-deletion-types
Open

Fix tests msg deletion types#70
Bilb wants to merge 6 commits intomainfrom
fix-tests-msg-deletion-types

Conversation

@Bilb
Copy link
Collaborator

@Bilb Bilb commented Mar 3, 2026

No description provided.

@Bilb Bilb requested a review from Miki-Session March 3, 2026 05:50
Comment on lines +61 to +65
await clickOnElement({
window,
strategy: 'data-testid',
selector: 'session-confirm-ok-button',
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be simplified to use clickOn instead:

await clickOn(window, Global.confirmButton);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

replaced a bunch of the existing ones too

Comment on lines +56 to +70
export async function waitForElement({
selector,
strategy,
window,
maxWaitMs,
shouldLog,
text,
}: {
window: Page;
strategy: Strategy;
selector: string;
maxWaitMs?: number;
text?: string;
shouldLog: boolean;
}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This pattern discourages the use of the centralized locator classes that have been introduced in an earlier PR. I would prefer something like this:

export async function waitFor(
  window: Page,
  locator: StrategyExtractionObj,
  options?: { maxWait?: number; text?: string; shouldLog?: boolean },
)

A legacy wrapper (similar to clickOnElement -> clickOn) might help in keeping this minimal effort.

Copy link
Collaborator

@Miki-Session Miki-Session Mar 3, 2026

Choose a reason for hiding this comment

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

In a perfect world we'd then have a ClickOptions and a WaitOptions type (replacing the current ElementOptions) but that might be going too far for this PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have implemented the first comment as part of this PR

Comment on lines 124 to 130
export async function waitForMatchingText(
window: Page,
text: string,
maxWait?: number,
maxWait: number,
) {
const builtSelector = `css=:has-text("${text}")`;
const maxTimeout = maxWait ?? 55000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather pick a sensible default (e.g. 10-15s) and let the caller decide if they want to deviate from that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the caller should pick the sensible default, as this is the one that has the context. Hence why I think this should always be provided.
Some of those calls are looking for a context menu item to show after a right click. And they were waiting for 55s until they eventually failed, when 50ms would have been enough to know for sure.

Comment on lines 115 to 117
const banMeUnbanLaterMsg = `Ban me but unban me later! - ${Date.now()}`;
const bannedCheckMsg = `I'm banned :( - ${Date.now()}`;
const msg3 = `Freedom! - ${Date.now()}`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Odd choice to rename 2 out of 3 messages only.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed to freedomNowMsg

Comment on lines +198 to +201
// Now, try to remove a new message as Alice (admin) sent by Bob
console.log(
`Now, try to remove a new message as ${alice.userName} (admin) sent by ${bob.userName}`,
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Without knowing the deletion code I can't say if this is the same code path for desktop; but in my mind, a member being able to global delete, and an admin being able to global delete, are two different things.
If bob's deletion fails the test never gets to checking if an admin can delete. Therefore these should be independent tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have tweaked this, let me know what you think

Comment on lines +225 to +226
test_group_Alice_2W_Bob_1W_Charlie_1W(
'Delete message locally in group',
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't look like we're checking anything related to an admin's linked devices so this can probably be simplified to test_group_Alice_1W_Bob_1W_Charlie_1W

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have tweaked this

Comment on lines +272 to +275
await deleteMessageFor(
charlieWindow1,
deletedMessageFromBob2,
'device_only',
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are independent events. If Bob's local deletion of his own message fails we get no test result on Charlie deleting someone else's message locally. These should be separate tests.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The comments in this file expand on this but the 100% test coverage would be as follows. Maybe a job for a follow-up PR.

  • Admin deletes outgoing (local and global)
  • Admin deletes incoming (local and global)
  • Member deletes outgoing (local and global)
  • Member deletes incoming (local only)

Comment on lines +169 to +170
// Now that the user is unban, check that we can ban and delete all.
// Note: a single test is doing all of those steps because having two of them on the same seed turns out to make both unreliable
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand the limitation but this now depends on every step working along the path.
Would it be too silly to assign a second admin seed for this test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants