Skip to content

Commit

Permalink
fix: 🐛 fix errant trailing slash in url (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskaransarkaria authored Dec 31, 2023
1 parent af74892 commit d74f1c0
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 46 deletions.
1 change: 1 addition & 0 deletions src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/about/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/classes/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/contact/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/gift-guide/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/payment/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/privacy-policy/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/repairs/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/shop/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/sitemap.xml/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/terms-and-conditions/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
1 change: 1 addition & 0 deletions src/routes/useful-links/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "never";
4 changes: 2 additions & 2 deletions tests/components/footer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ test.describe("Footer", () => {
);

await page.locator(".footer-icons >> nth=0").click();
await page.waitForURL("http://localhost:4000/contact/");
expect(page.url()).toBe("http://localhost:4000/contact/");
await page.waitForURL("http://localhost:4000/contact");
expect(page.url()).toBe("http://localhost:4000/contact");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");
Expand Down
72 changes: 36 additions & 36 deletions tests/components/header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,53 @@ test.describe("Header", () => {
await expect(page.locator("#nav-icon")).toHaveClass(/open/);
await expect(page.locator("button>> nth=0")).toHaveText("shop");
await page.locator("button>> nth=0").click();
await page.waitForURL("http://localhost:4000/shop/");
expect(page.url()).toBe("http://localhost:4000/shop/");
await page.waitForURL("http://localhost:4000/shop");
expect(page.url()).toBe("http://localhost:4000/shop");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");
await page.locator("#nav-icon").click();

await expect(page.locator("button>> nth=1")).toHaveText("gift guide");
await page.locator("button>> nth=1").click();
await page.waitForURL("http://localhost:4000/gift-guide/");
expect(page.url()).toBe("http://localhost:4000/gift-guide/");
await page.waitForURL("http://localhost:4000/gift-guide");
expect(page.url()).toBe("http://localhost:4000/gift-guide");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");
await page.locator("#nav-icon").click();

await expect(page.locator("button>> nth=2")).toHaveText("repairs");
await page.locator("button>> nth=2").click();
await page.waitForURL("http://localhost:4000/repairs/");
expect(page.url()).toBe("http://localhost:4000/repairs/");
await page.waitForURL("http://localhost:4000/repairs");
expect(page.url()).toBe("http://localhost:4000/repairs");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");
await page.locator("#nav-icon").click();

await expect(page.locator("button>> nth=3")).toHaveText("classes");
await page.locator("button>> nth=3").click();
await page.waitForURL("http://localhost:4000/classes/");
expect(page.url()).toBe("http://localhost:4000/classes/");
await page.waitForURL("http://localhost:4000/classes");
expect(page.url()).toBe("http://localhost:4000/classes");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");
await page.locator("#nav-icon").click();

await expect(page.locator("button>> nth=4")).toHaveText("about");
await page.locator("button>> nth=4").click();
await page.waitForURL("http://localhost:4000/about/");
expect(page.url()).toBe("http://localhost:4000/about/");
await page.waitForURL("http://localhost:4000/about");
expect(page.url()).toBe("http://localhost:4000/about");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");
await page.locator("#nav-icon").click();

await expect(page.locator("button>> nth=5")).toHaveText("contact");
await page.locator("button>> nth=5").click();
await page.waitForURL("http://localhost:4000/contact/");
expect(page.url()).toBe("http://localhost:4000/contact/");
await page.waitForURL("http://localhost:4000/contact");
expect(page.url()).toBe("http://localhost:4000/contact");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");
Expand All @@ -78,72 +78,72 @@ test.describe("Header", () => {

await expect(page.locator("a >> nth=0")).toHaveText("shop");
await page.locator("a >> nth=0").click();
await page.waitForURL("http://localhost:4000/shop/");
expect(page.url()).toBe("http://localhost:4000/shop/");
await page.waitForURL("http://localhost:4000/shop");
expect(page.url()).toBe("http://localhost:4000/shop");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");

await expect(page.locator("a >> nth=1")).toHaveText("gift guide");
await page.locator("a >> nth=1").click();
await page.waitForURL("http://localhost:4000/gift-guide/");
expect(page.url()).toBe("http://localhost:4000/gift-guide/");
await page.waitForURL("http://localhost:4000/gift-guide");
expect(page.url()).toBe("http://localhost:4000/gift-guide");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");

await expect(page.locator("a >> nth=2")).toHaveText("repairs");
await page.locator("a >> nth=2").click();
await page.waitForURL("http://localhost:4000/repairs/");
expect(page.url()).toBe("http://localhost:4000/repairs/");
await page.waitForURL("http://localhost:4000/repairs");
expect(page.url()).toBe("http://localhost:4000/repairs");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");

await expect(page.locator("a >> nth=3")).toHaveText("classes");
await page.locator("a >> nth=3").click();
await page.waitForURL("http://localhost:4000/classes/");
expect(page.url()).toBe("http://localhost:4000/classes/");
await page.waitForURL("http://localhost:4000/classes");
expect(page.url()).toBe("http://localhost:4000/classes");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");

await expect(page.locator("a >> nth=4")).toHaveText("about");
await page.locator("a >> nth=4").click();
await page.waitForURL("http://localhost:4000/about/");
expect(page.url()).toBe("http://localhost:4000/about/");
await page.waitForURL("http://localhost:4000/about");
expect(page.url()).toBe("http://localhost:4000/about");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");

await expect(page.locator("a >> nth=5")).toHaveText("contact");
await page.locator("a >> nth=5").click();
await page.waitForURL("http://localhost:4000/contact/");
expect(page.url()).toBe("http://localhost:4000/contact/");
await page.waitForURL("http://localhost:4000/contact");
expect(page.url()).toBe("http://localhost:4000/contact");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");

// this block clicks each of the links in the header without returning to the homepage
// making sure they go to the correct place
await page.locator("a >> nth=0").click();
await page.waitForURL("http://localhost:4000/shop/");
expect(page.url()).toBe("http://localhost:4000/shop/");
await page.waitForURL("http://localhost:4000/shop");
expect(page.url()).toBe("http://localhost:4000/shop");
await page.locator("a >> nth=1").click();
await page.waitForURL("http://localhost:4000/gift-guide/");
expect(page.url()).toBe("http://localhost:4000/gift-guide/");
await page.waitForURL("http://localhost:4000/gift-guide");
expect(page.url()).toBe("http://localhost:4000/gift-guide");
await page.locator("a >> nth=2").click();
await page.waitForURL("http://localhost:4000/repairs/");
expect(page.url()).toBe("http://localhost:4000/repairs/");
await page.waitForURL("http://localhost:4000/repairs");
expect(page.url()).toBe("http://localhost:4000/repairs");
await page.locator("a >> nth=3").click();
await page.waitForURL("http://localhost:4000/classes/");
expect(page.url()).toBe("http://localhost:4000/classes/");
await page.waitForURL("http://localhost:4000/classes");
expect(page.url()).toBe("http://localhost:4000/classes");
await page.locator("a >> nth=4").click();
await page.waitForURL("http://localhost:4000/about/");
expect(page.url()).toBe("http://localhost:4000/about/");
await page.waitForURL("http://localhost:4000/about");
expect(page.url()).toBe("http://localhost:4000/about");
await page.locator("a >> nth=5").click();
await page.waitForURL("http://localhost:4000/contact/");
expect(page.url()).toBe("http://localhost:4000/contact/");
await page.waitForURL("http://localhost:4000/contact");
expect(page.url()).toBe("http://localhost:4000/contact");
await page.locator("img.enki-logo").click();
await page.waitForURL("http://localhost:4000/");
expect(page.url()).toBe("http://localhost:4000/");
Expand Down
16 changes: 8 additions & 8 deletions tests/routes/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ test.describe("Desktop Home Page", () => {
await page.goto("/");
await expect(page).toHaveScreenshot({ maxDiffPixelRatio: 0.15 });
await page.locator("data-test-id=repairs").click();
await page.waitForURL("http://localhost:4000/repairs/");
expect(page.url()).toBe("http://localhost:4000/repairs/");
await page.waitForURL("http://localhost:4000/repairs");
expect(page.url()).toBe("http://localhost:4000/repairs");
await page.goBack();
expect(page.url()).toBe("http://localhost:4000/");
await page.locator("data-test-id=classes").click();
await page.waitForURL("http://localhost:4000/classes/");
expect(page.url()).toBe("http://localhost:4000/classes/");
await page.waitForURL("http://localhost:4000/classes");
expect(page.url()).toBe("http://localhost:4000/classes");
await page.goBack();
expect(page.url()).toBe("http://localhost:4000/");
await page.locator("data-test-id=online-shop").click();
await page.waitForURL("http://localhost:4000/shop/");
expect(page.url()).toBe("http://localhost:4000/shop/");
await page.waitForURL("http://localhost:4000/shop");
expect(page.url()).toBe("http://localhost:4000/shop");
await page.goBack();
expect(page.url()).toBe("http://localhost:4000/");
await page.locator("data-test-id=guide").click();
await page.waitForURL("http://localhost:4000/gift-guide/");
expect(page.url()).toBe("http://localhost:4000/gift-guide/");
await page.waitForURL("http://localhost:4000/gift-guide");
expect(page.url()).toBe("http://localhost:4000/gift-guide");
await page.goBack();
expect(page.url()).toBe("http://localhost:4000/");
});
Expand Down

0 comments on commit d74f1c0

Please sign in to comment.