diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index cb2faa1..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Cypress Testing - -on: [push] - -jobs: - cypress-run : - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Cypress run - uses: cypress-io/github-action@v4 - with: - start: npm start diff --git a/cypress.config.js b/cypress.config.js deleted file mode 100644 index 8f3b625..0000000 --- a/cypress.config.js +++ /dev/null @@ -1,8 +0,0 @@ -const { defineConfig } = require("cypress"); - -module.exports = defineConfig({ - e2e: { - baseUrl: "http://localhost:3000", - }, - chromeWebSecurity: false -}); diff --git a/cypress/e2e/spec.cy.js b/cypress/e2e/spec.cy.js deleted file mode 100644 index 518639f..0000000 --- a/cypress/e2e/spec.cy.js +++ /dev/null @@ -1,165 +0,0 @@ -describe("The Home Page", () => { - beforeEach(() => { - }); - - it("successfully loads", () => { - cy.visit("/"); - }); - - it("sets auth cookie when logging in via form submission", () => { - const username = "admin"; - const password = "changeme"; - - cy.visit("/login"); - - cy.get("input[name=username]").type(username); - cy.get("input[name=password]").type(`${password}{enter}`); - - cy.url().should("include", "/"); - - cy.getCookie("connect.sid").should("exist"); - - cy.get("li").contains("admin"); - }); - - it("fails to log in with wrong password", () => { - const username = "admin"; - const password = "wrongpassword"; - - cy.visit("/login"); - - cy.get("input[name=username]").type(username); - cy.get("input[name=password]").type(`${password}{enter}`); - - cy.url().should("include", "/login"); - - cy.getCookie("connect.sid").should("not.exist"); - }); - - it("logs out", () => { - const username = "admin"; - const password = "changeme"; - - cy.visit("/login"); - - cy.get("input[name=username]").type(username); - cy.get("input[name=password]").type(`${password}{enter}`); - - cy.url().should("include", "/"); - - cy.getCookie("connect.sid").should("exist"); - - cy.get("li").contains("admin"); - - cy.get("button").contains("Sign out").click(); - - cy.get("a").contains("Sign in"); - }); -}); - -describe("The Upload Page", () => { - beforeEach(() => { - cy.request("POST", "/login/password", { - username: "admin", - password: "changeme" - }); - }); - - it("successfully loads", () => { - cy.visit("/"); - - cy.getCookie("connect.sid").should("exist"); - - cy.get("li").contains("admin"); - }); - - it("successfully uploads a file", () => { - cy.visit("/"); - - cy.getCookie("connect.sid").should("exist"); - - cy.get("li").contains("admin"); - - cy.get("input[type=file]").attachFile("test.png"); - - cy.get("input[type=button][value=Upload]").click(); - - cy.url().should("include", "/"); - - cy.get("img").should("exist"); - }); - - it("successfully deletes a file", () => { - cy.visit("/"); - - cy.getCookie("connect.sid").should("exist"); - - cy.get("li").contains("admin"); - - cy.get("input[type=button][value=Upload]").click(); - - cy.url().should("include", "/"); - - cy.get("img").should("exist"); - - cy.get("img").realHover(); - - cy.get("button[class=destroy]").click(); - - cy.url().should("include", "/"); - - cy.get("img").should("not.exist"); - }); - - it("file successfully expires", () => { - cy.visit("/"); - - cy.getCookie("connect.sid").should("exist"); - - cy.get("li").contains("admin"); - - cy.get("input[type=file]").attachFile("test.png"); - - cy.get("select").select("1 minute"); - - cy.get("input[type=button][value=Upload]").click(); - - cy.url().should("include", "/"); - - cy.get("img").should("exist"); - - cy.wait(120000); //2 minutes - - cy.reload(); - - cy.get("img").should("not.exist"); - }); - - it("ShareX successfully uploads a file", () => { - cy.fixture("test.png", "base64") - .then((file) => Cypress.Blob.base64StringToBlob(file)) - .then((blob) => { - let formdata = new FormData(); - formdata.append("fileupload", blob, "test.png"); - - cy.request({ - url: "/sharex", - method: "POST", - headers: { - "Content-Type": "multipart/form-data", - "key": "pleaseSetAPI_KEY" - }, - body: formdata - }).its('status').should('be.equal', 200); - }); - - cy.visit("/"); - - cy.getCookie("connect.sid").should("exist"); - - cy.get("li").contains("admin"); - - cy.get("img").should("exist"); - - }); -}); \ No newline at end of file diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json deleted file mode 100644 index 02e4254..0000000 --- a/cypress/fixtures/example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io", - "body": "Fixtures are a great way to mock data for responses to routes" -} diff --git a/cypress/fixtures/test.png b/cypress/fixtures/test.png deleted file mode 100644 index 820de16..0000000 Binary files a/cypress/fixtures/test.png and /dev/null differ diff --git a/cypress/support/commands.js b/cypress/support/commands.js deleted file mode 100644 index 66ea16e..0000000 --- a/cypress/support/commands.js +++ /dev/null @@ -1,25 +0,0 @@ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) \ No newline at end of file diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js deleted file mode 100644 index 31b998a..0000000 --- a/cypress/support/e2e.js +++ /dev/null @@ -1,22 +0,0 @@ -// *********************************************************** -// This example support/e2e.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands' -import 'cypress-file-upload' -import 'cypress-real-events' - -// Alternatively you can use CommonJS syntax: -// require('./commands') \ No newline at end of file diff --git a/package.json b/package.json index 5cbfe62..66e6211 100644 --- a/package.json +++ b/package.json @@ -1,74 +1,71 @@ -{ - "name": "embedder", - "version": "0.0.0", - "private": true, - "description": "Media host for quick embeds to sites like discord", - "keywords": [ - "example", - "express", - "passport", - "sqlite" - ], - "author": { - "name": "Wavering Ana", - "email": "ana@nekomimi.pet", - "url": "https://l.nekomimi.pet/projects" - }, - "homepage": "https://github.com/WaveringAna/embedder", - "repository": { - "type": "git", - "url": "git://github.com/WaveringAna/embedder.git" - }, - "license": "Unlicense", - "scripts": { - "start": "node ./dist/app.js", - "clean": "rimraf dist/", - "copy-files": "copyfiles -a -u 1 app/public/* app/views/* app/public/**/* app/views/**/* dist/", - "tsc": "tsc", - "postinstall": "npm run tsc && npm run copy-files", - "build": "npm run clean && npm run copy-files && npm run tsc" - }, - "dependencies": { - "@ffmpeg-installer/ffmpeg": "^1.1.0", - "@ffprobe-installer/ffprobe": "^1.4.1", - "connect-sqlite3": "^0.9.13", - "cookie-parser": "~1.4.4", - "dotenv": "^8.6.0", - "ejs": "^3.1.8", - "express": "^4.18.2", - "express-session": "^1.17.3", - "fluent-ffmpeg": "^2.1.2", - "http-errors": "~1.6.3", - "mkdirp": "^1.0.4", - "multer": "^1.4.5-lts.1", - "passport": "^0.6.0", - "passport-local": "^1.0.0", - "probe-image-size": "^7.2.3", - "sqlite3": "^5.0.2" - }, - "devDependencies": { - "@types/connect-sqlite3": "^0.9.1", - "@types/cookie-parser": "^1.4.3", - "@types/dotenv": "^8.2.0", - "@types/express": "^4.17.14", - "@types/express-session": "^1.17.5", - "@types/fluent-ffmpeg": "^2.1.20", - "@types/mkdirp": "^1.0.2", - "@types/multer": "^1.4.7", - "@types/node": "^18.11.10", - "@types/passport": "^1.0.11", - "@types/passport-local": "^1.0.34", - "@types/probe-image-size": "^7.2.0", - "@typescript-eslint/eslint-plugin": "^5.46.1", - "@typescript-eslint/parser": "^5.46.1", - "copyfiles": "^2.4.1", - "cypress": "^11.1.0", - "cypress-file-upload": "^5.0.8", - "cypress-real-events": "^1.7.4", - "eslint": "^8.28.0", - "rimraf": "^3.0.2", - "ts-node": "^10.9.1", - "ts-node-dev": "^2.0.0", - "typescript": "^4.9.3" - } -} +{ + "name": "embedder", + "version": "0.0.0", + "private": true, + "description": "Media host for quick embeds to sites like discord", + "keywords": [ + "example", + "express", + "passport", + "sqlite" + ], + "author": { + "name": "Wavering Ana", + "email": "ana@nekomimi.pet", + "url": "https://l.nekomimi.pet/projects" + }, + "homepage": "https://github.com/WaveringAna/embedder", + "repository": { + "type": "git", + "url": "git://github.com/WaveringAna/embedder.git" + }, + "license": "Unlicense", + "scripts": { + "start": "node ./dist/app.js", + "clean": "rimraf dist/", + "copy-files": "copyfiles -a -u 1 app/public/* app/views/* app/public/**/* app/views/**/* dist/", + "tsc": "tsc", + "postinstall": "npm run tsc && npm run copy-files", + "build": "npm run clean && npm run copy-files && npm run tsc" + }, + "dependencies": { + "@ffmpeg-installer/ffmpeg": "^1.1.0", + "@ffprobe-installer/ffprobe": "^1.4.1", + "connect-sqlite3": "^0.9.13", + "cookie-parser": "~1.4.4", + "dotenv": "^8.6.0", + "ejs": "^3.1.8", + "express": "^4.18.2", + "express-session": "^1.17.3", + "fluent-ffmpeg": "^2.1.2", + "http-errors": "~1.6.3", + "mkdirp": "^1.0.4", + "multer": "^1.4.5-lts.1", + "passport": "^0.6.0", + "passport-local": "^1.0.0", + "probe-image-size": "^7.2.3", + "sqlite3": "^5.0.2" + }, + "devDependencies": { + "@types/connect-sqlite3": "^0.9.1", + "@types/cookie-parser": "^1.4.3", + "@types/dotenv": "^8.2.0", + "@types/express": "^4.17.14", + "@types/express-session": "^1.17.5", + "@types/fluent-ffmpeg": "^2.1.20", + "@types/mkdirp": "^1.0.2", + "@types/multer": "^1.4.7", + "@types/node": "^18.11.10", + "@types/passport": "^1.0.11", + "@types/passport-local": "^1.0.34", + "@types/probe-image-size": "^7.2.0", + "@typescript-eslint/eslint-plugin": "^5.46.1", + "@typescript-eslint/parser": "^5.46.1", + "copyfiles": "^2.4.1", + "eslint": "^8.28.0", + "rimraf": "^3.0.2", + "ts-node": "^10.9.1", + "ts-node-dev": "^2.0.0", + "typescript": "^4.9.3" + } +}