Skip to content

Commit

Permalink
upgrade vite (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rllyyy authored Nov 15, 2024
1 parent da7ad4f commit 0ff3719
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 171 deletions.
20 changes: 17 additions & 3 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import viteConfig from "./vite.config";
import { defineConfig } from "cypress";
import { rmdir, existsSync } from "fs";
import path from "path";

export default defineConfig({
e2e: {
Expand All @@ -17,7 +17,19 @@ export default defineConfig({
framework: "react",
bundler: "vite",
viteConfig: {
...viteConfig,
server: {
host: true,
port: 3000,
},
build: {
outDir: "build", // Changed output folder, like in CRA
},
resolve: {
alias: {
"@components": path.resolve(__dirname, "src/components"),
"@hooks": path.resolve(__dirname, "src/hooks"),
},
},
},
},
setupNodeEvents(on, config) {
Expand All @@ -28,7 +40,9 @@ export default defineConfig({
},
});

function deleteFolder(folderName: string): Promise<string> {
// Fuck cypress and their slow ass adoptation

function deleteFolder(folderName) {
return new Promise((resolve, reject) => {
if (existsSync(folderName)) {
rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.6.0",
"description": "Learn, repeat and memorize tasks with repeatio.",
"author": "Niklas Fischer",
"type": "commonjs",
"private": true,
"dependencies": {
"@dnd-kit/core": "^6.1.0",
Expand Down Expand Up @@ -94,9 +95,9 @@
"postcss": "^8.4.47",
"tailwindcss": "^3.4.14",
"ts-jest": "^29.2.5",
"vite": "^4.5.5",
"vite": "^5.4.11",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-svgr": "^3.2.0",
"vite-tsconfig-paths": "^4.3.2"
"vite-plugin-svgr": "^4.3.0",
"vite-tsconfig-paths": "^5.1.2"
}
}
16 changes: 16 additions & 0 deletions src/components/Home/Home.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const MockModulesWithRouter = () => {
};

describe("Modules (Home) component", () => {
beforeEach(() => {
cy.intercept("GET", "/data.json", { fixture: "../../public/data.json" }).as("getData");
});

it("should render modules from the localStorage", () => {
cy.fixtureToLocalStorage("repeatio-module-cypress_1.json");
cy.fixtureToLocalStorage("repeatio-module-gap_text.json");
Expand Down Expand Up @@ -71,6 +75,10 @@ describe("Modules (Home) component", () => {

/* Module sort */
describe("Module sort", () => {
beforeEach(() => {
cy.intercept("GET", "/data.json", { fixture: "../../public/data.json" }).as("getData");
});

it("should default select the sort by name (ascending)", () => {
cy.mount(<MockModulesWithRouter />);

Expand Down Expand Up @@ -324,6 +332,10 @@ describe("Add Module modal", () => {

/* Module Deletion */
describe("Module deletion", () => {
beforeEach(() => {
cy.intercept("GET", "/data.json", { fixture: "../../public/data.json" }).as("getData");
});

it("should open the module deletion confirm modal when clicking on delete", () => {
cy.mount(<MockModulesWithRouter />);

Expand Down Expand Up @@ -469,6 +481,10 @@ describe("Module deletion", () => {

/* Module edit */
describe("Module Edit", () => {
beforeEach(() => {
cy.intercept("GET", "/data.json", { fixture: "../../public/data.json" }).as("getData");
});

it("should open the <EditModule /> component", () => {
cy.mount(<MockModulesWithRouter />);
cy.get("button.popover-button").click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe("Bookmark a Question", () => {
/* cy.fixtureToLocalStorage("repeatio-marked-types_1.json");
cy.mount(<RenderWithRouter moduleID={"types_1"} questionID={"qID-1"} />); */
cy.viewport(1000, 500);
cy.intercept("GET", "/data.json", { fixture: "../../public/data.json" }).as("getData");
});

it("should create localStorage item if new bookmarked item is the first in module ", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/module/Module.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { MemoryRouter, Route, Routes } from "react-router-dom";
import { IModule, Module } from "./module";
import { CustomToastContainer } from "@components/toast/toast";
import { parseJSON } from "src/utils/parseJSON";
import { parseJSON } from "../../utils/parseJSON";
import { IBookmarkedQuestions } from "@components/Question/components/Actions/BookmarkQuestion";

import "../../index.css";
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts → vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from "vite";
import { defineConfig, UserConfig } from "vite";
import react from "@vitejs/plugin-react";
import viteTsconfigPaths from "vite-tsconfig-paths";
import svgrPlugin from "vite-plugin-svgr";
Expand All @@ -21,4 +21,4 @@ export default defineConfig({
"@hooks": path.resolve(__dirname, "src/hooks"),
},
},
});
} satisfies UserConfig);
Loading

0 comments on commit 0ff3719

Please sign in to comment.