Skip to content

test: test server.origin#17886

Merged
sapphi-red merged 6 commits into
vitejs:mainfrom
hi-ogawa:test-server-origin
Aug 20, 2024
Merged

test: test server.origin#17886
sapphi-red merged 6 commits into
vitejs:mainfrom
hi-ogawa:test-server-origin

Conversation

@hi-ogawa
Copy link
Copy Markdown
Contributor

Description

This PR adds a test case for server.origin (introduced long time ago in #5104). The playground here doesn't actually have a separate server, so it doesn't really make sense, but this confirms that url asset is served with server.origin prefix as intended.

I also made a PR on sapphi-red/vite-setup-catalogue#39 to update an example to show case the actual usage with backend.

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@hi-ogawa hi-ogawa marked this pull request as ready for review August 15, 2024 05:08
Comment on lines -30 to -34
server: {
// This option caused issues with HMR,
// although it should not affect the build
origin: 'http://localhost:8080',
},
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.

Technically this is testing server.origin, but this relies on rather redundant prepend/strip base manipulation, which is going to removed in #17886.

Comment thread playground/backend-integration/__tests__/backend-integration.spec.ts Outdated
Comment thread playground/backend-integration/__tests__/backend-integration.spec.ts Outdated
Comment on lines +27 to +31
await vi.waitFor(() =>
page
.locator('.asset-reference.outside-root .asset-preview')
.evaluate((el: HTMLImageElement) => el.naturalWidth > 0),
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this use expect so that it throws if the image is not shown yet? Not familiar with waitFor, but I thought it would retry only when it throws

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.

Oh, good catch. I meant to use waitUntil https://vitest.dev/api/vi.html#vi-waituntil

bluwy
bluwy previously approved these changes Aug 16, 2024
@sapphi-red sapphi-red added p1-chore Doesn't change code behavior (priority) test labels Aug 20, 2024
Comment thread playground/backend-integration/vite.config.js Outdated
@sapphi-red sapphi-red merged commit ed5ecd9 into vitejs:main Aug 20, 2024
@hi-ogawa hi-ogawa deleted the test-server-origin branch August 20, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p1-chore Doesn't change code behavior (priority) test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants