diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..e8e5a66f7c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM node:14.17.4 + +WORKDIR /opt +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup_install.sh +RUN chmod 755 rustup_install.sh +RUN echo 1 | sh rustup_install.sh -y +ENV PATH="/root/.cargo/bin:$PATH" +RUN cargo install typos-cli +COPY . /work +WORKDIR /work +RUN npm ci +EXPOSE 3000 + +CMD ["/bin/sh"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..d0ab9641c8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +version: '3' +services: + test: + build: . + working_dir: /work + # If you don't have node_modules, use "npm ci", install node_modules into the yor directory. + # Use command bellow + # `docker-compose up -d --build` + # The container will stop automatically after install + # If you have node_modules already, you comment out '# command: "npm ci"' + + # command: "npm ci" + + + # After node_modules install, use command bellow to exec "/bin/sh" and the container will remain. + # `docker-compose up -d` + # To access container, use command bellow + # `docker exec -it voicevox_test_1 /bin/bash` + + # command: "/bin/sh" + + + # If you want test automatically (test runs when you save any files), use this command property and view logs + # Use Command bellow + # `docker logs --tail 1000 -f voicevox_test_1` + + command: "npm run test-watch:unit " + ports: + - 3000:3000 + volumes: + - .:/work:cache + tty: true + stdin_open: true diff --git a/package.json b/package.json index 6d0fb37f43..27c105e981 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "serve": "vue-cli-service serve", "build": "vue-cli-service build", "test:unit": "vue-cli-service test:unit", + "test-watch:unit": "vue-cli-service test:unit --watch", "test:e2e": "vue-cli-service test:e2e", + "test-watch:e2e": "vue-cli-service test:e2e --watch", "lint": "vue-cli-service lint --no-fix", "markdownlint": "markdownlint *.md", "fmt": "vue-cli-service lint", diff --git a/tests/unit/store/Vuex.spec.ts b/tests/unit/store/Vuex.spec.ts new file mode 100644 index 0000000000..a1d759d8cf --- /dev/null +++ b/tests/unit/store/Vuex.spec.ts @@ -0,0 +1,101 @@ +import { createLogger } from "vuex"; +import { indexStore } from "@/store/index"; +import { createStore } from "@/store/vuex"; +import { AllActions, AllGetters, AllMutations, State } from "@/store/type"; +import { commandStore } from "@/store/command"; +import { audioStore, audioCommandStore } from "@/store/audio"; +import { projectStore } from "@/store/project"; +import { uiStore } from "@/store/ui"; +import { settingStore } from "@/store/setting"; +import { assert } from "chai"; +const isDevelopment = process.env.NODE_ENV == "development"; +// TODO: Swap external files to Mock + +describe("store/vuex.js test", () => { + it("creaete store", () => { + const store = createStore({ + state: { + engineState: "STARTING", + audioItems: {}, + audioKeys: [], + audioStates: {}, + uiLockCount: 0, + audioDetailPaneOffset: undefined, + audioInfoPaneOffset: undefined, + nowPlayingContinuously: false, + undoCommands: [], + redoCommands: [], + useUndoRedo: isDevelopment, + useGpu: false, + isHelpDialogOpen: false, + isSettingDialogOpen: false, + isMaximized: false, + savingSetting: { + fileEncoding: "UTF-8", + fixedExportEnabled: false, + fixedExportDir: "", + avoidOverwrite: false, + }, + isPinned: false, + }, + getters: { + ...uiStore.getters, + ...audioStore.getters, + ...commandStore.getters, + ...projectStore.getters, + ...settingStore.getters, + ...audioCommandStore.getters, + ...indexStore.getters, + }, + mutations: { + ...uiStore.mutations, + ...audioStore.mutations, + ...commandStore.mutations, + ...projectStore.mutations, + ...settingStore.mutations, + ...audioCommandStore.mutations, + ...indexStore.mutations, + }, + actions: { + ...uiStore.actions, + ...audioStore.actions, + ...commandStore.actions, + ...projectStore.actions, + ...settingStore.actions, + ...audioCommandStore.actions, + ...indexStore.actions, + }, + plugins: isDevelopment ? [createLogger()] : undefined, + strict: process.env.NODE_ENV !== "production", + }); + assert.exists(store); + assert.isObject(store); + assert.isObject(store.state); + assert.equal(store.state.engineState, "STARTING"); + assert.isObject(store.state.audioItems); + assert.isEmpty(store.state.audioItems); + assert.isArray(store.state.audioKeys); + assert.isEmpty(store.state.audioKeys); + assert.isObject(store.state.audioStates); + assert.isEmpty(store.state.audioStates); + assert.equal(store.state.uiLockCount, 0); + assert.isUndefined(store.state.audioDetailPaneOffset); + assert.isUndefined(store.state.audioInfoPaneOffset); + assert.equal(store.state.nowPlayingContinuously, false); + assert.isArray(store.state.undoCommands); + assert.isEmpty(store.state.undoCommands); + assert.isArray(store.state.redoCommands); + assert.isEmpty(store.state.redoCommands); + assert.equal(store.state.useUndoRedo, false); + assert.equal(store.state.useGpu, false); + assert.equal(store.state.isHelpDialogOpen, false); + assert.equal(store.state.isSettingDialogOpen, false); + assert.equal(store.state.isMaximized, false); + assert.isObject(store.state.savingSetting); + assert.propertyVal(store.state.savingSetting, "fileEncoding", "UTF-8"); + assert.propertyVal(store.state.savingSetting, "fixedExportEnabled", false); + assert.propertyVal(store.state.savingSetting, "fixedExportDir", ""); + assert.propertyVal(store.state.savingSetting, "avoidOverwrite", false); + assert.equal(store.state.isPinned, false); + }); +});