fix: Bug - Attachments gets syncronized corrupt
This commit is contained in:
@@ -132,6 +132,31 @@ export class ChatMessagesPage {
|
||||
}).toBe(true);
|
||||
}
|
||||
|
||||
/** SHA-256 of the bytes currently served by the rendered chat image. */
|
||||
async getMessageImageSha256(altText: string): Promise<string> {
|
||||
const image = this.getMessageImageByAlt(altText);
|
||||
|
||||
return image.evaluate(async (element) => {
|
||||
const img = element as HTMLImageElement;
|
||||
const response = await fetch(img.src);
|
||||
const buffer = await response.arrayBuffer();
|
||||
const digest = await crypto.subtle.digest('SHA-256', buffer);
|
||||
|
||||
return [...new Uint8Array(digest)]
|
||||
.map((byte) => byte.toString(16).padStart(2, '0'))
|
||||
.join('');
|
||||
});
|
||||
}
|
||||
|
||||
/** Asserts the rendered chat image is byte-identical to the sent file. */
|
||||
async expectMessageImageContentSha256(altText: string, expectedSha256: string): Promise<void> {
|
||||
await this.expectMessageImageLoaded(altText);
|
||||
await expect.poll(() => this.getMessageImageSha256(altText), {
|
||||
timeout: 30_000,
|
||||
message: `Image ${altText} should be received byte-identical (no truncated/corrupt transfer)`
|
||||
}).toBe(expectedSha256);
|
||||
}
|
||||
|
||||
getEmbedCardByTitle(title: string): Locator {
|
||||
return this.page.locator('app-chat-link-embed').filter({
|
||||
has: this.page.getByText(title, { exact: true })
|
||||
|
||||
Reference in New Issue
Block a user