Skip to content

Commit

Permalink
Deploy test (#468)
Browse files Browse the repository at this point in the history
* Chore/460 update npm packages (#461)

* update markdown packages; refactor affected views;
* update babel-plugin-relay package
* latest eslint with new config;
* update eslint plugins; apply new linting;
* update relay packages;
* update typescript
* update testing-libary & jest;
* fix failing hazard page cypress test; improve lat-lon error handling;
* cypress v10 -> 13; cypress test config changes;
* updated husky, jsdom, mathjs
* update remark-gfm, uuid, @types/node packages
* ran `yarn upgrade -L -C` with all packages updated to latest; reverted msw & web-vitals - these need further attention.
* version bump; update changelog;
* comment console.log messages;

* increase precision of hazard curve and UHS csv files (#467)

* increase precision of hazard curve and UHS csv files
* bump version and update changelog

---------

Co-authored-by: Chris B Chamberlain <[email protected]>
  • Loading branch information
chrisdicaprio and chrisbc authored Aug 1, 2024
1 parent a5a3a1d commit 415b8df
Show file tree
Hide file tree
Showing 42 changed files with 2,177 additions and 2,032 deletions.
20 changes: 0 additions & 20 deletions .eslintrc.cjs

This file was deleted.

1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default defineConfig({
},
baseUrl: "http://localhost:5173",
excludeSpecPattern: ["./cypress/e2e/FaultModel.cy.ts"],
testIsolation: false, // our e2e tests are setup assuming no isolation
},
});
4 changes: 2 additions & 2 deletions cypress/e2e/FaultModel.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe.skip("Fault Model all locations", () => {
cy.get("button").contains("Show").click({ force: true });
cy.get('[class="MuiTablePagination-displayedRows css-levciy-MuiTablePagination-displayedRows"]').should(
"contain",
"1–100 of 2099"
"1–100 of 2099",
);
});
});
Expand Down Expand Up @@ -71,7 +71,7 @@ describe("Fault Model wellington", () => {
cy.get("button").contains("Show").click({ force: true });
cy.get('[class="MuiTablePagination-displayedRows css-levciy-MuiTablePagination-displayedRows"]').should(
"contain",
"1–100 of 875"
"1–100 of 875",
);
});
});
47 changes: 38 additions & 9 deletions cypress/e2e/HazardCurves.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
/* eslint-disable cypress/unsafe-to-chain-command */
describe("Hazard Curves", () => {
before(() => {
// NB in cypress config we've set Pre 12 compatability
// https://docs.cypress.io/guides/references/migration-guide#Simulating-Pre-Test-Isolation-Behavior
cy.clearLocalStorage();
cy.clearCookies();
cy.visit("/HazardCurves");
});

// beforeEach(() => {
// cy.clearLocalStorage()
// cy.clearCookies()
// });

it("Hits graphql with hazard curve query", () => {
cy.get("button").contains("Accept").click();
});
Expand All @@ -12,6 +21,23 @@ describe("Hazard Curves", () => {
cy.get('[role="curve"]').should("have.length", 10);
});

it("Displays field error if invalid location coordinates are entered ", () => {
cy.get(
'[class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1x51dt5-MuiInputBase-input-MuiInput-input"]',
)
.first()
.clear()
.type("-40, 181");

cy.get('p[id="lat-lon-component-helper-text"]').should("contain.text", "Invalid lat, lon input");

cy.get(
'[class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1x51dt5-MuiInputBase-input-MuiInput-input"]',
)
.first()
.clear();
});

it("Displays out of range error when POE over 100 or below 0 is selected", () => {
cy.get('input[id="poe-input"]').type("1000");
cy.get('[type="submit"]').click();
Expand Down Expand Up @@ -67,35 +93,38 @@ describe("Hazard Curves", () => {
cy.get("li").contains("Christchurch").click({ force: true });
cy.get("li").contains("Wellington").click({ force: true });
cy.get(
'[class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1x51dt5-MuiInputBase-input-MuiInput-input"]'
'[class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1x51dt5-MuiInputBase-input-MuiInput-input"]',
)
.first()
.type("-42, 173");
.type("-42, 173"); // MSW returns a single curve
cy.get('[type="submit"]').click({ force: true });
cy.get('[role="curve"]').should("have.length", 10);
cy.get('div[class="visx-legend-label"]').should("contain.text", "400m/s PGA -42.0, 173.0");
});

it("Displays error when user inputs invalid latlon value", () => {
it("Displays error on chart if some location data is missing", () => {
cy.get(
'[class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1x51dt5-MuiInputBase-input-MuiInput-input"]'
'[class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1x51dt5-MuiInputBase-input-MuiInput-input"]',
)
.first()
.clear()
.type("-40, 180");
cy.get('[type="submit"]').click({ force: true });
cy.get("div").contains("Location not in data: -40, 180");

// get the plots view message
cy.get('div[role="plotsView"]').get('div[role="alert"]').should("contain.text", "Location not in data: -40, 180");
});

// MSW mocking required after here
it.skip("Displays one curve and error when only one latlon is in data", () => {
cy.get(
'[class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1x51dt5-MuiInputBase-input-MuiInput-input"]'
'[class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd css-1x51dt5-MuiInputBase-input-MuiInput-input"]',
)
.first()
.clear()
.type("-37.78, 175.28; -40, 180");
.type("-37.78, 175.28; -40, 180"); //Hamilton + non-location
cy.get('[type="submit"]').click({ force: true });
cy.get("div").contains("Location not in data: -40, 180");
cy.get('div[role="plotsView"]').get('div[role="alert"]').should("contain.text", "Location not in data: -40, 180");
cy.get('[role="curve"]').should("have.length", 5);
});

Expand All @@ -109,7 +138,7 @@ describe("Hazard Curves", () => {

it.skip("When the save data button is clicked, a CSV file is downloaded", () => {
cy.get(
'button[class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-9z10d6-MuiButtonBase-root-MuiIconButton-root"]'
'button[class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-9z10d6-MuiButtonBase-root-MuiIconButton-root"]',
).click();
cy.get("li").contains("get CSV").click();
cy.readFile("./hazard-curves.csv");
Expand Down
17 changes: 16 additions & 1 deletion cypress/e2e/HomePage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
describe("Home Page", () => {
before(() => {
// NB in cypress config we've set Pre 12 compatability
// https://docs.cypress.io/guides/references/migration-guide#Simulating-Pre-Test-Isolation-Behavior
cy.clearLocalStorage();
cy.clearCookies();
});

it("Visits the Home Page", () => {
cy.visit("/");
});
Expand Down Expand Up @@ -57,11 +64,19 @@ describe("Home Page", () => {
});

describe("NavBarLinks", () => {
beforeEach(() => {
before(() => {
// NB in cypress config we've set Pre 12 compatability
// https://docs.cypress.io/guides/references/migration-guide#Simulating-Pre-Test-Isolation-Behavior
cy.clearLocalStorage();
cy.clearCookies();
cy.visit("/");
cy.get("button").contains("Accept").click();
});

beforeEach(() => {
cy.visit("/");
});

it("Hazard Curves Nav Link works", () => {
cy.get("header").contains("Hazard").click();
cy.get('[role="menuitem"]').contains("Curves and Spectra").click({ force: true });
Expand Down
4 changes: 4 additions & 0 deletions cypress/e2e/LeafletPage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
describe("HazardMapsPage", () => {
before(() => {
// NB in cypress config we've set Pre 12 compatability
// https://docs.cypress.io/guides/references/migration-guide#Simulating-Pre-Test-Isolation-Behavior
cy.clearLocalStorage();
cy.clearCookies();
cy.visit("/HazardMaps");
});

Expand Down
8 changes: 6 additions & 2 deletions cypress/e2e/RuptureAnimation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
describe("ComboRuptureMapPage", () => {
before(() => {
// NB in cypress config we've set Pre 12 compatability
// https://docs.cypress.io/guides/references/migration-guide#Simulating-Pre-Test-Isolation-Behavior
cy.clearLocalStorage();
cy.clearCookies();
cy.visit("/RuptureMap");
});

Expand Down Expand Up @@ -48,14 +52,14 @@ describe("ComboRuptureMapPage", () => {
});

it("Map renders", () => {
cy.get("button").contains("Accept").click({ force: true });
// cy.get("button").contains("Accept").click({ force: true });
cy.get('[id="leaflet-map-container"]').should("exist");
});

it("Displays geojson when selected", () => {
cy.get('[data-testid="ChevronRightIcon"]').click({ force: true });
cy.get(
'[class="MuiSelect-select MuiSelect-standard MuiInputBase-input MuiInput-input css-1rxz5jq-MuiSelect-select-MuiInputBase-input-MuiInput-input"]'
'[class="MuiSelect-select MuiSelect-standard MuiInputBase-input MuiInput-input css-1rxz5jq-MuiSelect-select-MuiInputBase-input-MuiInput-input"]',
)
.first()
.click({ force: true });
Expand Down
53 changes: 53 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { fixupConfigRules } from "@eslint/compat";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: ["**/dist", "build/**"],
},
...fixupConfigRules(
compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
),
),
{
languageOptions: {
globals: {
...globals.browser,
},

parser: tsParser,
},

settings: {
react: {
version: "detect",
},
},

rules: {
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "off",
"no-unused-vars": "off",
},
},
];
Loading

0 comments on commit 415b8df

Please sign in to comment.