/ok-to-test tags="@tag.All" ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/10815637874> > Commit: 54937a7a64e755959e3420a0a20abcc30ee10d78 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10815637874&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Wed, 11 Sep 2024 17:30:00 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for visual regression testing through new tagging in various test suites. - Integrated a new image snapshot plugin to enhance testing capabilities. - **Bug Fixes** - Removed outdated image snapshot assertions to streamline testing processes. - **Documentation** - Updated tags in multiple test suites to improve organization and clarity regarding visual testing. - **Chores** - Upgraded Node.js version in the Cypress Dockerfile for improved performance and compatibility. - Simplified Cypress plugin configuration by removing unnecessary functions and enhancing browser compatibility. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Pawan Kumar <pawankumar@Pawans-MacBook-Pro-2.local>
177 lines
5.0 KiB
JavaScript
177 lines
5.0 KiB
JavaScript
// ***********************************************************
|
|
// 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" />
|
|
/// <reference types='cypress-tags' />
|
|
import "cypress-real-events";
|
|
import "cypress-real-events/support";
|
|
import "cypress-wait-until";
|
|
import "cypress-network-idle";
|
|
import "cypress-xpath";
|
|
import * as MESSAGES from "../../src/ce/constants/messages.ts";
|
|
import "./ApiCommands";
|
|
import "./commands";
|
|
import { initLocalstorage, addIndexedDBKey } from "./commands";
|
|
import "./dataSourceCommands";
|
|
import "./gitSync";
|
|
import { initLocalstorageRegistry } from "./Objects/Registry";
|
|
import RapidMode from "./RapidMode.ts";
|
|
import "cypress-mochawesome-reporter/register";
|
|
import installLogsCollector from "cypress-terminal-report/src/installLogsCollector";
|
|
import { CURRENT_REPO, REPO } from "../fixtures/REPO";
|
|
import { addMatchImageSnapshotCommand } from "@simonsmith/cypress-image-snapshot/command";
|
|
|
|
import "./WorkspaceCommands";
|
|
import "./queryCommands";
|
|
import "./widgetCommands";
|
|
import "./themeCommands";
|
|
import "./AdminSettingsCommands";
|
|
import "cypress-plugin-tab";
|
|
import {
|
|
FEATURE_WALKTHROUGH_INDEX_KEY,
|
|
WALKTHROUGH_TEST_PAGE,
|
|
} from "./Constants.js";
|
|
const registerCypressGrep = require("@cypress/grep");
|
|
/// <reference types="cypress-xpath" />
|
|
|
|
registerCypressGrep();
|
|
installLogsCollector();
|
|
|
|
addMatchImageSnapshotCommand({
|
|
comparisonMethod: "ssim",
|
|
failureThreshold: 0.01,
|
|
failureThresholdType: "percent",
|
|
});
|
|
|
|
Cypress.on("uncaught:exception", (error) => {
|
|
return false; // returning false here prevents Cypress from failing the test
|
|
});
|
|
|
|
Cypress.on("fail", (error) => {
|
|
cy.log(error.message);
|
|
throw error; // throw error to have test fail
|
|
});
|
|
|
|
Cypress.env("MESSAGES", MESSAGES);
|
|
|
|
before(function () {
|
|
if (RapidMode.config.enabled) {
|
|
cy.startServerAndRoutes();
|
|
cy.getCookie("SESSION").then((cookie) => {
|
|
if (!cookie) {
|
|
cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
|
|
}
|
|
});
|
|
|
|
if (!RapidMode.config.usesDSL) {
|
|
cy.visit(RapidMode.url());
|
|
cy.wait("@getWorkspace");
|
|
}
|
|
}
|
|
});
|
|
|
|
before(function () {
|
|
if (RapidMode.config.enabled) {
|
|
return;
|
|
}
|
|
initLocalstorage();
|
|
initLocalstorageRegistry();
|
|
cy.startServerAndRoutes();
|
|
// Clear indexedDB
|
|
cy.window().then((window) => {
|
|
window.indexedDB.deleteDatabase("Appsmith");
|
|
});
|
|
cy.visit("/setup/welcome", { timeout: 60000 });
|
|
cy.wait("@getConsolidatedData");
|
|
|
|
cy.wait(2000);
|
|
const username = Cypress.env("USERNAME");
|
|
const password = Cypress.env("PASSWORD");
|
|
cy.url().then((url) => {
|
|
if (url.indexOf("setup/welcome") > -1) {
|
|
cy.createSuperUser();
|
|
cy.SignupFromAPI(
|
|
Cypress.env("TESTUSERNAME1"),
|
|
Cypress.env("TESTPASSWORD1"),
|
|
);
|
|
cy.LogOut();
|
|
cy.SignupFromAPI(
|
|
Cypress.env("TESTUSERNAME2"),
|
|
Cypress.env("TESTPASSWORD2"),
|
|
);
|
|
cy.LogOut();
|
|
cy.SignupFromAPI(
|
|
Cypress.env("TESTUSERNAME3"),
|
|
Cypress.env("TESTPASSWORD3"),
|
|
);
|
|
cy.LogOut();
|
|
cy.SignupFromAPI(
|
|
Cypress.env("TESTUSERNAME4"),
|
|
Cypress.env("TESTPASSWORD4"),
|
|
);
|
|
cy.LogOut();
|
|
cy.LoginFromAPI(username, password);
|
|
} else if (url.indexOf("user/login") > -1) {
|
|
//Cypress.Cookies.preserveOnce("SESSION", "remember_token");
|
|
cy.LoginFromAPI(username, password);
|
|
cy.wait(3000);
|
|
}
|
|
});
|
|
|
|
if (CURRENT_REPO === REPO.EE) {
|
|
cy.wait(2000);
|
|
cy.url().then((url) => {
|
|
if (url.indexOf("/license") > -1) {
|
|
cy.validateLicense();
|
|
}
|
|
});
|
|
}
|
|
|
|
if (!Cypress.currentTest.titlePath[0].includes(WALKTHROUGH_TEST_PAGE)) {
|
|
// Adding key FEATURE_WALKTHROUGH (which is used to check if the walkthrough is already shown to the user or not) for non walkthrough cypress tests (to not show walkthrough)
|
|
addIndexedDBKey(FEATURE_WALKTHROUGH_INDEX_KEY, {
|
|
ab_ds_binding_enabled: true,
|
|
ab_ds_schema_enabled: true,
|
|
binding_widget: true,
|
|
});
|
|
}
|
|
|
|
cy.CreateNewAppInNewWorkspace(); //Creating new workspace and app
|
|
cy.fixture("TestDataSet1").then(function (data) {
|
|
this.dataSet = data;
|
|
});
|
|
});
|
|
|
|
beforeEach(function () {
|
|
if (!navigator.userAgent.includes("Cypress")) {
|
|
window.addEventListener("beforeunload", this.beforeunloadFunction);
|
|
}
|
|
initLocalstorage();
|
|
cy.startServerAndRoutes();
|
|
//-- Delete local storage data of entity explorer
|
|
cy.DeleteEntityStateLocalStorage();
|
|
cy.intercept("api/v1/admin/env", (req) => {
|
|
req.headers["origin"] = Cypress.config("baseUrl");
|
|
});
|
|
});
|
|
|
|
after(function () {
|
|
if (RapidMode.config.enabled) {
|
|
return;
|
|
}
|
|
//-- Deleting the application by Api---//
|
|
cy.DeleteAppByApi();
|
|
cy.DeleteWorkspaceByApi();
|
|
});
|