Skip to content

Commit

Permalink
Set Cypress to use Talkback
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorntonMatthewD authored and oliviasculley committed Oct 18, 2023
1 parent 67bdd4f commit 19ca8e5
Show file tree
Hide file tree
Showing 12 changed files with 14,128 additions and 57 deletions.
4 changes: 0 additions & 4 deletions cypress/e2e/about.cy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
describe("About page", () => {
it("displays information after navigating to tab", () => {
cy.intercept("https://data.openupstate.org/rest/maps?_format=json").as(
"mapsList",
);
cy.visit("/");
cy.wait("@mapsList");

cy.contains("About").click();

Expand Down
39 changes: 7 additions & 32 deletions cypress/e2e/map.cy.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,27 @@
describe("Map", () => {
function loadMap(path: string) {
cy.intercept("https://*.tile.openstreetmap.org/**", {
fixture: "images/tile.png",
}).as("tiles");
cy.intercept("https://data.openupstate.org/rest/maps?_format=json", {
fixture: "maps.json",
}).as("mapsList");

cy.visit(path);

cy.wait(["@mapsList", "@tiles"]);

cy.url()
.should("contain", "lat=")
.should("contain", "lng=")
.should("contain", "zoom=");
}

function waitForLayer(func: Function) {
cy.intercept("https://data.openupstate.org/**", {
fixture: "art-galleries.json",
}).as("layer");

func();

cy.wait("@layer");
}

it("adds a map layer and changes URL", () => {
loadMap("/");

waitForLayer(() => {
cy.get("[title='Layers']").trigger("mouseover");
cy.get(".leaflet-control-layers-overlays label input").click();
});
cy.get("[title='Layers']").trigger("mouseover");
cy.get(".leaflet-control-layers-overlays label input").first().click();

cy.url().should("contain", "maps=");
});

it("unchecks a map layer and changes URL", () => {
waitForLayer(() => {
loadMap("/?maps=art-galleries");
cy.get("[title='Layers']").trigger("mouseover");
cy.get(".leaflet-control-layers-overlays label input[checked]").click();
});
loadMap("/?maps=adult-day-care");

cy.get("[title='Layers']").trigger("mouseover");
cy.get(".leaflet-control-layers-overlays label input[checked]").click();

cy.url().should("not.contain", "maps=");
});
Expand Down Expand Up @@ -140,13 +118,10 @@ describe("Map", () => {
cy.contains("Walker Reed")
.should("have.attr", "href")
.and("match", /https:\/\/github.com\/walkreed/);

// User without a provided uri appears as plain text
cy.contains("Shy Guy").should("not.have.attr", "href");
});

it("The Maintainer Control disappears if all layers are unchecked", () => {
loadMap("/?maps=art-galleries");
loadMap("/?maps=adult-day-care");
cy.get("[title='Maintainers']").should("exist");

// Disable the art galleries layer
Expand Down
18 changes: 0 additions & 18 deletions cypress/fixtures/art-galleries.json

This file was deleted.

113 changes: 113 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
"preview": "vite preview",
"test:unit": "vitest --environment jsdom --root src/ --watch=false",
"test:unit:dev": "cross-env-shell OVERWRITE_TAPES=$OVERWRITE_TAPES \"vitest --environment jsdom --root src/\"",
"test:e2e": "start-server-and-test 'vite dev --port 4173 --host 127.0.0.1' http://127.0.0.1:4173 'cypress run'",
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173 --host 127.0.0.1' http://127.0.0.1:4173 'cypress open'",
"cypress:run": "start-server-and-test 'vite dev --port 4173 --host 127.0.0.1 --mode test' http://127.0.0.1:4173 'cypress run'",
"cypress:open": "start-server-and-test 'vite dev --port 4173 --host 127.0.0.1 --mode test' http://127.0.0.1:4173 'cypress open'",
"test:all": "run-p build test:unit test:e2e type-check lint-check",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore; prettier --write . --ignore-path .gitignore --ignore-path .prettierignore",
"lint-check": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix-dry-run --ignore-path .gitignore && prettier --check . --ignore-path .gitignore --ignore-path .prettierignore"
"lint-check": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix-dry-run --ignore-path .gitignore && prettier --check . --ignore-path .gitignore --ignore-path .prettierignore",
"talkback": "DIRECT=enabled tsx src/tests/support/talkback-server.ts",
"test:e2e": "start-server-and-test talkback http://127.0.0.1:9090 cypress:run",
"test:e2e:dev": "start-server-and-test talkback http://127.0.0.1:9090 cypress:open"
},
"dependencies": {
"@types/geojson": "^7946.0.11",
Expand Down Expand Up @@ -50,6 +53,7 @@
"start-server-and-test": "^2.0.1",
"tailwindcss": "^3.3.3",
"talkback": "^3.0.2",
"tsx": "^3.14.0",
"typescript": "~5.2.2",
"vite": "^4.4.11",
"vitest": "^0.34.6",
Expand Down
6 changes: 6 additions & 0 deletions src/tests/support/talkback-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ const create_talkback_server = async () => {
};
};

// Server can be launched independently by calling
// DIRECT=enabled npx tsx talkback-server.ts
if (process.env.DIRECT === "enabled") {
create_talkback_server();
}

export default create_talkback_server;
Loading

0 comments on commit 19ca8e5

Please sign in to comment.