Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Cypress - added @tag.excludeForAirgap, @tag.Templates tags #29790

Merged
merged 14 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions app/client/cypress/addtags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
const fs = require("fs");
const path = require("path");

// Replace tag names with the actual tag values
const tag = {
excludeForAirgap: "tag.excludeForAirgap",
airgap: "tag.airgap",
Git: "tag.Git",
Widget: "tag.Widget",
Multiselect: "tag.Multiselect",
Slider: "tag.Slider",
CurrencyInput: "tag.CurrencyInput",
Text: "tag.Text",
Statbox: "tag.Statbox",
Modal: "tag.Modal",
Filepicker: "tag.Filepicker",
Select: "tag.Select",
RichTextEditor: "tag.RichTextEditor",
Switch: "tag.Switch",
List: "tag.List",
Button: "tag.Button",
Divider: "tag.Divider",
Audio: "tag.Audio",
Table: "tag.Table",
Image: "tag.Image",
Tab: "tag.Tab",
JSONForm: "tag.JSONForm",
Binding: "tag.Binding",
IDE: "tag.IDE",
Datasource: "tag.Datasource",
JS: "tag.JS",
GenerateCRUD: "tag.GenerateCRUD",
MobileResponsive: "tag.MobileResponsive",
Theme: "tag.Theme",
Random: "tag.Random",
Admin: "tag.Admin",
};

// Function to convert tag strings to tag values
function convertTagsToTagValues(tags) {
return tags.map((t) => tag[t]);
}

function addTagsToDescribeBlock(filePath, tags) {
const fileContent = fs.readFileSync(filePath, "utf-8");

const updatedContent = fileContent.replace(
/describe\s*\(\s*("[^"]*")\s*,\s*function\s*\(\s*\)\s*{/g,
(match, p1) => {
const describeString = p1.replace(/"/g, ""); // Remove quotes from the first parameter
if (tags.some((tag) => describeString.includes(tag))) {
const tagValues = convertTagsToTagValues(tags);
return `describe(${p1}, { tags: [${tagValues.join(
", ",
)}] }, function () {`;
}
return match; // Return original match if no matching tag is found
},
);

// Write updated content back to the file
fs.writeFileSync(filePath, updatedContent, "utf-8");
}

// Function to iterate through files in a directory
function iterateFilesInFolder(folderPath, tags) {
fs.readdir(folderPath, (err, files) => {
if (err) {
console.error("Error reading directory:", err);
return;
}

files.forEach((file) => {
const filePath = path.join(folderPath, file);

// Check if the file is a .js or .ts file
if (
fs.statSync(filePath).isFile() &&
(filePath.endsWith(".js") || filePath.endsWith(".ts"))
) {
addTagsToDescribeBlock(filePath, tags);
console.log(`Tags added to ${filePath}`);
} else if (fs.statSync(filePath).isDirectory()) {
// Recursively call for subdirectories
iterateFilesInFolder(filePath, tags);
}
});
});
}

// Read command line arguments for folderPath and tagsToAdd
const args = process.argv.slice(2);
if (args.length < 2) {
console.error("Please provide both folder path and tags to add.");
process.exit(1);
}

const folderPath = args[0];
const tagsToAdd = args.slice(1);

// Start iterating through files in the specified folder
iterateFilesInFolder(folderPath, tagsToAdd);
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
});

it(
"excludeForAirgap",
"4. Should test that settings page tab redirects",
{ tags: ["@tag.excludeForAirgap"] },
() => {
Expand Down Expand Up @@ -93,7 +92,6 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
);

it(
"excludeForAirgap",
"5. Should test that authentication page redirects",
{ tags: ["@tag.excludeForAirgap"] },
() => {
Expand Down Expand Up @@ -129,7 +127,6 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
);

it(
"excludeForAirgap",
"6. Should test that configure link redirects to google signup setup doc",
{ tags: ["@tag.excludeForAirgap"] },
() => {
Expand All @@ -149,7 +146,6 @@ describe("Admin settings page", { tags: ["@tag.Settings"] }, function () {
);

it(
"excludeForAirgap",
"7. Should test that configure link redirects to github signup setup doc",
{ tags: ["@tag.excludeForAirgap"] },
() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ describe("Autocomplete bug fixes", { tags: ["@tag.JS"] }, function () {
});

it(
"excludeForAirgap",
"7. Installed library should show up in autocomplete",
{ tags: ["@tag.excludeForAirgap"] },
function () {
AppSidebar.navigate(AppSidebarButton.Libraries);
installer.OpenInstaller();
Expand All @@ -106,8 +106,8 @@ describe("Autocomplete bug fixes", { tags: ["@tag.JS"] }, function () {
);

it(
"excludeForAirgap",
"8. No autocomplete for Removed libraries",
{ tags: ["@tag.excludeForAirgap"] },
function () {
entityExplorer.RenameEntityFromExplorer("Text1Copy", "UUIDTEXT");
AppSidebar.navigate(AppSidebarButton.Libraries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const testdata = require("../../../../fixtures/testdata.json");
import * as _ from "../../../../support/Objects/ObjectsCore";

describe(
"excludeForAirgap",
"Binding the Button widget with Text widget using Recpatcha v3",
{ tags: ["@tag.excludeForAirgap", "@tag.Binding"] },
function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
import * as _ from "../../../../support/Objects/ObjectsCore";

describe(
"excludeForAirgap",
"Welcome tour spec",
{ tags: ["@tag.excludeForAirgap"] },
function () {
it("1. Bug: 22275: Debugger should not render in preview mode", function () {
//Open debugger
_.agHelper.GetNClick(_.debuggerHelper.locators._debuggerIcon);
//Enter preview mode
_.agHelper.GetNClick(_.locators._enterPreviewMode);
//verify debugger is not present
_.agHelper.AssertElementAbsence(_.locators._errorTab);
//Exit preview mode
_.agHelper.GetNClick(_.locators._exitPreviewMode);
//verify debugger is present
_.agHelper.GetNAssertContains(_.locators._errorTab, "Errors");
});
it("2. Bug: 22281: Debugger should not open by default in welcome tour", function () {
//Get back to application page
_.homePage.NavigateToHome();
_.agHelper.WaitUntilEleAppear(_.homePage._homePageAppCreateBtn);

// Temporary workaround until https://github.com/appsmithorg/appsmith/issues/24665 is fixed
_.agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
_.homePage.CreateNewWorkspace("GuidedtourWorkspace" + uid);
_.homePage.CreateAppInWorkspace(
"GuidedtourWorkspace" + uid,
`GuidedtourApp${uid}`,
);
_.homePage.NavigateToHome();
});
describe("Welcome tour spec", { tags: ["@tag.excludeForAirgap"] }, function () {
it("1. Bug: 22275: Debugger should not render in preview mode", function () {
//Open debugger
_.agHelper.GetNClick(_.debuggerHelper.locators._debuggerIcon);
//Enter preview mode
_.agHelper.GetNClick(_.locators._enterPreviewMode);
//verify debugger is not present
_.agHelper.AssertElementAbsence(_.locators._errorTab);
//Exit preview mode
_.agHelper.GetNClick(_.locators._exitPreviewMode);
//verify debugger is present
_.agHelper.GetNAssertContains(_.locators._errorTab, "Errors");
});
it("2. Bug: 22281: Debugger should not open by default in welcome tour", function () {
//Get back to application page
_.homePage.NavigateToHome();
_.agHelper.WaitUntilEleAppear(_.homePage._homePageAppCreateBtn);

//Start welcome tour
_.agHelper.GetNClick(_.homePage._welcomeTour);
_.agHelper.WaitUntilEleAppear(_.homePage._welcomeTourBuildingButton);
//Verify debugger is not present
_.agHelper.AssertElementAbsence(_.locators._errorTab);
// Temporary workaround until https://github.com/appsmithorg/appsmith/issues/24665 is fixed
_.agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
_.homePage.CreateNewWorkspace("GuidedtourWorkspace" + uid);
_.homePage.CreateAppInWorkspace(
"GuidedtourWorkspace" + uid,
`GuidedtourApp${uid}`,
);
_.homePage.NavigateToHome();
});
},
);

//Start welcome tour
_.agHelper.GetNClick(_.homePage._welcomeTour);
_.agHelper.WaitUntilEleAppear(_.homePage._welcomeTourBuildingButton);
//Verify debugger is not present
_.agHelper.AssertElementAbsence(_.locators._errorTab);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ const dataSources = ObjectsRegistry.DataSources,
agHelper = ObjectsRegistry.AggregateHelper;

describe(
"excludeForAirgap",
"Bug 18035: Updates save button text on datasource discard popup",
{ tags: ["@tag.Datasource"] },
{ tags: ["@tag.Datasource", "@tag.excludeForAirgap"] },
function () {
it("1. Create gsheet datasource, click on back button, discard popup should contain save and authorize", function () {
dataSources.NavigateToDSCreateNew();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import EditorNavigation, {
let dsName: any, userMock: string, movieMock: string;

describe(
"excludeForAirgap",
"Bug 26716: Datasource selected from entity explorer should be correctly highlighted",
{ tags: ["@tag.Datasource"] },
{ tags: ["@tag.Datasource", "@tag.excludeForAirgap"] },
function () {
it("1. Create users and movies mock datasources and switch between them through entity explorer, check the active state", function () {
dataSources.CreateMockDB("Users").then((mockDBName) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,22 @@ import { featureFlagIntercept } from "../../../../support/Objects/FeatureFlags";

describe(
"Datasource structure schema preview data",
{ tags: ["@tag.Datasource"] },
{ tags: ["@tag.Datasource", "@tag.excludeForAirgap"] },
() => {
before(() => {
featureFlagIntercept({ ab_gsheet_schema_enabled: true });
dataSources.CreateMockDB("Users");
});

it(
"excludeForAirgap",
"1. Verify if the schema table accordions is collapsed in case of search",
() => {
agHelper.TypeText(
dataSources._datasourceStructureSearchInput,
"public.us",
);
agHelper.Sleep(1000);
agHelper.AssertElementAbsence(
`${dataSources._dsStructurePreviewMode} ${dataSources._datasourceSchemaColumn}`,
);
},
);
it("1. Verify if the schema table accordions is collapsed in case of search", () => {
agHelper.TypeText(
dataSources._datasourceStructureSearchInput,
"public.us",
);
agHelper.Sleep(1000);
agHelper.AssertElementAbsence(
`${dataSources._dsStructurePreviewMode} ${dataSources._datasourceSchemaColumn}`,
);
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import EditorNavigation, {
} from "../../../../support/Pages/EditorNavigation";

describe(
"excludeForAirgap",
"Fix UQI query switching",
{ tags: ["@tag.Datasource"] },
{ tags: ["@tag.Datasource", " @tag.excludeForAirgap"] },
function () {
it("1. The command of the Mongo query must be preserved and should not default to initial value after changed.", function () {
dataSources.NavigateToDSCreateNew();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ describe(
});

it(
"excludeForAirgap",
"3. Verify if schema (table and column) exist in query editor and searching works",
{ tags: ["@tag.excludeForAirgap"] },
() => {
agHelper.RefreshPage();
dataSources.CreateMockDB("Users");
Expand All @@ -87,8 +87,8 @@ describe(
);

it(
"excludeForAirgap",
"4. Verify if collapsible opens when refresh button is opened.",
{ tags: ["@tag.excludeForAirgap"] },
() => {
agHelper.RefreshPage();
dataSources.CreateMockDB("Users");
Expand Down
Loading
Loading