Skip to content

Fix test using a mock redirected response#667

Merged
tintinthong merged 13 commits into
add-extension-and-realm-infofrom
fix-test-using-a-mock-redirected-response
Sep 25, 2023
Merged

Fix test using a mock redirected response#667
tintinthong merged 13 commits into
add-extension-and-realm-infofrom
fix-test-using-a-mock-redirected-response

Conversation

@tintinthong

@tintinthong tintinthong commented Sep 21, 2023

Copy link
Copy Markdown
Contributor

This wud complete CS-5982

2 issues

  • source fetching without an extension returns a 302, eg person. We usually rely on native fetch to follow this response, but since we use realm.maybeHandle in test our app just gets a 302
  • source fetching with an extension doesn't return a response.url in host test, eg person.gts rather it returns response.url =''

Solution

create overriding url handlers that

  • create a mock response that allows us to mutate return response.url. Response object doesn't allow this
  • if we expect a redirect, just return the redirected response

There are ofcourse assumptions about how the handler overrides the request. I tried my best to restrict as much as possible and if the handler doesn't pick up the request just pass it along to its handlers set previously

@tintinthong
tintinthong changed the base branch from main to add-extension-and-realm-info September 21, 2023 09:15
@github-actions

github-actions Bot commented Sep 21, 2023

Copy link
Copy Markdown
Contributor

Test Results

388 tests  +373   381 ✔️ +370   5m 10s ⏱️ + 5m 0s
    1 suites ±    0       7 💤 +    4 
    1 files   ±    0       0  -     1 

Results for commit 927700f. ± Comparison against base commit cc90d68.

♻️ This comment has been updated with latest results.

@tintinthong

tintinthong commented Sep 22, 2023

Copy link
Copy Markdown
Contributor Author

If preferred for ease of review can merge this into the root branch -- feel free to do so (squash & merge wud b good)

@habdelra habdelra left a comment

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.

The approach looks good, but there a couple things you need to fix.

Comment thread packages/host/tests/helpers/index.gts Outdated
Comment thread packages/host/tests/helpers/index.gts Outdated
isCardSourceFetch(request) &&
urlParts.length === 1 //has no extension
) {
const realmPaths = new RealmPaths(testRealmURL);

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.

testRealmPathURL is just the default test realm URL. There is an option to configure the test realm with a different URL and we do that for a few tests—don’t assume this is the realm URL.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmmm ok fixed this. But I made the handler pass an argument (required) of realmURL. I thought ideally, I would build something higher order which allows the handlers to have realmURL,adapter and maybeHandle available but the change seemed a bit too much and made the handlers being passed more unclear. I prefer this way of forcing the test maker to specify the realmURL.

@tintinthong
tintinthong merged commit 466ee51 into add-extension-and-realm-info Sep 25, 2023
@delete-merged-branch
delete-merged-branch Bot deleted the fix-test-using-a-mock-redirected-response branch September 25, 2023 13:02
tintinthong added a commit that referenced this pull request Sep 26, 2023
* get file extension and realm info

* reinclude test

* put getRealmInfo in resource

* fix url bug

* cache request

* lint

* Use adoption manager and use loading states

* add selection of card

* mock out some ui

* fix lint

* refactor for better loading pattern and clearer role

* Change selections to a single object

* might as well use a select button

* add comment

* fix loading

* place realm info deeper in definition info

* maintain selected card type api

* TODO for test

* TODO test

* wokraround 4 redirect in host test

* Revert "TODO test"

This reverts commit d1df438.

* Revert "TODO for test"

This reverts commit 20f00a6.

* fix due to card no longer being resource. TODO: solve .json identification

* Fix test using a mock redirected response (#667)

* register a redirect handler that returns redirected response

* revert original change

* fix

* fix

* fix

* fix lint

* fix

* reposition

* clean up & organise useage

* fix file response.url not returning

* fix url parts using pathname

* arg to pass in realm

* make realm url explicit to guard from the wrong use of handle

* use pathname

* move everything to code mode

* Fix lint

* Fix linting

* fix info service to get card source accept header
burieberry added a commit that referenced this pull request Jul 20, 2026
FigJam-style infinite-canvas board card, step 1 of CS-12193: pan,
cursor-anchored wheel/pinch zoom with momentum (rig.gts camera engine),
zoom toolbar, and layout-independent keyboard shortcuts, with live tests
and a demo instance. Continues development in the monorepo; the
boxel-catalog PRs (#666, #667) hold the earlier history.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
burieberry added a commit that referenced this pull request Jul 20, 2026
FigJam-style infinite-canvas board card, step 1 of CS-12193: pan,
cursor-anchored wheel/pinch zoom with momentum (rig.gts camera engine),
zoom toolbar, and layout-independent keyboard shortcuts, with live tests
and a demo instance. Continues development in the monorepo; the
boxel-catalog PRs (#666, #667) hold the earlier history.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
burieberry added a commit that referenced this pull request Jul 21, 2026
FigJam-style infinite-canvas board card, step 1 of CS-12193: pan,
cursor-anchored wheel/pinch zoom with momentum (rig.gts camera engine),
zoom toolbar, and layout-independent keyboard shortcuts, with live tests
and a demo instance. Continues development in the monorepo; the
boxel-catalog PRs (#666, #667) hold the earlier history.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
burieberry added a commit that referenced this pull request Jul 21, 2026
FigJam-style infinite-canvas board card, step 1 of CS-12193: pan,
cursor-anchored wheel/pinch zoom with momentum (rig.gts camera engine),
zoom toolbar, and layout-independent keyboard shortcuts, with live tests
and a demo instance. Continues development in the monorepo; the
boxel-catalog PRs (#666, #667) hold the earlier history.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
burieberry added a commit that referenced this pull request Jul 21, 2026
* Add poster-board to experiments realm

FigJam-style infinite-canvas board card, step 1 of CS-12193: pan,
cursor-anchored wheel/pinch zoom with momentum (rig.gts camera engine),
zoom toolbar, and layout-independent keyboard shortcuts, with live tests
and a demo instance. Continues development in the monorepo; the
boxel-catalog PRs (#666, #667) hold the earlier history.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Update readme

* Scope poster-board keyboard shortcuts to the board element

Move the zoom-shortcut keydown listener from window onto the focusable
board root so Shift+=/−/0 only act when the board is the active surface,
and two isolated instances can't both react to one keystroke. Panning
focuses the board explicitly since preventDefault on pointerdown
suppresses the default click-to-focus.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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