Skip to content
Draft
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
4 changes: 2 additions & 2 deletions packages/react/src/hooks/useCredentials.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('fetchCredentials', () => {
});

const connectFn = mock(() =>
Promise.resolve({ sessionId: 'sess-4', sessionKey: 'key-4' } as any),
Promise.resolve({ sessionId: 'sess-4', sessionKey: 'key-4' }),
);

const result = await fetchCredentials({
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('fetchCredentials', () => {

const consumeCall = fetchCalls.find((c) => c.url.includes('/consume'));
expect(consumeCall).toBeDefined();
expect(consumeCall!.url).toContain('https://custom-api.example.com');
expect(consumeCall?.url).toContain('https://custom-api.example.com');
});

it('throws when connectUrl returns a non-OK response', async () => {
Expand Down
11 changes: 8 additions & 3 deletions packages/react/src/hooks/usePageActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { JSDOM } from 'jsdom';

const HIGHLIGHT_ATTR = 'data-avatar-highlighted';

function required<T>(value: T | null | undefined, label: string): T {
if (value == null) throw new Error(`Expected ${label} to exist`);
return value;
}

let dom: JSDOM;
let doc: Document;

Expand Down Expand Up @@ -81,7 +86,7 @@ describe('page-actions click behavior', () => {
describe('page-actions scroll_to behavior', () => {
it('calls scrollIntoView on the resolved element', () => {
doc.body.innerHTML = '<section id="features">Features</section>';
const section = doc.getElementById('features')!;
const section = required(doc.getElementById('features'), '#features');
const scrollSpy = mock(() => {});
section.scrollIntoView = scrollSpy;

Expand All @@ -102,7 +107,7 @@ describe('page-actions highlight behavior', () => {
});

it('sets and clears the highlight attribute', () => {
const element = defaultResolveElement('card')!;
const element = required(defaultResolveElement('card'), 'card element');

element.setAttribute(HIGHLIGHT_ATTR, 'true');
expect(element.getAttribute(HIGHLIGHT_ATTR)).toBe('true');
Expand All @@ -112,7 +117,7 @@ describe('page-actions highlight behavior', () => {
});

it('clears highlight after a timeout', async () => {
const element = defaultResolveElement('card')!;
const element = required(defaultResolveElement('card'), 'card element');
element.setAttribute(HIGHLIGHT_ATTR, 'true');

await new Promise<void>((resolve) => {
Expand Down