From 9b16d45df2d25e167ae9a6d6a91f7d991ef8fc14 Mon Sep 17 00:00:00 2001 From: quacumque Date: Wed, 15 Oct 2025 13:54:05 +0900 Subject: [PATCH] fix(client): pass bytes to `POST /query` properly Failed only in browser. Added more tests to catch this kind of error in future. Signed-off-by: quacumque --- packages/client/api.ts | 4 +- tests/browser/cypress/e2e/main.cy.ts | 24 +++- tests/browser/src/App.vue | 7 +- tests/browser/src/components/CreateDomain.vue | 4 +- .../browser/src/components/EventListener.vue | 65 ----------- tests/browser/src/components/Listener.vue | 106 ++++++++++++++++++ tests/browser/src/components/QueryDomains.vue | 26 +++++ 7 files changed, 163 insertions(+), 73 deletions(-) delete mode 100644 tests/browser/src/components/EventListener.vue create mode 100644 tests/browser/src/components/Listener.vue create mode 100644 tests/browser/src/components/QueryDomains.vue diff --git a/packages/client/api.ts b/packages/client/api.ts index 047ecdf6..a40a16c3 100644 --- a/packages/client/api.ts +++ b/packages/client/api.ts @@ -167,10 +167,12 @@ export class MainAPI { } public async query(query: dm.SignedQuery): Promise { + const bytes = getCodec(dm.SignedQuery).encode(query) return this.http .getFetch()(urlJoinPath(this.http.toriiBaseURL, ENDPOINT_QUERY), { method: 'POST', - body: [getCodec(dm.SignedQuery).encode(query)], + // FIXME: see `transaction` method, same issue + body: bytes as unknown as BodyInit, }) .then(handleQueryResponse) } diff --git a/tests/browser/cypress/e2e/main.cy.ts b/tests/browser/cypress/e2e/main.cy.ts index e15a3539..6ab4478c 100644 --- a/tests/browser/cypress/e2e/main.cy.ts +++ b/tests/browser/cypress/e2e/main.cy.ts @@ -9,7 +9,9 @@ it('Register new domain and wait until commitment', () => { // wait for the genesis block cy.get('h3').contains('Status').closest('div').contains('Blocks: 2') - cy.get('button').contains('Listen').click().contains('Stop') + cy.get('button').contains('Listen').click() + cy.get('li.active-events').contains('Events: true') + cy.get('li.active-blocks').contains('Blocks: true') cy.get('input').type('bob') cy.get('button').contains('Register domain').click() @@ -21,10 +23,26 @@ it('Register new domain and wait until commitment', () => { const EXPECTED_EVENTS = 8 // And all events are caught - cy.get('ul.events-list') + cy.get('ul.events') .children('li') .should('have.length', EXPECTED_EVENTS) .last() - .contains('Block') + .contains('Block (height=4)') .contains('Applied') + + // And all blocks too + cy.get('ul.blocks') + .children('li') + .should('have.length', 4) + .first().contains('1') + .parent() + .last().contains('4') + + cy.get('button').contains('Query domains').click() + + // our registered domain appears + cy.get('ul.domains') + .children('li') + .should('have.length', 3) + .first().contains('bob') }) diff --git a/tests/browser/src/App.vue b/tests/browser/src/App.vue index c1e24152..5d56c9c8 100644 --- a/tests/browser/src/App.vue +++ b/tests/browser/src/App.vue @@ -1,7 +1,8 @@