Skip to content

Commit 208b2ab

Browse files
committed
fix: update changeset and improve test assertions
1 parent 1daafbd commit 208b2ab

File tree

3 files changed

+6
-30
lines changed

3 files changed

+6
-30
lines changed

.changeset/honest-cobras-jog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
'@sveltejs/kit': major
2+
'@sveltejs/kit': patch
33
---
44

55
fix: `fetch` not working when URL is same host but different than `paths.base`

packages/kit/test/apps/options/source/pages/fetch/link-root/+page.server.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ export async function load({ fetch }) {
33
const response1 = await fetch('/', { redirect: 'manual' });
44
// fetch to root without trailing slash
55
const response2 = await fetch('', { redirect: 'manual' });
6-
// fetch to root with custom base path with trailing slash
7-
const response3 = await fetch('/path-base/', { redirect: 'manual' });
8-
// fetch to root with custom base path without trailing slash
9-
const response4 = await fetch('/path-base', { redirect: 'manual' });
106
return {
117
fetches: [
128
{
@@ -18,16 +14,6 @@ export async function load({ fetch }) {
1814
url: response2.url,
1915
response: await response2.text(),
2016
redirect: response2.headers.get('location')
21-
},
22-
{
23-
url: response3.url,
24-
response: await response3.text(),
25-
redirect: response3.headers.get('location')
26-
},
27-
{
28-
url: response4.url,
29-
response: await response4.text(),
30-
redirect: response4.headers.get('location')
3117
}
3218
]
3319
};

packages/kit/test/apps/options/test/paths-assets.test.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,16 @@ test.describe('base path', () => {
8080

8181
test('fetch outside base path succeeds', async ({ page, baseURL }) => {
8282
await page.goto('/path-base/fetch/link-outside-base/');
83-
expect(await page.locator('[data-testid="fetch-url"]').textContent()).toContain(
84-
`${baseURL}/not-base-path/`
85-
);
86-
expect(await page.locator('[data-testid="fetch-response"]').textContent()).toContain(
83+
await expect(page.locator('[data-testid="fetch-url"]')).toHaveText(`${baseURL}/not-base-path/`);
84+
await expect(page.locator('[data-testid="fetch-response"]')).toContainText(
8785
'did you mean to visit'
8886
);
8987
});
9088

9189
test('fetch to root succeeds', async ({ page, baseURL }) => {
9290
await page.goto('/path-base/fetch/link-root/');
9391
// fetch to root with trailing slash
94-
expect(await page.locator('[data-testid="fetch1-url"]').textContent()).toContain(`${baseURL}/`);
92+
await expect(page.locator('[data-testid="fetch1-url"]')).toHaveText(`${baseURL}/`);
9593
const fetch1Response = await page.locator('[data-testid="fetch1-response"]').textContent();
9694
const fetch1Redirect = await page.locator('[data-testid="fetch1-redirect"]').textContent();
9795
expect(
@@ -102,16 +100,8 @@ test.describe('base path', () => {
102100
).toBe(true);
103101

104102
// fetch to root without trailing slash should be relative
105-
expect(await page.locator('[data-testid="fetch2-url"]').textContent()).toBeFalsy();
106-
expect(await page.locator('[data-testid="fetch2-response"]').textContent()).toBe('relative');
107-
108-
// fetch to root with custom base path with trailing slash
109-
expect(await page.locator('[data-testid="fetch3-url"]').textContent()).toBeFalsy();
110-
expect(await page.locator('[data-testid="fetch3-response"]').textContent()).toBe('root');
111-
112-
// fetch to root with custom base path without trailing slash
113-
expect(await page.locator('[data-testid="fetch4-url"]').textContent()).toBeFalsy();
114-
expect(await page.locator('[data-testid="fetch4-redirect"]').textContent()).toBe('/path-base/');
103+
await expect(page.locator('[data-testid="fetch2-url"]')).toBeEmpty();
104+
await expect(page.locator('[data-testid="fetch2-response"]')).toHaveText('relative');
115105
});
116106
});
117107

0 commit comments

Comments
 (0)