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: new test cases framework functions and Action selector #37566

Merged
merged 59 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a88888a
new test cases fof action
sagar-qa007 Nov 19, 2024
4790898
Update for flaky
sagar-qa007 Nov 20, 2024
cc8200d
Alert messsage code done
sagar-qa007 Nov 21, 2024
ba6a61d
update for test
sagar-qa007 Nov 21, 2024
59e9362
Modal related cases done
sagar-qa007 Nov 21, 2024
6b0d5dc
local storage related test cases
sagar-qa007 Nov 25, 2024
9906ca7
Run setup
sagar-qa007 Nov 25, 2024
1203bf5
update only
sagar-qa007 Nov 26, 2024
25a3d63
Merge remote-tracking branch 'origin/release' into test/frameworkfunc…
sagar-qa007 Nov 26, 2024
9ce0a1b
Saved changes for download
sagar-qa007 Nov 26, 2024
41ffc6f
Merge remote-tracking branch 'origin/release' into test/frameworkfunc…
sagar-qa007 Nov 26, 2024
0b7f0de
Merge remote-tracking branch 'origin/release' into test/frameworkfunc…
sagar-qa007 Nov 26, 2024
056527a
Merge remote-tracking branch 'origin/release' into test/frameworkfunc…
sagar-qa007 Nov 26, 2024
405a351
Merge remote-tracking branch 'origin/release' into test/frameworkfunc…
sagar-qa007 Nov 26, 2024
ba3a393
Merge remote-tracking branch 'origin/release' into test/frameworkfunc…
sagar-qa007 Nov 26, 2024
af97ce4
Minor update
sagar-qa007 Nov 27, 2024
68f0553
Merge remote-tracking branch 'origin/release' into test/frameworkfunc…
sagar-qa007 Nov 27, 2024
390638a
Merge remote-tracking branch 'origin/release' into test/frameworkfunc…
sagar-qa007 Nov 27, 2024
9038912
reverted only
sagar-qa007 Nov 28, 2024
359b47b
Download fun test cases
sagar-qa007 Nov 28, 2024
62fa7f0
Reverted only
sagar-qa007 Nov 28, 2024
4e0c35b
Completed download file
sagar-qa007 Nov 28, 2024
ceef715
Minor optimisations
sagar-qa007 Nov 29, 2024
683cf24
Optimisation for jsobject
sagar-qa007 Nov 29, 2024
dc24c4b
Copy to clipboard cases done
sagar-qa007 Nov 29, 2024
93575cc
Reset widget test cases
sagar-qa007 Nov 30, 2024
ae8b90a
Completed basic code for setInterval
sagar-qa007 Dec 1, 2024
ab2cf12
Data added
sagar-qa007 Dec 1, 2024
92fc503
Merge branch 'release' into test/frameworkfunctions
sagar-qa007 Dec 3, 2024
f6251eb
Small update for code
sagar-qa007 Dec 3, 2024
704c5c0
Merge remote-tracking branch 'origin' into test/frameworkfunctions
sagar-qa007 Dec 3, 2024
42f5163
Merge remote-tracking branch 'origin' into test/frameworkfunctions
sagar-qa007 Dec 3, 2024
cbf2217
Updated interval tc
sagar-qa007 Dec 3, 2024
bff309f
Watch geo location cases
sagar-qa007 Dec 3, 2024
d0fc084
some work progress
sagar-qa007 Dec 4, 2024
339795e
Merge branch 'release' into test/frameworkfunctions
yatinappsmith Dec 4, 2024
7359fe9
Update with postmessage
sagar-qa007 Dec 5, 2024
de199ee
Update for postwindow
sagar-qa007 Dec 6, 2024
b2c711b
Merge branch 'release' into test/frameworkfunctions
sagar-qa007 Dec 9, 2024
f65f265
Basic setup
sagar-qa007 Dec 9, 2024
5878c38
Some steps written
sagar-qa007 Dec 9, 2024
dba856b
Progress saved
sagar-qa007 Dec 10, 2024
eb7bf2a
remove only
sagar-qa007 Dec 10, 2024
6dc9327
Fix local store and actionselector done
sagar-qa007 Dec 10, 2024
9756ce8
Fix for download file
sagar-qa007 Dec 10, 2024
4ea1a3b
Merge branch 'release' into test/frameworkfunctions
sagar-qa007 Dec 10, 2024
98300a1
Modal and stop location fixes
sagar-qa007 Dec 10, 2024
b8e53e2
Postwindownew cases
sagar-qa007 Dec 10, 2024
46ff2ce
Updated name
sagar-qa007 Dec 10, 2024
6dae3c9
Deleted unused file
sagar-qa007 Dec 10, 2024
c14d734
Minor update
sagar-qa007 Dec 10, 2024
9cda459
Prettier error resolve
sagar-qa007 Dec 10, 2024
09176be
Homepage revert
sagar-qa007 Dec 10, 2024
6560706
HomepageTs revert
sagar-qa007 Dec 10, 2024
e6768cb
Update for test fix
sagar-qa007 Dec 11, 2024
c6250d0
Update
sagar-qa007 Dec 11, 2024
fd8d5e2
Merge branch 'release' into test/frameworkfunctions
sagar-qa007 Dec 11, 2024
d89d870
Fix cases
sagar-qa007 Dec 12, 2024
56f7a2e
Merge remote-tracking branch 'origin' into test/frameworkfunctions
sagar-qa007 Dec 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,241 @@ describe(
agHelper.ClickButton("ClearStore");
agHelper.AssertContains(JSON.stringify({}));
deployMode.NavigateBacktoEditor();
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
agHelper.GetNClick(propPane._deleteWidget);
EditorNavigation.SelectEntityByName("Button2", EntityType.Widget);
agHelper.GetNClick(propPane._deleteWidget);
});
Comment on lines +82 to +86
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use API calls for test cleanup instead of UI interactions

Replace widget deletion via UI with API calls for more reliable and faster test execution.

-      EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
-      agHelper.GetNClick(propPane._deleteWidget);
-      EditorNavigation.SelectEntityByName("Button2", EntityType.Widget);
-      agHelper.GetNClick(propPane._deleteWidget);
+      // Use API calls to delete widgets
+      cy.deleteWidget("Button1");
+      cy.deleteWidget("Button2");

Committable suggestion skipped: line range outside the PR's diff.


it("2. To verify both persistent and session-specific stored values are cleared when clearStore() is called.", function () {
entityExplorer.DragDropWidgetNVerify("buttonwidget", 100, 100);
const JS_OBJECT_BODY = `export default {
storePersistentValue: async () => {
let values = [
storeValue('persistentVal1', 'persistent value 1', true),
storeValue('persistentVal2', 'persistent value 2', true),
storeValue('sessionVal1', 'session value 1'),
storeValue('sessionVal2', 'session value 2'),
];
await Promise.all(values);
await showAlert(JSON.stringify(appsmith.store));
},
clearStore: async () => {
await clearStore();
await showAlert(JSON.stringify(appsmith.store));
}
}`;

jsEditor.CreateJSObject(JS_OBJECT_BODY, {
paste: true,
completeReplace: true,
toRun: false,
prettify: false,
shouldCreateNewJSObj: true,
});

EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
propPane.UpdatePropertyFieldValue("Label", "");
propPane.TypeTextIntoField("Label", "StorePersistentValue");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"storePersistentValue",
);
});

entityExplorer.DragDropWidgetNVerify("buttonwidget", 200, 300);
EditorNavigation.SelectEntityByName("Button2", EntityType.Widget);
propPane.UpdatePropertyFieldValue("Label", "");
propPane.TypeTextIntoField("Label", "ClearStore");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"clearStore",
);
});

deployMode.DeployApp();
agHelper.ClickButton("StorePersistentValue");
agHelper.AssertContains(
JSON.stringify({
persistentVal1: "persistent value 1",
persistentVal2: "persistent value 2",
sessionVal1: "session value 1",
sessionVal2: "session value 2",
}),
);
agHelper.ClickButton("ClearStore");
agHelper.AssertContains(JSON.stringify({}));
deployMode.NavigateBacktoEditor();
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
agHelper.GetNClick(propPane._deleteWidget);
EditorNavigation.SelectEntityByName("Button2", EntityType.Widget);
agHelper.GetNClick(propPane._deleteWidget);
});

it("3. To verify that clearStore() only removes values stored by the application and does not affect other unrelated data in the browser's local storage.", function () {
entityExplorer.DragDropWidgetNVerify("buttonwidget", 100, 100);
// Set some unrelated local storage data
cy.window().then((win) => {
win.localStorage.setItem("unrelatedKey1", "unrelated value 1");
win.localStorage.setItem("unrelatedKey2", "unrelated value 2");
});

entityExplorer.DragDropWidgetNVerify("buttonwidget", 100, 100);
const JS_OBJECT_BODY = `export default {
storeValue: async () => {
let values = [
storeValue('val1', 'value 1'),
storeValue('val2', 'value 2'),
];
await Promise.all(values);
await showAlert(JSON.stringify(appsmith.store));
},
clearStore: async () => {
await clearStore();
await showAlert(JSON.stringify(appsmith.store));
}
}`;

jsEditor.CreateJSObject(JS_OBJECT_BODY, {
paste: true,
completeReplace: true,
toRun: false,
prettify: false,
shouldCreateNewJSObj: true,
});

EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
propPane.UpdatePropertyFieldValue("Label", "");
propPane.TypeTextIntoField("Label", "StoreValue");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"storeValue",
);
});

entityExplorer.DragDropWidgetNVerify("buttonwidget", 200, 200);
EditorNavigation.SelectEntityByName("Button2", EntityType.Widget);
propPane.UpdatePropertyFieldValue("Label", "");
propPane.TypeTextIntoField("Label", "ClearStore");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"clearStore",
);
});

deployMode.DeployApp();
agHelper.ClickButton("StoreValue");
agHelper.AssertContains(
JSON.stringify({
val1: "value 1",
val2: "value 2",
}),
);
agHelper.ClickButton("ClearStore");
agHelper.AssertContains(JSON.stringify({}));

// Verify unrelated local storage data is not cleared
cy.window().then((win) => {
expect(win.localStorage.getItem("unrelatedKey1")).to.equal(
"unrelated value 1",
);
expect(win.localStorage.getItem("unrelatedKey2")).to.equal(
"unrelated value 2",
);
});

deployMode.NavigateBacktoEditor();
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
agHelper.GetNClick(propPane._deleteWidget);
EditorNavigation.SelectEntityByName("Button2", EntityType.Widget);
agHelper.GetNClick(propPane._deleteWidget);
});

it("4. To verify that clearStore() only affects the current tab's storage and does not inadvertently impact session storage across tabs.", function () {
entityExplorer.DragDropWidgetNVerify("buttonwidget", 100, 100);
const JS_OBJECT_BODY = `export default {
storeValue: async () => {
let values = [
storeValue('val1', 'value 1'),
storeValue('val2', 'value 2'),
];
await Promise.all(values);
await showAlert(JSON.stringify(appsmith.store));
},
clearStore: async () => {
await clearStore();
await showAlert(JSON.stringify(appsmith.store));
}
}`;

jsEditor.CreateJSObject(JS_OBJECT_BODY, {
paste: true,
completeReplace: true,
toRun: false,
prettify: false,
shouldCreateNewJSObj: true,
});

EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
propPane.UpdatePropertyFieldValue("Label", "");
propPane.TypeTextIntoField("Label", "StoreValue");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"storeValue",
);
});

entityExplorer.DragDropWidgetNVerify("buttonwidget", 200, 200);
EditorNavigation.SelectEntityByName("Button2", EntityType.Widget);
propPane.UpdatePropertyFieldValue("Label", "");
propPane.TypeTextIntoField("Label", "ClearStore");
cy.get("@jsObjName").then((jsObj: any) => {
propPane.SelectJSFunctionToExecute(
"onClick",
jsObj as string,
"clearStore",
);
});

deployMode.DeployApp();
agHelper.ClickButton("StoreValue");
agHelper.AssertContains(
JSON.stringify({
val1: "value 1",
val2: "value 2",
}),
);

// Open a new tab and verify the storage is not affected
cy.window().then((win) => {
const newTab = win.open(win.location.href, "_blank");
if (newTab) {
cy.wrap(newTab).should(() => {
const isEmpty = Object.keys(newTab.localStorage).length === 0;
expect(isEmpty).to.be.false;
});
newTab.close();
}
});
Comment on lines +298 to +307
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid using 'window.open' in Cypress tests

Cypress does not support multiple tabs or window.open. Consider simulating the behavior within the same tab.


agHelper.ClickButton("ClearStore");
agHelper.AssertContains(JSON.stringify({}));

deployMode.NavigateBacktoEditor();
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
agHelper.GetNClick(propPane._deleteWidget);
EditorNavigation.SelectEntityByName("Button2", EntityType.Widget);
agHelper.GetNClick(propPane._deleteWidget);
});
},
);
Loading
Loading