Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: test server.origin #17886

Merged
merged 6 commits into from
Aug 20, 2024
Merged

test: test server.origin #17886

merged 6 commits into from
Aug 20, 2024

Conversation

hi-ogawa
Copy link
Collaborator

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.

Copy link

stackblitz bot commented Aug 15, 2024

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
Collaborator 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 on lines 27 to 31
await vi.waitFor(() =>
page
.locator('.asset-reference.outside-root .asset-preview')
.evaluate((el: HTMLImageElement) => el.naturalWidth > 0),
)
Copy link
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
Collaborator 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
@sapphi-red sapphi-red merged commit ed5ecd9 into vitejs:main Aug 20, 2024
12 checks passed
@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