Skip to content

Commit

Permalink
fix: use web hash history
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscobmacedo committed Jan 21, 2024
1 parent 973bd0e commit 2866468
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 49 deletions.
50 changes: 25 additions & 25 deletions cypress/e2e/test_simulator_to_url_parameters.cy.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
describe("simulator loads", () => {
it("successfully loads the home page", () => {
cy.visit("/");
cy.visit("/#/");
cy.contains("h4", " Remote freelancer from Portugal 🇵🇹");
});
});

describe("pass income to url parameters", () => {
it("successfully uses income from simulator", () => {
cy.visit("/");
cy.visit("/#/");
cy.get('[data-cy="income"]').type("50000");
cy.url().should("include", "?income=50000");
});
it("doesn't update the url if wrong format passed", () => {
cy.visit("/");
cy.visit("/#/");
cy.get('[data-cy="income"]').type("dummyval");
cy.url().should("not.include", "dummyval");
});
it("doesn't update the url if income is 0", () => {
cy.visit("/");
cy.visit("/#/");
cy.get('[data-cy="income"]').type("0");
cy.url().should("not.include", "0");
});
});

describe("pass incomeFrequency to url parameters", () => {
it("successfully uses incomeFrequency from simulator", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="frequency-dropdown"]>input').click();
cy.contains("Day").click();
cy.url().should("include", "incomeFrequency=day");
Expand All @@ -34,36 +34,36 @@ describe("pass incomeFrequency to url parameters", () => {

describe("pass displayFrequency to url parameters", () => {
it("successfully uses displayFrequency from simulator", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="frequency-button"]').contains("Day").click();
cy.url().should("include", "displayFrequency=day");
});
});

describe("pass nrMonthsDisplay to url parameters", () => {
it("successfully uses nrMonthsDisplay from simulator", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="nr-months-display"] input:first-of-type')
.invoke("val", "")
.type("13");
cy.url().should("include", "nrMonthsDisplay=13");
});
it("successfully uses nrMonthsDisplay from simulator when using decrease button", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get(
'[data-cy="nr-months-display"] [data-cy="counter-decrease"]',
).click();
cy.url().should("include", "nrMonthsDisplay=11");
});
it("successfully uses nrMonthsDisplay from simulator when using increase button", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get(
'[data-cy="nr-months-display"] [data-cy="counter-increase"]',
).click();
cy.url().should("include", "nrMonthsDisplay=13");
});
it("doesn't update nrMonthsDisplay if incorrect from simulator", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="nr-months-display"] input:first-of-type')
.invoke("val", "")
.type("-1");
Expand All @@ -73,37 +73,37 @@ describe("pass nrMonthsDisplay to url parameters", () => {

describe("pass ssDiscount to url parameters", () => {
it("successfully uses ssDiscount from simulator when using decrease button", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="ss-discount"] [data-cy="counter-decrease"]').click();
cy.url().should("include", "ssDiscount=-0.05");
});
it("successfully uses ssDiscount from simulator when using increase button", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="ss-discount"] [data-cy="counter-increase"]').click();
cy.url().should("include", "ssDiscount=0.05");
});
});

describe("pass expenses to url parameters", () => {
it("successfully uses expenses from simulator", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="expenses"] input:first-of-type')
.invoke("val", "")
.type("3500");
cy.url().should("include", "expenses=3500");
});
it("successfully uses expenses from simulator when using decrease button", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="expenses"] [data-cy="counter-decrease"]').click();
cy.url().should("include", "expenses=2400");
});
it("successfully uses expenses from simulator when using increase button", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="expenses"] [data-cy="counter-increase"]').click();
cy.url().should("include", "expenses=2600");
});
it("doesn't update expenses if incorrect from simulator", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="expenses"] input:first-of-type')
.invoke("val", "")
.type("adadsads");
Expand All @@ -113,7 +113,7 @@ describe("pass expenses to url parameters", () => {

describe("pass currentTaxRankYear to url parameters", () => {
it("successfully uses currentTaxRankYear from simulator", () => {
cy.visit("/?income=50000");
cy.visit("/#/?income=50000");
cy.get('[data-cy="tax-rank-years-dropdown"]>input').click();
cy.contains("2024").click();
cy.url().should("include", "currentTaxRankYear=2024");
Expand All @@ -122,54 +122,54 @@ describe("pass currentTaxRankYear to url parameters", () => {

describe("pass ssFirstYear to url parameters", () => {
it("successfully uses true ssFirstYear from simulator", () => {
cy.visit("/?income=50000"); // change URL to match your dev URL
cy.visit("/#/?income=50000"); // change URL to match your dev URL
cy.get('[data-cy="ss-first-year"] input:first-of-type').click();
cy.url().should("include", "ssFirstYear=true");
});

it("successfully uses false ssFirstYear from simulator", () => {
cy.visit("/?income=50000"); // change URL to match your dev URL
cy.visit("/#/?income=50000"); // change URL to match your dev URL
cy.get('[data-cy="ss-first-year"] input:first-of-type').click().click();
cy.url().should("include", "ssFirstYear=false");
});
});
describe("pass firstYear to url parameters", () => {
it("successfully uses true firstYear from simulator", () => {
cy.visit("/?income=50000"); // change URL to match your dev URL
cy.visit("/#/?income=50000"); // change URL to match your dev URL
cy.get('[data-cy="first-year"] input:first-of-type').click();
cy.url().should("include", "firstYear=true");
});

it("successfully uses false firstYear from simulator", () => {
cy.visit("/?income=50000"); // change URL to match your dev URL
cy.visit("/#/?income=50000"); // change URL to match your dev URL
cy.get('[data-cy="first-year"] input:first-of-type').click().click();
cy.url().should("include", "firstYear=false");
});
});

describe("pass secondYear to url parameters", () => {
it("successfully uses true secondYear from simulator", () => {
cy.visit("/?income=50000"); // change URL to match your dev URL
cy.visit("/#/?income=50000"); // change URL to match your dev URL
cy.get('[data-cy="second-year"] input:first-of-type').click();
cy.url().should("include", "secondYear=true");
});

it("successfully uses false secondYear from simulator", () => {
cy.visit("/?income=50000"); // change URL to match your dev URL
cy.visit("/#/?income=50000"); // change URL to match your dev URL
cy.get('[data-cy="second-year"] input:first-of-type').click().click();
cy.url().should("include", "secondYear=false");
});
});

describe("pass rnh to url parameters", () => {
it("successfully uses true rnh from simulator", () => {
cy.visit("/?income=50000"); // change URL to match your dev URL
cy.visit("/#/?income=50000"); // change URL to match your dev URL
cy.get('[data-cy="rnh"] input:first-of-type').click();
cy.url().should("include", "rnh=true");
});

it("successfully uses false rnh from simulator", () => {
cy.visit("/?income=50000"); // change URL to match your dev URL
cy.visit("/#/?income=50000"); // change URL to match your dev URL
cy.get('[data-cy="rnh"] input:first-of-type').click().click();
cy.url().should("include", "rnh=false");
});
Expand Down
46 changes: 24 additions & 22 deletions cypress/e2e/test_url_parameters_to_simulator.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ describe("simulator loads", () => {
});

describe("pass income through url parameters", () => {


it("successfully uses income from url", () => {
cy.visit("/?income=50000"); // change URL to match your dev URL
cy.get('[data-cy="income"]').should("have.value", "50 000");
Expand Down Expand Up @@ -37,14 +39,14 @@ describe("pass displayFrequency through url parameters", () => {
cy.visit("/?income=50000&displayFrequency=day"); // change URL to match your dev URL
cy.get('[data-cy="frequency-button"].bg-secondary').should(
"have.text",
"Day",
"Day"
);
});
it("doesn't update displayFrequency if incorrect from url", () => {
cy.visit("/?income=50000&displayFrequency=dummyval"); // change URL to match your dev URL
cy.get('[data-cy="frequency-button"].bg-secondary').should(
"have.text",
"Month",
"Month"
);
});
});
Expand All @@ -54,14 +56,14 @@ describe("pass nrMonthsDisplay through url parameters", () => {
cy.visit("/?income=50000&nrMonthsDisplay=13"); // change URL to match your dev URL
cy.get('[data-cy="nr-months-display"] input:first-of-type').should(
"have.value",
"13",
"13"
);
});
it("doesn't update nrMonthsDisplay if incorrect from url", () => {
cy.visit("/?income=50000&nrMonthsDisplay=-1"); // change URL to match your dev URL
cy.get('[data-cy="nr-months-display"] input:first-of-type').should(
"have.value",
"12",
"12"
);
});
});
Expand All @@ -82,23 +84,23 @@ describe("pass expenses through url parameters", () => {
cy.visit("/?income=50000&expenses=1534"); // change URL to match your dev URL
cy.get('[data-cy="expenses"] input:first-of-type').should(
"have.value",
"1 534",
"1 534"
);
});

it("successfully uses 0 expenses from url", () => {
cy.visit("/?income=50000&expenses=0"); // change URL to match your dev URL
cy.get('[data-cy="expenses"] input:first-of-type').should(
"have.value",
"0",
"0"
);
});

it("doesn't update expenses if incorrect from url", () => {
cy.visit("/?income=50000&expenses=-1534"); // change URL to match your dev URL
cy.get('[data-cy="expenses"] input:first-of-type').should(
"have.value",
"0",
"0"
);
});
});
Expand All @@ -108,23 +110,23 @@ describe("pass currentTaxRankYear through url parameters", () => {
cy.visit("/?income=50000&currentTaxRankYear=2024"); // change URL to match your dev URL
cy.get('[data-cy="tax-rank-years-dropdown"] input:first-of-type').should(
"have.value",
"2024",
"2024"
);
});

it("doesn't update currentTaxRankYear if invalid year from url", () => {
cy.visit("/?income=50000&currentTaxRankYear=2025"); // change URL to match your dev URL
cy.get('[data-cy="tax-rank-years-dropdown"] input:first-of-type').should(
"have.value",
"2023",
"2023"
);
});

it("doesn't update currentTaxRankYear if incorrect type from url", () => {
cy.visit("/?income=50000&currentTaxRankYear=dummyval"); // change URL to match your dev URL
cy.get('[data-cy="tax-rank-years-dropdown"] input:first-of-type').should(
"have.value",
"2023",
"2023"
);
});
});
Expand All @@ -134,31 +136,31 @@ describe("pass ssFirstYear through url parameters", () => {
cy.visit("/?income=50000&ssFirstYear=true"); // change URL to match your dev URL
cy.get('[data-cy="ss-first-year"] input:first-of-type').should(
"have.value",
"true",
"true"
);
});

it("successfully uses false ssFirstYear from url", () => {
cy.visit("/?income=50000&ssFirstYear=false"); // change URL to match your dev URL
cy.get('[data-cy="ss-first-year"] input:first-of-type').should(
"have.value",
"false",
"false"
);
});

it("doesn't update ssFirstYear if string type from url", () => {
cy.visit("/?income=50000&ssFirstYear=yes"); // change URL to match your dev URL
cy.get('[data-cy="ss-first-year"] input:first-of-type').should(
"have.value",
"false",
"false"
);
});

it("doesn't update ssFirstYear if number type from url", () => {
cy.visit("/?income=50000&ssFirstYear=1"); // change URL to match your dev URL
cy.get('[data-cy="ss-first-year"] input:first-of-type').should(
"have.value",
"false",
"false"
);
});
});
Expand All @@ -168,31 +170,31 @@ describe("pass firstYear through url parameters", () => {
cy.visit("/?income=50000&firstYear=true"); // change URL to match your dev URL
cy.get('[data-cy="first-year"] input:first-of-type').should(
"have.value",
"true",
"true"
);
});

it("successfully uses false firstYear from url", () => {
cy.visit("/?income=50000&firstYear=false"); // change URL to match your dev URL
cy.get('[data-cy="first-year"] input:first-of-type').should(
"have.value",
"false",
"false"
);
});

it("doesn't update firstYear if string type from url", () => {
cy.visit("/?income=50000&firstYear=yes"); // change URL to match your dev URL
cy.get('[data-cy="first-year"] input:first-of-type').should(
"have.value",
"false",
"false"
);
});

it("doesn't update firstYear if number type from url", () => {
cy.visit("/?income=50000&firstYear=1"); // change URL to match your dev URL
cy.get('[data-cy="first-year"] input:first-of-type').should(
"have.value",
"false",
"false"
);
});
});
Expand All @@ -202,31 +204,31 @@ describe("pass secondYear through url parameters", () => {
cy.visit("/?income=50000&secondYear=true"); // change URL to match your dev URL
cy.get('[data-cy="second-year"] input:first-of-type').should(
"have.value",
"true",
"true"
);
});

it("successfully uses false secondYear from url", () => {
cy.visit("/?income=50000&secondYear=false"); // change URL to match your dev URL
cy.get('[data-cy="second-year"] input:first-of-type').should(
"have.value",
"false",
"false"
);
});

it("doesn't update secondYear if string type from url", () => {
cy.visit("/?income=50000&secondYear=yes"); // change URL to match your dev URL
cy.get('[data-cy="second-year"] input:first-of-type').should(
"have.value",
"false",
"false"
);
});

it("doesn't update secondYear if number type from url", () => {
cy.visit("/?income=50000&secondYear=1"); // change URL to match your dev URL
cy.get('[data-cy="second-year"] input:first-of-type').should(
"have.value",
"false",
"false"
);
});
});
Expand Down
Loading

0 comments on commit 2866468

Please sign in to comment.