chore: add e2e test with cypress
This commit is contained in:
parent
f2a3998cc8
commit
3dc8725853
|
@ -0,0 +1 @@
|
|||
node_modules
|
|
@ -0,0 +1,10 @@
|
|||
const { defineConfig } = require("cypress");
|
||||
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
},
|
||||
},
|
||||
video: false,
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
export const PUBLIC_URL = "http://localhost:8080";
|
|
@ -0,0 +1,23 @@
|
|||
import { PUBLIC_URL } from "../constants";
|
||||
|
||||
describe("login", () => {
|
||||
it("works", () => {
|
||||
cy.login();
|
||||
|
||||
cy.url().should("include", "/showbuilder#tracks");
|
||||
|
||||
cy.get('a[href="/login/logout"]').click();
|
||||
cy.url().should("include", "/");
|
||||
});
|
||||
|
||||
it("fails with bad credentials", () => {
|
||||
cy.visit(PUBLIC_URL + "/login");
|
||||
cy.get('input[name="username"]').type("admin");
|
||||
cy.get('input[name="password"]').type("bad password");
|
||||
cy.get('input[name="submit"]').click();
|
||||
|
||||
cy.contains("Wrong username or password provided. Please try again.");
|
||||
|
||||
cy.url().should("include", "/login");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
describe("settings", () => {
|
||||
it("list users", () => {
|
||||
cy.login();
|
||||
cy.contains("Settings").click();
|
||||
cy.get("#sub-menu").children().contains("Users").click();
|
||||
|
||||
cy.contains("Manage Users");
|
||||
cy.contains("admin");
|
||||
});
|
||||
|
||||
it("working streaming status", () => {
|
||||
cy.login();
|
||||
cy.contains("Settings").click();
|
||||
cy.get("#sub-menu").children().contains("Streams").click();
|
||||
|
||||
cy.contains("Connected to the streaming server");
|
||||
});
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
import dayjs from "dayjs";
|
||||
|
||||
describe("shows", () => {
|
||||
it("add a show", () => {
|
||||
const now = dayjs(Date()).add(1, "day");
|
||||
cy.clock(now.toDate());
|
||||
|
||||
cy.login();
|
||||
cy.contains("Calendar").click();
|
||||
cy.url().should("include", "/schedule");
|
||||
|
||||
cy.get("button.add-button").click();
|
||||
cy.get("input#add_show_name").clear().type("My show name");
|
||||
cy.get("input#add_show_start_now-future").click();
|
||||
cy.get("input#add_show_start_date").clear().type(now.format("YYYY-MM-DD"));
|
||||
|
||||
cy.contains("Add this show").click();
|
||||
cy.contains("My show name").click();
|
||||
cy.contains("Delete").click();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
describe("upload", () => {
|
||||
it("upload a file", () => {
|
||||
cy.login();
|
||||
cy.contains("Upload").click();
|
||||
cy.url().should("include", "/plupload");
|
||||
cy.contains("Drop files here or click to browse your computer.").selectFile(
|
||||
"cypress/fixtures/sample.ogg",
|
||||
{ action: "drag-drop" }
|
||||
);
|
||||
|
||||
cy.contains("Recent Uploads");
|
||||
cy.contains("Pending import");
|
||||
cy.contains("Successfully imported");
|
||||
|
||||
cy.contains("Tracks").click();
|
||||
cy.contains("Test Title").click();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
describe("webstreams", () => {
|
||||
it("add a webstream", () => {
|
||||
cy.login();
|
||||
cy.contains("Webstreams").click();
|
||||
cy.get('button[id="sb-new"]').click();
|
||||
|
||||
cy.get('input[class="playlist_name_display"]').clear().type("Test Name");
|
||||
cy.get('dd[id="description-element"] > textarea').type("Test Description");
|
||||
|
||||
cy.get('dd[id="streamurl-element"] > input')
|
||||
.clear()
|
||||
.type("http://localhost:8000/main");
|
||||
|
||||
cy.get('button[id="webstream_save"]').click();
|
||||
});
|
||||
});
|
Binary file not shown.
|
@ -0,0 +1,23 @@
|
|||
// ***********************************************
|
||||
// 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
|
||||
// ***********************************************
|
||||
import { PUBLIC_URL } from "../constants";
|
||||
|
||||
Cypress.Commands.add("login", (userType, options = {}) => {
|
||||
cy.on("uncaught:exception", (err, runnable) => {
|
||||
if (err.message.includes("dt is undefined")) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
cy.visit(PUBLIC_URL + "/login");
|
||||
cy.get('input[name="username"]').type("admin");
|
||||
cy.get('input[name="password"]').type("admin");
|
||||
cy.get('select[name="locale"]').select("en_US");
|
||||
cy.get('input[name="submit"]').click();
|
||||
});
|
|
@ -0,0 +1,16 @@
|
|||
// ***********************************************************
|
||||
// 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";
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "libretime-e2e",
|
||||
"version": "1.0.0",
|
||||
"license": "GPLv3",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "cypress open",
|
||||
"test:chrome": "cypress run --browser chromium",
|
||||
"test:firefox": "cypress run --browser firefox"
|
||||
},
|
||||
"dependencies": {
|
||||
"cypress": "^12.10.0",
|
||||
"dayjs": "^1.11.7"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue