remove unit testing TODO replace

This commit is contained in:
Aayan 2023-08-17 05:40:26 -04:00
parent dc19aa014d
commit a42eeeda90
8 changed files with 71 additions and 313 deletions

View file

@ -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

View file

@ -1,8 +0,0 @@
const { defineConfig } = require("cypress");
module.exports = defineConfig({
e2e: {
baseUrl: "http://localhost:3000",
},
chromeWebSecurity: false
});

View file

@ -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");
});
});

View file

@ -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"
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 863 KiB

View file

@ -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) => { ... })

View file

@ -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')

View file

@ -1,74 +1,71 @@
{ {
"name": "embedder", "name": "embedder",
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"description": "Media host for quick embeds to sites like discord", "description": "Media host for quick embeds to sites like discord",
"keywords": [ "keywords": [
"example", "example",
"express", "express",
"passport", "passport",
"sqlite" "sqlite"
], ],
"author": { "author": {
"name": "Wavering Ana", "name": "Wavering Ana",
"email": "ana@nekomimi.pet", "email": "ana@nekomimi.pet",
"url": "https://l.nekomimi.pet/projects" "url": "https://l.nekomimi.pet/projects"
}, },
"homepage": "https://github.com/WaveringAna/embedder", "homepage": "https://github.com/WaveringAna/embedder",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/WaveringAna/embedder.git" "url": "git://github.com/WaveringAna/embedder.git"
}, },
"license": "Unlicense", "license": "Unlicense",
"scripts": { "scripts": {
"start": "node ./dist/app.js", "start": "node ./dist/app.js",
"clean": "rimraf dist/", "clean": "rimraf dist/",
"copy-files": "copyfiles -a -u 1 app/public/* app/views/* app/public/**/* app/views/**/* dist/", "copy-files": "copyfiles -a -u 1 app/public/* app/views/* app/public/**/* app/views/**/* dist/",
"tsc": "tsc", "tsc": "tsc",
"postinstall": "npm run tsc && npm run copy-files", "postinstall": "npm run tsc && npm run copy-files",
"build": "npm run clean && npm run copy-files && npm run tsc" "build": "npm run clean && npm run copy-files && npm run tsc"
}, },
"dependencies": { "dependencies": {
"@ffmpeg-installer/ffmpeg": "^1.1.0", "@ffmpeg-installer/ffmpeg": "^1.1.0",
"@ffprobe-installer/ffprobe": "^1.4.1", "@ffprobe-installer/ffprobe": "^1.4.1",
"connect-sqlite3": "^0.9.13", "connect-sqlite3": "^0.9.13",
"cookie-parser": "~1.4.4", "cookie-parser": "~1.4.4",
"dotenv": "^8.6.0", "dotenv": "^8.6.0",
"ejs": "^3.1.8", "ejs": "^3.1.8",
"express": "^4.18.2", "express": "^4.18.2",
"express-session": "^1.17.3", "express-session": "^1.17.3",
"fluent-ffmpeg": "^2.1.2", "fluent-ffmpeg": "^2.1.2",
"http-errors": "~1.6.3", "http-errors": "~1.6.3",
"mkdirp": "^1.0.4", "mkdirp": "^1.0.4",
"multer": "^1.4.5-lts.1", "multer": "^1.4.5-lts.1",
"passport": "^0.6.0", "passport": "^0.6.0",
"passport-local": "^1.0.0", "passport-local": "^1.0.0",
"probe-image-size": "^7.2.3", "probe-image-size": "^7.2.3",
"sqlite3": "^5.0.2" "sqlite3": "^5.0.2"
}, },
"devDependencies": { "devDependencies": {
"@types/connect-sqlite3": "^0.9.1", "@types/connect-sqlite3": "^0.9.1",
"@types/cookie-parser": "^1.4.3", "@types/cookie-parser": "^1.4.3",
"@types/dotenv": "^8.2.0", "@types/dotenv": "^8.2.0",
"@types/express": "^4.17.14", "@types/express": "^4.17.14",
"@types/express-session": "^1.17.5", "@types/express-session": "^1.17.5",
"@types/fluent-ffmpeg": "^2.1.20", "@types/fluent-ffmpeg": "^2.1.20",
"@types/mkdirp": "^1.0.2", "@types/mkdirp": "^1.0.2",
"@types/multer": "^1.4.7", "@types/multer": "^1.4.7",
"@types/node": "^18.11.10", "@types/node": "^18.11.10",
"@types/passport": "^1.0.11", "@types/passport": "^1.0.11",
"@types/passport-local": "^1.0.34", "@types/passport-local": "^1.0.34",
"@types/probe-image-size": "^7.2.0", "@types/probe-image-size": "^7.2.0",
"@typescript-eslint/eslint-plugin": "^5.46.1", "@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1", "@typescript-eslint/parser": "^5.46.1",
"copyfiles": "^2.4.1", "copyfiles": "^2.4.1",
"cypress": "^11.1.0", "eslint": "^8.28.0",
"cypress-file-upload": "^5.0.8", "rimraf": "^3.0.2",
"cypress-real-events": "^1.7.4", "ts-node": "^10.9.1",
"eslint": "^8.28.0", "ts-node-dev": "^2.0.0",
"rimraf": "^3.0.2", "typescript": "^4.9.3"
"ts-node": "^10.9.1", }
"ts-node-dev": "^2.0.0", }
"typescript": "^4.9.3"
}
}