Skip to content

Commit

Permalink
Fixed Cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LordChunk committed Jan 30, 2024
1 parent f80456e commit c36e617
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "QB Inventory",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:18",
"image": "ghcr.io/lordchunk/devcontainers/typescript:18",
"features": {
"ghcr.io/devcontainers-contrib/features/vue-cli:2": {}
},
Expand Down
2 changes: 2 additions & 0 deletions ui/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { defineConfig } from "cypress";

export default defineConfig({
viewportHeight: 1080,
viewportWidth: 1920,
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
Expand Down
12 changes: 8 additions & 4 deletions ui/cypress/e2e/open.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,23 @@ describe("Open inventory", () => {
});

it.only("should swap items", () => {
const phone = cy.get(".item-container").contains("Phone").parent();
const idCard = cy.get(".item-container").contains("ID Card").parent();
// Find img with "phone" in src and get parent
const phone = cy.get(".item-container").find("img[src*='phone']").parent();
const idCard = cy
.get(".item-container")
.find("img[src*='id_card']")
.parent();

phone.should("be.visible");
idCard.should("be.visible");

cy.intercept("/SetInventoryData", { statusCode: 200, body: {} }).as(
"setInventoryData"
"setInventoryData",
);

phone
.realMouseDown()
.realMouseMove(-150, 200, { position: "center" })
.realMouseMove(-200, 0, { position: "center" })
.wait(300)
.realMouseUp();

Expand Down
7 changes: 6 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
"serve": "vue-cli-service serve --port 3000",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "start-server-and-test serve http://localhost:3000 cypress:run",
"test:e2e:open": "start-server-and-test serve http://localhost:3000 cypress:open",
"lint": "vue-cli-service lint",
"postinstall": "cypress install"
"postinstall": "cypress install",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
"dependencies": {
"@headlessui/vue": "^1.7.17",
Expand Down Expand Up @@ -43,6 +47,7 @@
"prettier": "^3.2.4",
"sass": "^1.70.0",
"sass-loader": "^14.0.0",
"start-server-and-test": "^2.0.3",
"ts-jest": "^27.0.4",
"ts-node": "^10.9.2",
"typescript": "~4.9.5",
Expand Down
Loading

0 comments on commit c36e617

Please sign in to comment.