Skip to content

Commit

Permalink
Add pages for each product
Browse files Browse the repository at this point in the history
  • Loading branch information
edvinlinden committed Jun 6, 2022
1 parent fdd0bdc commit 812d177
Show file tree
Hide file tree
Showing 24 changed files with 1,533 additions and 1,156 deletions.
4 changes: 1 addition & 3 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import react from "@astrojs/react";

// https://astro.build/config
export default defineConfig({
buildOptions: {
site: "https://killedby.tech",
},
site: "https://killedby.tech",
integrations: [react()],
});
10 changes: 5 additions & 5 deletions cypress/integration/pages.spec.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
describe("Pages", () => {
it("startpage should have the correct page title", () => {
cy.visit("http://localhost:3000/");
cy.visit("http://localhost:3000/?ref=cypress");
cy.title().should(
"eq",
"Killed by Apple, Google and Microsoft - Discontinued products and services"
);
});

it("Apple page should have the correct page title", () => {
cy.visit("http://localhost:3000/apple/");
cy.visit("http://localhost:3000/apple/?ref=cypress");
cy.title().should(
"eq",
"Killed by Apple - Discontinued products and services"
);
});

it("Google page should have the correct page title", () => {
cy.visit("http://localhost:3000/google/");
cy.visit("http://localhost:3000/google/?ref=cypress");
cy.title().should(
"eq",
"Killed by Google - Discontinued products and services"
);
});

it("Microsoft page should have the correct page title", () => {
cy.visit("http://localhost:3000/microsoft/");
cy.visit("http://localhost:3000/microsoft/?ref=cypress");
cy.title().should(
"eq",
"Killed by Microsoft - Discontinued products and services"
);
});

it("other page should have the correct page title", () => {
cy.visit("http://localhost:3000/other/");
cy.visit("http://localhost:3000/other/?ref=cypress");
cy.title().should(
"eq",
"Killed by other companies - Discontinued products and services"
Expand Down
26 changes: 15 additions & 11 deletions cypress/integration/products.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import googleProducts from "./../../src/assets/products/google.json";
import microsoftProducts from "./../../src/assets/products/microsoft.json";
import appleProducts from "./../../src/assets/products/apple.json";
import otherProducts from "./../../src/assets/products/other.json";
import toSlug from "./../../src/utils/toSlug.ts";

describe("Products", () => {
it("should display correct count for each company", () => {
cy.visit("http://localhost:3000/");
cy.visit("http://localhost:3000/?ref=cypress");

const allSumText = `(${
[
Expand Down Expand Up @@ -56,49 +57,52 @@ describe("Products", () => {
});

it("should only display Apple products", () => {
cy.visit("http://localhost:3000/apple/");
cy.visit("http://localhost:3000/apple/?ref=cypress");
const productsCount = appleProducts.length;

cy.get("[data-cy=product]").should("have.length", productsCount);
});

it("should only display Google products", () => {
cy.visit("http://localhost:3000/google/");
cy.visit("http://localhost:3000/google/?ref=cypress");
const productsCount = googleProducts.length;

cy.get("[data-cy=product]").should("have.length", productsCount);
});

it("should only display Microsoft products", () => {
cy.visit("http://localhost:3000/microsoft/");
cy.visit("http://localhost:3000/microsoft/?ref=cypress");
const productsCount = microsoftProducts.length;

cy.get("[data-cy=product]").should("have.length", productsCount);
});

it("should only display other products", () => {
cy.visit("http://localhost:3000/other/");
cy.visit("http://localhost:3000/other/?ref=cypress");
const productsCount = otherProducts.length;

cy.get("[data-cy=product]").should("have.length", productsCount);
});

it("should display correct product information", () => {
cy.visit("http://localhost:3000/other/");
cy.visit("http://localhost:3000/other/?ref=cypress");

const firstProduct = [...otherProducts].sort(
(a, b) => new Date(b.dateClose) - new Date(a.dateClose)
)[0];

const category =
["apple", "google", "microsoft"].indexOf(firstProduct.company) == -1
? "other"
: firstProduct.company;

const firstProductLink = `/${category}/${toSlug(firstProduct.name)}/`;

cy.get("[data-cy=product]")
.eq(0)
.find("h2>a")
.should("have.text", firstProduct.name)
.should(
"have.attr",
"href",
firstProduct.link + "?ref=killedby.tech"
);
.should("have.attr", "href", firstProductLink);
cy.get("[data-cy=product]").eq(0).find("h2>img").should("exist");
cy.get("[data-cy=product]")
.eq(0)
Expand Down
Loading

0 comments on commit 812d177

Please sign in to comment.