1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-22 07:52:43 +00:00

Remove cypress

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-11-25 16:46:21 +01:00
parent 477e8a5778
commit bfe833af7f
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
12 changed files with 0 additions and 544 deletions

View file

@ -29,7 +29,6 @@ module.exports = {
},
],
"@typescript-eslint/no-explicit-any": "off",
"cypress/no-unnecessary-waiting": "off",
"vue/max-len": [
"off",
{

View file

@ -1,8 +0,0 @@
module.exports = {
env: {
jest: true,
"cypress/globals": true,
},
extends: ["plugin:cypress/recommended"],
plugins: ["cypress"],
};

View file

@ -1,13 +0,0 @@
export default class ElementCount {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
constructor(selector, count) {
this.message = `Testing if element <${selector}> has count: ${count}`;
this.expected = count;
this.pass = (val) => val === count;
this.value = (res) => res.value;
function evaluator(_selector) {
return document.querySelectorAll(_selector).length;
}
this.command = (cb) => this.api.execute(evaluator, [selector], cb);
}
}

View file

@ -1,23 +0,0 @@
// https://docs.cypress.io/guides/guides/plugins-guide.html
// if you need a custom webpack configuration
// you can uncomment the following import
// and then use the `file:preprocessor` event
// as explained in the cypress docs
// https://docs.cypress.io/api/plugins/preprocessors-api.html#Examples
module.exports = (on, config) => {
// on('file:preprocessor', webpack({
// webpackOptions: require('@vue/cli-service/webpack.config'),
// watchOptions: {}
// }))
return {
...config,
fixturesFolder: "tests/e2e/fixtures",
integrationFolder: "tests/e2e/specs",
screenshotsFolder: "tests/e2e/screenshots",
videosFolder: "tests/e2e/videos",
supportFile: "tests/e2e/support/index.js",
};
};

View file

@ -1,5 +0,0 @@
// Set the en-US language just in case
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default function (window) {
Object.defineProperty(window.navigator, "language", { value: "en-US" });
}

View file

@ -1,37 +0,0 @@
// https://docs.cypress.io/api/introduction/api.html
import onBeforeLoad from "./browser-language";
describe("Homepage", () => {
it("Checks the footer", () => {
cy.visit("/", { onBeforeLoad });
cy.get("#mobilizon").find("footer").contains("The Mobilizon Contributors");
cy.contains("About")
.should("have.attr", "href")
.and("eq", "https://joinmobilizon.org");
cy.contains("License")
.should("have.attr", "href")
.and("eq", "https://framagit.org/framasoft/mobilizon/blob/main/LICENSE");
});
it("Tries to register from the hero section", () => {
cy.visit("/", { onBeforeLoad });
cy.get(".hero-body").contains("Sign up").click();
cy.url().should("include", "/register/user");
});
it("Tries to register from the navbar", () => {
cy.visit("/", { onBeforeLoad });
cy.get("nav.navbar").contains("Sign up").click();
cy.url().should("include", "/register/user");
});
it("Tries to connect from the navbar", () => {
cy.visit("/", { onBeforeLoad });
cy.get("nav.navbar").contains("Log in").click();
cy.url().should("include", "/login");
});
});

View file

@ -1,54 +0,0 @@
beforeEach(() => {
cy.clearLocalStorage();
});
describe("Events", () => {
it("Shows my current events", () => {
const EVENT = { title: "My first event" };
cy.loginUser();
cy.visit("/events/me");
cy.contains(".message.is-danger", "No events found");
cy.contains(".navbar-item", "Create").click();
cy.url().should("include", "create");
cy.get(".field").first().find("input").type(EVENT.title);
cy.get(".field").eq(1).find("input").type("my tag, holo{enter}");
cy.get(".field").eq(2).find(".datepicker .dropdown-trigger").click();
cy.get(".field")
.eq(3)
.find(".pagination-list .control")
.first()
.find(".select select")
.select("September");
cy.get(".field")
.eq(3)
.find(".pagination-list .control")
.last()
.find(".select select")
.select("2021");
cy.get(".field").eq(3).contains(".datepicker-cell", "15").click();
cy.contains(".button.is-primary", "Create my event").click();
cy.url().should("include", "/events/");
cy.contains(".title", EVENT.title);
cy.contains(".column.is-3-tablet", "One person going");
cy.get(".eventMetadataBlock")
.eq(1)
.contains("On Wednesday, September 15, 2021 from");
cy.contains(".column.is-3-tablet", "Public event");
cy.contains(".navbar-item", "My events").click();
cy.contains(".title", EVENT.title);
cy.contains(".content.column", "Organized by I'm a test user");
cy.contains(
".title-wrapper .date-component .datetime-container .month",
"Sep"
);
cy.contains(
".title-wrapper .date-component .datetime-container .day",
"15"
);
});
});

View file

@ -1,124 +0,0 @@
import onBeforeLoad from "./browser-language";
beforeEach(() => {
cy.clearLocalStorage();
});
describe("Login", () => {
it("Tests that everything is present", () => {
cy.visit("/login", { onBeforeLoad });
cy.get("form .field").first().contains("label", "Email");
cy.get("form .field").last().contains("label", "Password");
cy.get("form").contains("button.button", "Login");
cy.get("form")
.contains(".control a.button", "Forgot your password ?")
.click();
cy.url().should("include", "/password-reset/send");
cy.go("back");
cy.get("form").contains(".control a.button", "Register").click();
cy.url().should("include", "/register/user");
cy.go("back");
});
it("Tries to login with incorrect credentials", () => {
cy.visit("/login", { onBeforeLoad });
cy.get("input[type=email]")
.type("notanemail")
.should("have.value", "notanemail");
cy.get("input[type=password]").click();
cy.contains("button.button.is-primary.is-large", "Login").click();
// cy.get('form .field').first().contains('p.help.is-danger', '@');
});
it("Tries to login with invalid credentials", () => {
cy.visit("/login", { onBeforeLoad });
cy.get("input[type=email]")
.type("test@email.com")
.should("have.value", "test@email.com");
cy.get("input[type=password]")
.type("badPassword")
.should("have.value", "badPassword");
cy.contains("button.button.is-primary.is-large", "Login").click();
cy.contains(
".message.is-danger",
"No user account with this email was found. Maybe you made a typo?"
);
});
it("Tries to login with valid credentials", () => {
cy.visit("/login", { onBeforeLoad });
cy.get("input[type=email]").type("user@email.com");
cy.get("input[type=password]").type("some password");
cy.get("form").submit();
cy.get(".navbar-end .navbar-link span.icon i").should(
"have.class",
"mdi-account-circle"
);
cy.contains("article.message.is-info", "Welcome back I'm a test user");
cy.get(".navbar-item.has-dropdown").click();
cy.get(".navbar-item").last().contains("Log out").click();
});
it("Tries to login with valid credentials but unconfirmed account", () => {
cy.visit("/login", { onBeforeLoad });
cy.get("input[type=email]").type("unconfirmed@email.com");
cy.get("input[type=password]").type("some password");
cy.get("form").submit();
cy.contains(
".message.is-danger",
"The user account you're trying to login as has not been confirmed yet. Check your email inbox and eventually your spam folder.You may also ask to resend confirmation email."
);
});
it("Tries to login with valid credentials, confirmed account but no profile", () => {
cy.visit("/login", { onBeforeLoad });
cy.get("input[type=email]").type("confirmed@email.com");
cy.get("input[type=password]").type("some password");
cy.get("form").submit();
cy.contains(
".message",
"To achieve your registration, please create a first identity profile."
);
cy.get("form > .field")
.eq(1)
.contains("label", "Username")
.parent()
.find("input")
.type("test_user");
cy.get("form > .field")
.first()
.contains("label", "Display name")
.parent()
.find("input")
.type("Duplicate");
cy.get("form > .field")
.eq(2)
.contains("label", "Description")
.parent()
.find("textarea")
.type("This shouln't work because it' using a dupublicated username");
cy.get(".control.has-text-centered")
.contains("button", "Create my profile")
.click();
cy.contains(".help.is-danger", "This username is already taken.");
cy.get("form .field input").first(0).clear().type("test_user_2");
cy.get("form .field input").eq(1).type("Not");
cy.get("form .field textarea").clear().type("This will now work");
cy.get("form").submit();
cy.get(".navbar-link span.icon i").should(
"have.class",
"mdi-account-circle"
);
cy.contains(
"article.message.is-info",
"Welcome to Mobilizon, test_user_2!"
);
});
});

View file

@ -1,92 +0,0 @@
import onBeforeLoad from "./browser-language";
describe("Registration", () => {
it("Tests that everything is present", () => {
cy.visit("/register/user", { onBeforeLoad });
cy.get("form .field").first().contains("label", "Email");
cy.get("form .field").eq(1).contains("label", "Password");
cy.get("input[type=email]").click();
cy.get("input[type=password]").type("short").should("have.value", "short");
cy.get("form").contains("button.button.is-primary", "Register");
cy.get("form")
.contains(".control a.button", "Didn't receive the instructions ?")
.click();
cy.url().should("include", "/resend-instructions");
cy.go("back");
cy.get("form")
.get(".control a.button")
.contains("Login")
.click({ force: true });
cy.url().should("include", "/login");
cy.go("back");
});
it("Tests that registration works", () => {
cy.visit("/register/user", { onBeforeLoad });
cy.get("input[type=email]").type("user2register@email.com");
cy.get("input[type=password]").type("userPassword");
cy.get("form").contains("button.button.is-primary", "Register").click();
cy.url().should("include", "/register/profile");
cy.get("form > .field")
.eq(1)
.contains("label", "Username")
.parent()
.find("input")
.type("tester");
cy.get("form > .field")
.first()
.contains("label", "Display name")
.parent()
.find("input")
.type("tester account");
cy.get("form > .field")
.eq(2)
.contains("label", "Description")
.parent()
.find("textarea")
.type("This is a test account");
cy.get(".control.has-text-centered")
.contains("button", "Create my profile")
.click();
cy.contains(
"article.message.is-success",
"Your account is nearly ready, tester"
).contains("A validation email was sent to user2register@email.com");
cy.visit("/sent_emails");
cy.get("iframe")
.first()
.iframeLoaded()
.its("document")
.getInDocument("a")
.eq(1)
.contains("Activate my account")
.invoke("attr", "href")
.then((href) => {
cy.visit(href);
});
// cy.url().should('include', '/validate/');
// cy.contains('Your account is being validated');
cy.location().should((loc) => {
expect(loc.pathname).to.eq("/");
});
cy.get(".navbar-link span.icon i").should(
"have.class",
"mdi-account-circle"
);
cy.contains(
"article.message.is-info",
"Welcome to Mobilizon, tester account!"
);
});
});

View file

@ -1,159 +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 is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
const AUTH_ACCESS_TOKEN = "auth-access-token";
const AUTH_REFRESH_TOKEN = "auth-refresh-token";
const AUTH_USER_ID = "auth-user-id";
const AUTH_USER_EMAIL = "auth-user-email";
const AUTH_USER_ACTOR_ID = "auth-user-actor-id";
const AUTH_USER_ROLE = "auth-user-role";
const LOCAL_STORAGE_MEMORY = {};
Cypress.Commands.add("saveLocalStorage", () => {
Object.keys(localStorage).forEach((key) => {
LOCAL_STORAGE_MEMORY[key] = localStorage[key];
});
});
Cypress.Commands.add("restoreLocalStorage", () => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
});
Cypress.Commands.add("clearLocalStorage", () => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
localStorage.removeItem(key);
});
});
Cypress.Commands.add("loginUser", () => {
console.log("Going to login an user");
const loginMutation = `
mutation Login($email: String!, $password: String!) {
login(email: $email, password: $password) {
accessToken,
refreshToken,
user {
id,
email,
role
}
},
}`;
const body = JSON.stringify({
operationName: "Login",
query: loginMutation,
variables: { email: "user@email.com", password: "some password" },
});
cy.request({
url: "http://localhost:4000/api",
body,
method: "POST",
headers: {
"Content-Type": "application/json",
},
}).then((res) => {
console.log("Reply from server when logging-in", res);
const obj = res.body.data.login;
console.log("Login data: ", obj);
localStorage.setItem(AUTH_USER_ID, `${obj.user.id}`);
localStorage.setItem(AUTH_USER_EMAIL, obj.user.email);
localStorage.setItem(AUTH_USER_ROLE, obj.user.role);
localStorage.setItem(AUTH_USER_ACTOR_ID, `${obj.id}`);
localStorage.setItem(AUTH_ACCESS_TOKEN, obj.accessToken);
localStorage.setItem(AUTH_REFRESH_TOKEN, obj.refreshToken);
});
});
// const increaseFetches = () => {
// const count = Cypress.env('fetchCount') || 0;
// Cypress.env('fetchCount', count + 1);
// };
const decreaseFetches = () => {
const count = Cypress.env("fetchCount") || 0;
Cypress.env("fetchCount", count - 1);
};
const buildTrackableFetchWithSessionId =
(fetch) => (fetchUrl, fetchOptions) => {
const { headers } = fetchOptions;
const modifiedHeaders = {
"x-session-id": Cypress.env("sessionId"),
...headers,
};
const modifiedOptions = { ...fetchOptions, headers: modifiedHeaders };
return fetch(fetchUrl, modifiedOptions)
.then((result) => {
decreaseFetches();
return Promise.resolve(result);
})
.catch((result) => {
decreaseFetches();
return Promise.reject(result);
});
};
Cypress.on("window:before:load", (win) => {
cy.stub(win, "fetch", buildTrackableFetchWithSessionId(fetch));
});
Cypress.Commands.add("waitForFetches", () => {
if (Cypress.env("fetchCount") <= 0) {
return;
}
cy.waitForFetches();
});
Cypress.Commands.add("iframeLoaded", { prevSubject: "element" }, ($iframe) => {
const contentWindow = $iframe.prop("contentWindow");
return new Promise((resolve) => {
if (contentWindow && contentWindow.document.readyState === "complete") {
resolve(contentWindow);
} else {
$iframe.on("load", () => {
resolve(contentWindow);
});
}
});
});
Cypress.Commands.add(
"getInDocument",
{ prevSubject: "document" },
(document, selector) => Cypress.$(selector, document)
);

View file

@ -1,20 +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')

View file

@ -1,8 +0,0 @@
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "../node_modules",
"types": ["cypress"]
},
"include": ["**/*.*"]
}