Repository: sveltejs/kit
Pull request #8364 (2023-01-06 14:42:43)

Version Packages
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to master, this PR will be updated.


# Releases
## @sveltejs/kit@1.0.6

### Patch Changes

-   Guarantee that `$page.route` has the correct shape ([#8359](https://github.com/sveltejs/kit/pull/8359))



Patch:
diff --git a/.changeset/quiet-feet-compare.md b/.changeset/quiet-feet-compare.md
deleted file mode 100644
index 0a9eb19da..000000000
--- a/.changeset/quiet-feet-compare.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@sveltejs/kit': patch
----
-
-Guarantee that `$page.route` has the correct shape
diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md
index f3206b4f6..765a4e5af 100644
--- a/packages/kit/CHANGELOG.md
+++ b/packages/kit/CHANGELOG.md
@@ -1,5 +1,11 @@
 # @sveltejs/kit
 
+## 1.0.6
+
+### Patch Changes
+
+- Guarantee that `$page.route` has the correct shape ([#8359](https://github.com/sveltejs/kit/pull/8359))
+
 ## 1.0.5
 
 ### Patch Changes
diff --git a/packages/kit/package.json b/packages/kit/package.json
index baddb6a45..cd65af9db 100644
--- a/packages/kit/package.json
+++ b/packages/kit/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "@sveltejs/kit",
-	"version": "1.0.5",
+	"version": "1.0.6",
 	"repository": {
 		"type": "git",
 		"url": "https://github.com/sveltejs/kit",


Test patch:
diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js
index 82dc87df0..613133031 100644
--- a/packages/kit/test/apps/basics/test/client.test.js
+++ b/packages/kit/test/apps/basics/test/client.test.js
@@ -238,7 +238,7 @@ test.describe('Scrolling', () => {
 
 	test('scroll is restored after hitting the back button', async ({ baseURL, clicknav, page }) => {
 		await page.goto('/anchor');
-		await page.click('#scroll-anchor');
+		await page.locator('#scroll-anchor').click();
 		const originalScrollY = /** @type {number} */ (await page.evaluate(() => scrollY));
 		await clicknav('#routing-page');
 		await page.goBack();
@@ -266,7 +266,7 @@ test.describe('Scrolling', () => {
 		const target_scroll_y = rect.y + rect.height - height;
 		await page.evaluate((y) => scrollTo(0, y), target_scroll_y);
 
-		await page.click('[href="/scroll/cross-document/b"]');
+		await page.locator('[href="/scroll/cross-document/b"]').click();
 		expect(await page.textContent('h1')).toBe('b');
 		await page.waitForSelector('body.started');
 
@@ -394,7 +394,7 @@ test.describe('CSS', () => {
 test.describe('Endpoints', () => {
 	test('calls a delete handler', async ({ page }) => {
 		await page.goto('/delete-route');
-		await page.click('.del');
+		await page.locator('.del').click();
 		expect(await page.innerHTML('h1')).toBe('deleted 42');
 	});
 });
@@ -556,43 +556,35 @@ test.describe('Load', () => {
 		test('load does not call fetch if max-age allows it', async ({ page, request }) => {
 			await request.get('/load/cache-control/reset');
 
-			page.addInitScript(`
-			window.now = 0;
-			window.performance.now = () => now;
-		`);
-
 			await page.goto('/load/cache-control');
-			expect(await page.textContent('p')).toBe('Count is 0');
-			await page.waitForTimeout(500);
-			await page.click('button.default');
-			await page.waitForTimeout(500);
-			expect(await page.textContent('p')).toBe('Count is 0');
-
-			await page.evaluate(() => (window.now = 2500));
-			await page.click('button.default');
-			await expect(page.locator('p')).toHaveText('Count is 2');
+			await expect(page.getByText('Count is 0')).toBeVisible();
+			await page.locator('button.default').click();
+			await expect(page.getByText('Count is 0')).toBeVisible();
+
+			// use a cache expiration value high enough that we're confident the earlier
+			// portions of the test will complete before the cache expires
+			await page.waitForTimeout(4000);
+
+			await page.locator('button.default').click();
+			await expect(page.getByText('Count is 2')).toBeVisible();
 		});
 
 		test('load does ignore ttl if fetch cache options says so', async ({ page, request }) => {
 			await request.get('/load/cache-control/reset');
 
 			await page.goto('/load/cache-control');
-			expect(await page.textContent('p')).toBe('Count is 0');
-			await page.waitForTimeout(500);
-			await page.click('button.force');
-			await page.waitForTimeout(500);
-			expect(await page.textContent('p')).toBe('Count is 1');
+			await expect(page.getByText('Count is 0')).toBeVisible();
+			await page.locator('button.force').click();
+			await expect(page.getByText('Count is 1')).toBeVisible();
 		});
 
 		test('load busts cache if non-GET request to resource is made', async ({ page, request }) => {
 			await request.get('/load/cache-control/reset');
 
 			await page.goto('/load/cache-control');
-			expect(await page.textContent('p')).toBe('Count is 0');
-			await page.waitForTimeout(500);
-			await page.click('button.bust');
-			await page.waitForTimeout(500);
-			expect(await page.textContent('p')).toBe('Count is 1');
+			await expect(page.getByText('Count is 0')).toBeVisible();
+			await page.locator('button.bust').click();
+			await expect(page.getByText('Count is 1')).toBeVisible();
 		});
 	});
 
@@ -792,10 +784,10 @@ test.describe('Routing', () => {
 		await page.goto('/routing/hashes/pagestore');
 		expect(await page.textContent('#window-hash')).toBe('');
 		expect(await page.textContent('#page-url-hash')).toBe('');
-		await page.click('[href="#target"]');
+		await page.locator('[href="#target"]').click();
 		expect(await page.textContent('#window-hash')).toBe('#target');
 		expect(await page.textContent('#page-url-hash')).toBe('#target');
-		await page.click('[href="/routing/hashes/pagestore"]');
+		await page.locator('[href="/routing/hashes/pagestore"]').click();
 		await expect(page.locator('#window-hash')).toHaveText('#target'); // hashchange doesn't fire for these
 		await expect(page.locator('#page-url-hash')).toHaveText('');
 	});
@@ -811,7 +803,7 @@ test.describe('Routing', () => {
 
 		try {
 			await page.goto(`/routing/slashes?port=${port}`);
-			await page.click(`a[href="http://localhost:${port}/with-slash/"]`);
+			await page.locator(`a[href="http://localhost:${port}/with-slash/"]`).click();
 
 			expect(urls).toEqual(['/with-slash/']);
 		} finally {
@@ -823,7 +815,7 @@ test.describe('Routing', () => {
 		await page.goto('/routing/external-popstate');
 		expect(await page.textContent('h1')).toBe('hello');
 
-		await page.click('button');
+		await page.locator('button').click();
 		expect(await page.textContent('h1')).toBe('hello');
 
 		await page.goBack();
@@ -836,7 +828,7 @@ test.describe('Routing', () => {
 	test('recognizes clicks outside the app target', async ({ page }) => {
 		await page.goto('/routing/link-outside-app-target/source');
 
-		await page.click('[href="/routing/link-outside-app-target/target"]');
+		await page.locator('[href="/routing/link-outside-app-target/target"]').click();
 		await expect(page.locator('h1')).toHaveText('target: 1');
 	});
 
@@ -850,7 +842,7 @@ test.describe('Routing', () => {
 		page.on('request', (request) => requests.push(request.url()));
 
 		await page.locator('input').fill('updated');
-		await page.click('button');
+		await page.locator('button').click();
 
 		expect(requests).toEqual([]);
 		expect(await page.textContent('h1')).toBe('updated');
@@ -921,7 +913,7 @@ test.describe('$app/stores', () => {
 	test('can use $app/stores from anywhere on client', async ({ page }) => {
 		await page.goto('/store/client-access');
 		await expect(page.locator('h1')).toHaveText('undefined');
-		await page.click('button');
+		await page.locator('button').click();
 		await expect(page.locator('h1')).toHaveText('/store/client-access');
 	});
 
@@ -1014,7 +1006,7 @@ test.describe.serial('Invalidation', () => {
 
 	test('multiple invalidations run concurrently', async ({ page, request }) => {
 		await page.goto('/load/invalidation/multiple');
-		expect(await page.textContent('p')).toBe('layout: 0, page: 0');
+		await expect(page.getByText('layout: 0, page: 0')).toBeVisible();
 
 		await page.click('button.layout');
 		await page.click('button.layout');
@@ -1023,12 +1015,12 @@ test.describe.serial('Invalidation', () => {
 		await page.click('button.layout');
 		await page.click('button.page');
 		await page.click('button.all');
-		await expect(page.locator('p')).toHaveText('layout: 4, page: 4');
+		await expect(page.getByText('layout: 4, page: 4')).toBeVisible();
 	});
 
 	test('invalidateAll persists through redirects', async ({ page }) => {
 		await page.goto('/load/invalidation/multiple/redirect');
-		await page.click('button.redirect');
+		await page.locator('button.redirect').click();
 		await expect(page.locator('p.redirect-state')).toHaveText('Redirect state: done');
 	});
 
@@ -1096,10 +1088,10 @@ test.describe.serial('Invalidation', () => {
 
 	test('$page.url can safely be mutated', async ({ page }) => {
 		await page.goto('/load/mutated-url?q=initial');
-		expect(await page.textContent('h1')).toBe('initial');
+		await expect(page.getByText('initial')).toBeVisible();
 
-		await page.click('button');
-		expect(await page.textContent('h1')).toBe('updated');
+		await page.locator('button').click();
+		await expect(page.getByText('updated')).toBeVisible();
 	});
 });
 
@@ -1146,12 +1138,12 @@ test.describe('data-sveltekit attributes', () => {
 		page.on('request', (r) => requests.push(r.url()));
 
 		await page.goto('/data-sveltekit/reload');
-		await page.click('#one');
+		await page.locator('#one').click();
 		expect(requests).toContain(`${baseURL}/data-sveltekit/reload/target`);
 
 		requests.length = 0;
 		await page.goto('/data-sveltekit/reload');
-		await page.click('#two');
+		await page.locator('#two').click();
 		expect(requests).toContain(`${baseURL}/data-sveltekit/reload/target`);
 
 		requests.length = 0;
@@ -1207,7 +1199,7 @@ test.describe('cookies', () => {
 	test('etag forwards cookies', async ({ page }) => {
 		await page.goto('/cookies/forwarded-in-etag');
 		await expect(page.locator('p')).toHaveText('foo=bar');
-		await Promise.all([page.waitForNavigation(), page.click('button')]);
+		await page.locator('button').click();
 		await expect(page.locator('p')).toHaveText('foo=bar');
 	});
 });
@@ -1224,11 +1216,11 @@ test.describe('Interactivity', () => {
 		await page.goto('/interactivity/toggle-element');
 		expect(await page.textContent('button')).toBe('remove');
 
-		await page.click('button');
+		await page.locator('button').click();
 		expect(await page.textContent('button')).toBe('add');
 		expect(await page.textContent('a')).toBe('add');
 
-		await page.click('a');
+		await page.locator('a').filter({ hasText: 'add' }).click();
 		expect(await page.textContent('a')).toBe('remove');
 
 		expect(errored).toBe(false);