dev: remove Cypress tests

We'll use mocha and ava
This commit is contained in:
naskya 2024-02-12 22:25:55 +09:00
parent fc3aa02142
commit 5ff1afc4f2
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C
10 changed files with 52 additions and 954 deletions

View file

@ -1,12 +0,0 @@
import { defineConfig } from "cypress";
export default defineConfig({
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require("./cypress/plugins/index.js")(on, config);
},
baseUrl: "http://localhost:61812",
},
});

View file

@ -1,151 +0,0 @@
describe("Before setup instance", () => {
beforeEach(() => {
cy.resetState();
});
afterEach(() => {
// テスト終了直前にページ遷移するようなテストケース(例えばアカウント作成)だと、たぶんCypressのバグでブラウザの内容が次のテストケースに引き継がれてしまう(例えばアカウントが作成し終わった段階からテストが始まる)。
// waitを入れることでそれを防止できる
cy.wait(1000);
});
it("successfully loads", () => {
cy.visit("/");
});
it("setup instance", () => {
cy.visit("/");
cy.intercept("POST", "/api/admin/accounts/create").as("signup");
cy.get("[data-cy-admin-username] input").type("admin");
cy.get("[data-cy-admin-password] input").type("admin1234");
cy.get("[data-cy-admin-ok]").click();
// なぜか動かない
//cy.wait('@signup').should('have.property', 'response.statusCode');
cy.wait("@signup");
});
});
describe("After setup instance", () => {
beforeEach(() => {
cy.resetState();
// インスタンス初期セットアップ
cy.registerUser("admin", "pass", true);
});
afterEach(() => {
// テスト終了直前にページ遷移するようなテストケース(例えばアカウント作成)だと、たぶんCypressのバグでブラウザの内容が次のテストケースに引き継がれてしまう(例えばアカウントが作成し終わった段階からテストが始まる)。
// waitを入れることでそれを防止できる
cy.wait(1000);
});
it("successfully loads", () => {
cy.visit("/");
});
it("signup", () => {
cy.visit("/");
cy.intercept("POST", "/api/signup").as("signup");
cy.get("[data-cy-signup]").click();
cy.get("[data-cy-signup-username] input").type("alice");
cy.get("[data-cy-signup-password] input").type("alice1234");
cy.get("[data-cy-signup-password-retype] input").type("alice1234");
cy.get("[data-cy-signup-submit]").click();
cy.wait("@signup");
});
});
describe("After user signup", () => {
beforeEach(() => {
cy.resetState();
// インスタンス初期セットアップ
cy.registerUser("admin", "pass", true);
// ユーザー作成
cy.registerUser("alice", "alice1234");
});
afterEach(() => {
// テスト終了直前にページ遷移するようなテストケース(例えばアカウント作成)だと、たぶんCypressのバグでブラウザの内容が次のテストケースに引き継がれてしまう(例えばアカウントが作成し終わった段階からテストが始まる)。
// waitを入れることでそれを防止できる
cy.wait(1000);
});
it("successfully loads", () => {
cy.visit("/");
});
it("signin", () => {
cy.visit("/");
cy.intercept("POST", "/api/signin").as("signin");
cy.get("[data-cy-signin]").click();
cy.get("[data-cy-signin-username] input").type("alice");
// Enterキーでサインインできるかの確認も兼ねる
cy.get("[data-cy-signin-password] input").type("alice1234{enter}");
cy.wait("@signin");
});
it("suspend", function () {
cy.request("POST", "/api/admin/suspend-user", {
i: this.admin.token,
userId: this.alice.id,
});
cy.visit("/");
cy.get("[data-cy-signin]").click();
cy.get("[data-cy-signin-username] input").type("alice");
cy.get("[data-cy-signin-password] input").type("alice1234{enter}");
// TODO: cypressにブラウザの言語指定できる機能が実装され次第英語のみテストするようにする
cy.contains(
/アカウントが凍結されています|This account has been suspended due to/gi,
);
});
});
describe("After user singed in", () => {
beforeEach(() => {
cy.resetState();
// インスタンス初期セットアップ
cy.registerUser("admin", "pass", true);
// ユーザー作成
cy.registerUser("alice", "alice1234");
cy.login("alice", "alice1234");
});
afterEach(() => {
// テスト終了直前にページ遷移するようなテストケース(例えばアカウント作成)だと、たぶんCypressのバグでブラウザの内容が次のテストケースに引き継がれてしまう(例えばアカウントが作成し終わった段階からテストが始まる)。
// waitを入れることでそれを防止できる
cy.wait(1000);
});
it("successfully loads", () => {
cy.get("[data-cy-open-post-form]").should("be.visible");
});
it("note", () => {
cy.get("[data-cy-open-post-form]").click();
cy.get("[data-cy-post-form-text]").type("Hello, Firefish!");
cy.get("[data-cy-open-post-form-submit]").click();
cy.contains("Hello, Firefish!");
});
});
// TODO: 投稿フォームの公開範囲指定のテスト
// TODO: 投稿フォームのファイル添付のテスト
// TODO: 投稿フォームのハッシュタグ保持フィールドのテスト

View file

@ -1,63 +0,0 @@
describe("After user signed in", () => {
beforeEach(() => {
cy.resetState();
cy.viewport("macbook-16");
// インスタンス初期セットアップ
cy.registerUser("admin", "pass", true);
// ユーザー作成
cy.registerUser("alice", "alice1234");
cy.login("alice", "alice1234");
});
afterEach(() => {
// テスト終了直前にページ遷移するようなテストケース(例えばアカウント作成)だと、たぶんCypressのバグでブラウザの内容が次のテストケースに引き継がれてしまう(例えばアカウントが作成し終わった段階からテストが始まる)。
// waitを入れることでそれを防止できる
cy.wait(1000);
});
it("widget edit toggle is visible", () => {
cy.get(".mk-widget-edit").should("be.visible");
});
it("widget select should be visible in edit mode", () => {
cy.get(".mk-widget-edit").click();
cy.get(".mk-widget-select").should("be.visible");
});
it("first widget should be removed", () => {
cy.get(".mk-widget-edit").click();
cy.get(".customize-container:first-child .remove._button").click();
cy.get(".customize-container").should("have.length", 2);
});
function buildWidgetTest(widgetName) {
it(`${widgetName} widget should get added`, () => {
cy.get(".mk-widget-edit").click();
cy.get(".mk-widget-select select").select(widgetName, { force: true });
cy.get(".bg._modalBg.transparent").click({ multiple: true, force: true });
cy.get(".mk-widget-add").click({ force: true });
cy.get(`.mkw-${widgetName}`).should("exist");
});
}
buildWidgetTest("memo");
buildWidgetTest("notifications");
buildWidgetTest("timeline");
buildWidgetTest("calendar");
buildWidgetTest("rss");
buildWidgetTest("trends");
buildWidgetTest("clock");
buildWidgetTest("activity");
buildWidgetTest("photos");
buildWidgetTest("digitalClock");
buildWidgetTest("federation");
buildWidgetTest("postForm");
buildWidgetTest("slideshow");
buildWidgetTest("serverMetric");
buildWidgetTest("onlineUsers");
buildWidgetTest("jobQueue");
buildWidgetTest("button");
buildWidgetTest("aiscript");
});

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

View file

@ -1,21 +0,0 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
/**
* @type {Cypress.PluginConfig}
*/
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};

View file

@ -1,57 +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) => { ... })
Cypress.Commands.add("resetState", () => {
cy.window((win) => {
win.indexedDB.deleteDatabase("keyval-store");
});
cy.request("POST", "/api/reset-db").as("reset");
cy.get("@reset").its("status").should("equal", 204);
cy.reload(true);
});
Cypress.Commands.add("registerUser", (username, password, isAdmin = false) => {
const route = isAdmin ? "/api/admin/accounts/create" : "/api/signup";
cy.request("POST", route, {
username: username,
password: password,
})
.its("body")
.as(username);
});
Cypress.Commands.add("login", (username, password) => {
cy.visit("/");
cy.intercept("POST", "/api/signin").as("signin");
cy.get("[data-cy-signin]").click();
cy.get("[data-cy-signin-username] input").type(username);
cy.get("[data-cy-signin-password] input").type(`${password}{enter}`);
cy.wait("@signin").as("signedIn");
});

View file

@ -1,34 +0,0 @@
// ***********************************************************
// This example support/index.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";
// Alternatively you can use CommonJS syntax:
// require('./commands')
Cypress.on("uncaught:exception", (err, runnable) => {
if (
[
// Chrome
"ResizeObserver loop limit exceeded",
// Firefox
"ResizeObserver loop completed with undelivered notifications",
].some((msg) => err.message.includes(msg))
) {
return false;
}
});

View file

@ -26,9 +26,6 @@
"lint": "pnpm -r --parallel run lint",
"debug": "pnpm run clean && pnpm run build:debug && pnpm run start",
"build:debug": "pnpm -r --parallel run build:debug && pnpm run gulp",
"cy:open": "cypress open --browser --e2e --config-file=cypress.config.ts",
"cy:run": "cypress run",
"e2e": "start-server-and-test start:test http://localhost:61812 cy:run",
"mocha": "pnpm --filter backend run mocha",
"test": "pnpm run mocha",
"format": "pnpm -r --parallel run format",
@ -59,7 +56,6 @@
"@types/node": "20.11.17",
"add": "2.0.6",
"cross-env": "7.0.3",
"cypress": "13.6.4",
"execa": "8.0.1",
"gulp": "4.0.2",
"gulp-cssnano": "2.1.3",
@ -68,7 +64,6 @@
"gulp-terser": "2.1.0",
"install-peers": "^1.0.4",
"pnpm": "8.15.1",
"start-server-and-test": "2.0.3",
"typescript": "5.3.3"
}
}

View file

@ -64,6 +64,7 @@
"feed": "4.2.2",
"file-type": "19.0.0",
"fluent-ffmpeg": "2.1.2",
"form-data": "^4.0.0",
"got": "14.2.0",
"gunzip-maybe": "^1.4.2",
"happy-dom": "^13.3.8",

File diff suppressed because it is too large Load diff