PromucFlow_constructor/app/client/cypress/support/index.js

103 lines
2.7 KiB
JavaScript
Raw Normal View History

2019-12-12 07:50:53 +00:00
// ***********************************************************
// 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
// ***********************************************************
/// <reference types="Cypress" />
import "cypress-real-events/support";
import "cypress-xpath";
/// <reference types="cypress-xpath" />
2020-05-05 09:08:31 +00:00
let appId;
2020-03-20 14:21:24 +00:00
2019-12-12 07:50:53 +00:00
// Import commands.js using ES2015 syntax:
import "./commands";
2021-07-02 06:04:36 +00:00
import { initLocalstorage } from "./commands";
import * as MESSAGES from "../../../client/src/constants/messages";
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false;
});
Cypress.on("fail", (error, runnable) => {
throw error; // throw error to have test still fail
});
Cypress.env("MESSAGES", MESSAGES);
before(function() {
//console.warn = () => {};
2021-07-02 06:04:36 +00:00
initLocalstorage();
cy.startServerAndRoutes();
// Clear indexedDB
cy.window().then((window) => {
window.indexedDB.deleteDatabase("Appsmith");
});
2021-07-02 06:04:36 +00:00
cy.visit("/setup/welcome");
cy.wait("@getUser");
cy.url().then((url) => {
if (url.indexOf("setup/welcome") > -1) {
cy.createSuperUser();
cy.LogOut();
cy.SignupFromAPI(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
);
cy.LogOut();
cy.SignupFromAPI(
Cypress.env("TESTUSERNAME2"),
Cypress.env("TESTPASSWORD2"),
);
cy.LogOut();
}
});
});
before(function() {
//console.warn = () => {};
Cypress.Cookies.preserveOnce("SESSION", "remember_token");
const username = Cypress.env("USERNAME");
const password = Cypress.env("PASSWORD");
cy.LoginFromAPI(username, password);
cy.visit("/applications");
2021-11-17 15:45:48 +00:00
cy.wait("@getUser");
cy.wait(3000);
cy.get(".t--applications-container .createnew").should("be.visible");
cy.get(".t--applications-container .createnew").should("be.enabled");
cy.generateUUID().then((id) => {
2020-05-05 09:08:31 +00:00
appId = id;
cy.CreateAppInFirstListedOrg(id);
2020-05-20 11:04:39 +00:00
localStorage.setItem("AppName", appId);
2020-05-05 09:08:31 +00:00
});
2020-05-08 09:01:11 +00:00
cy.fixture("example").then(function(data) {
this.data = data;
});
});
2020-05-08 09:01:11 +00:00
beforeEach(function() {
2021-07-02 06:04:36 +00:00
initLocalstorage();
Cypress.Cookies.preserveOnce("SESSION", "remember_token");
cy.startServerAndRoutes();
});
2019-12-12 07:50:53 +00:00
after(function() {
//-- Deleting the application by Api---//
cy.DeleteAppByApi();
2020-05-19 06:13:15 +00:00
//-- LogOut Application---//
cy.LogOut();
});