remove unit testing TODO replace
This commit is contained in:
parent
dc19aa014d
commit
a42eeeda90
8 changed files with 71 additions and 313 deletions
14
.github/workflows/main.yml
vendored
14
.github/workflows/main.yml
vendored
|
@ -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
|
|
|
@ -1,8 +0,0 @@
|
||||||
const { defineConfig } = require("cypress");
|
|
||||||
|
|
||||||
module.exports = defineConfig({
|
|
||||||
e2e: {
|
|
||||||
baseUrl: "http://localhost:3000",
|
|
||||||
},
|
|
||||||
chromeWebSecurity: false
|
|
||||||
});
|
|
|
@ -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");
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -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 |
|
@ -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) => { ... })
|
|
|
@ -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')
|
|
|
@ -62,9 +62,6 @@
|
||||||
"@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",
|
|
||||||
"cypress-file-upload": "^5.0.8",
|
|
||||||
"cypress-real-events": "^1.7.4",
|
|
||||||
"eslint": "^8.28.0",
|
"eslint": "^8.28.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue