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

Cypress tests don't run on Windows(?) anymore #23487

Closed
turt2live opened this issue Oct 14, 2022 · 3 comments
Closed

Cypress tests don't run on Windows(?) anymore #23487

turt2live opened this issue Oct 14, 2022 · 3 comments
Assignees
Labels
A-Developer-Experience T-Task Tasks for the team like planning

Comments

@turt2live
Copy link
Member

Uncaught TypeError: Cannot read properties of undefined (reading 'message')
    at makeErrFromObj (cypress_runner.js:170633:30)
    at errorFromProjectRejectionEvent (cypress_runner.js:170997:10)
    at Object.errorFromUncaughtEvent (cypress_runner.js:171003:65)
    at cypress_runner.js:167727:74
makeErrFromObj	@	cypress_runner.js:170633
errorFromProjectRejectionEvent	@	cypress_runner.js:170997
errorFromUncaughtEvent	@	cypress_runner.js:171003
(anonymous)	@	cypress_runner.js:167727



:8080/#/login:1 Uncaught (in promise) undefined
setInterval (async)		
a	@	(index):3
(anonymous)	@	(index):3
waitForStyleSheetLoading	@	theme.ts?6c0f:300
eval	@	theme.ts?6c0f:327
setTheme	@	theme.ts?6c0f:264
loadTheme	@	init.tsx?ef7e:135
start	@	index.ts?4311:167
await in start (async)		
eval	@	index.ts?4311:240
(anonymous)	@	bundle.js:1389
__webpack_require__	@	bundle.js:833
fn	@	bundle.js:130
(anonymous)	@	bundle.js:1013
__webpack_require__	@	bundle.js:833
(anonymous)	@	bundle.js:1000
(anonymous)	@	bundle.js:1003

No idea what this might be. The error message shows up in cypress-io/cypress#23937 but that could be unrelated.

Currently managed to isolate this to be something to do with localStorage values of the access token, somehow. Other localStorage values are fine though, which is weird and annoying. Upgrading Cypress did not help. See cypress-io/cypress#23937 (comment)

@turt2live turt2live self-assigned this Oct 14, 2022
@RiotRobot RiotRobot added this to In Progress in Web App Team Oct 14, 2022
@turt2live
Copy link
Member Author

In case someone else is staring at this trying to figure out wtf is going on, this is the debugging I've managed to get through so far (the console logs don't really reveal anything):

diff --git a/cypress/e2e/user-view/user-view.spec.ts b/cypress/e2e/user-view/user-view.spec.ts
index 30c3ff23ca9..11ba5bd0301 100644
--- a/cypress/e2e/user-view/user-view.spec.ts
+++ b/cypress/e2e/user-view/user-view.spec.ts
@@ -19,6 +19,10 @@ limitations under the License.
 import { SynapseInstance } from "../../plugins/synapsedocker";
 import { MatrixClient } from "../../global";
 
+Cypress.on("uncaught:exception", (err) => {
+    console.error("@@", err);
+});
+
 describe("UserView", () => {
     let synapse: SynapseInstance;
 
@@ -27,7 +31,7 @@ describe("UserView", () => {
             synapse = data;
 
             cy.initTestUser(synapse, "Violet");
-            cy.getBot(synapse, { displayName: "Usman" }).as("bot");
+            // cy.getBot(synapse, { displayName: "Usman" }).as("bot");
         });
     });
 
@@ -36,16 +40,18 @@ describe("UserView", () => {
     });
 
     it("should render the user view as expected", () => {
-        cy.get<MatrixClient>("@bot").then(bot => {
-            cy.visit(`/#/user/${bot.getUserId()}`);
-        });
-
-        cy.get("#mx_RightPanel .mx_UserInfo_profile h2").should("contain", "Usman");
-        cy.get(".mx_RightPanel .mx_Spinner").should("not.exist"); // wait for spinners to finish
-        cy.get(".mx_RightPanel").percySnapshotElement("User View", {
-            // Hide the MXID field as it'll vary on each test
-            percyCSS: ".mx_UserInfo_profile_mxid { visibility: hidden !important; }",
-            widths: [260, 500],
-        });
+        cy.visit("/");
+        cy.get(".mx_AuthBody_language").should('exist').click();
+        // cy.get<MatrixClient>("@bot").then(bot => {
+        //     cy.visit(`/#/user/${bot.getUserId()}`);
+        // });
+        //
+        // cy.get("#mx_RightPanel .mx_UserInfo_profile h2").should("contain", "Usman");
+        // cy.get(".mx_RightPanel .mx_Spinner").should("not.exist"); // wait for spinners to finish
+        // cy.get(".mx_RightPanel").percySnapshotElement("User View", {
+        //     // Hide the MXID field as it'll vary on each test
+        //     percyCSS: ".mx_UserInfo_profile_mxid { visibility: hidden !important; }",
+        //     widths: [260, 500],
+        // });
     });
 });
diff --git a/cypress/support/login.ts b/cypress/support/login.ts
index e44be781231..b23668ec23e 100644
--- a/cypress/support/login.ts
+++ b/cypress/support/login.ts
@@ -104,31 +104,32 @@ Cypress.Commands.add("initTestUser", (synapse: SynapseInstance, displayName: str
         return cy.loginUser(synapse, username, password);
     }).then(response => {
         cy.window({ log: false }).then(win => {
+            console.log("@@-1", response.accessToken);
             // Seed the localStorage with the required credentials
             win.localStorage.setItem("mx_hs_url", synapse.baseUrl);
             win.localStorage.setItem("mx_user_id", response.userId);
-            win.localStorage.setItem("mx_access_token", response.accessToken);
+            win.localStorage.setItem("mx_access_token", response.accessToken); // Comment this out
             win.localStorage.setItem("mx_device_id", response.deviceId);
             win.localStorage.setItem("mx_is_guest", "false");
             win.localStorage.setItem("mx_has_pickle_key", "false");
-            win.localStorage.setItem("mx_has_access_token", "true");
+            win.localStorage.setItem("mx_has_access_token", "true"); // Comment this out
 
             // Ensure the language is set to a consistent value
             win.localStorage.setItem("mx_local_settings", '{"language":"en"}');
         });
-
-        prelaunchFn?.();
-
-        return cy.visit("/").then(() => {
-            // wait for the app to load
-            return cy.get(".mx_MatrixChat", { timeout: 30000 });
-        }).then(() => ({
-            password,
-            username,
-            accessToken: response.accessToken,
-            userId: response.userId,
-            deviceId: response.deviceId,
-            homeServer: response.homeServer,
-        }));
+        //
+        // prelaunchFn?.();
+        //
+        // return cy.visit("/").then(() => {
+        //     // wait for the app to load
+        //     return cy.get(".mx_MatrixChat", { timeout: 30000 });
+        // }).then(() => ({
+        //     password,
+        //     username,
+        //     accessToken: response.accessToken,
+        //     userId: response.userId,
+        //     deviceId: response.deviceId,
+        //     homeServer: response.homeServer,
+        // }));
     });
 });
diff --git a/src/Lifecycle.ts b/src/Lifecycle.ts
index 64d1d9b5fdf..df363cc4914 100644
--- a/src/Lifecycle.ts
+++ b/src/Lifecycle.ts
@@ -367,6 +367,8 @@ export async function getStoredSessionVars(): Promise<IStoredSession> {
         isGuest = localStorage.getItem("matrix-is-guest") === "true";
     }
 
+    console.log("@@ Done with lifecycle1");
+
     return { hsUrl, isUrl, hasAccessToken, accessToken, userId, deviceId, isGuest };
 }
 
@@ -651,6 +653,7 @@ function showStorageEvictedDialog(): Promise<boolean> {
 class AbortLoginAndRebuildStorage extends Error { }
 
 async function persistCredentials(credentials: IMatrixClientCreds): Promise<void> {
+    console.log("@@CALLING");
     localStorage.setItem(HOMESERVER_URL_KEY, credentials.homeserverUrl);
     if (credentials.identityServerUrl) {
         localStorage.setItem(ID_SERVER_URL_KEY, credentials.identityServerUrl);
@@ -715,7 +718,7 @@ async function persistCredentials(credentials: IMatrixClientCreds): Promise<void
 
     SecurityCustomisations.persistCredentials?.(credentials);
 
-    logger.log(`Session persisted for ${credentials.userId}`);
+    logger.log(`@@ Session persisted for ${credentials.userId}`);
 }
 
 let _isLoggingOut = false;
@@ -878,6 +881,7 @@ export async function onLoggedOut(): Promise<void> {
  * @returns {Promise} promise which resolves once the stores have been cleared
  */
 async function clearStorage(opts?: { deleteEverything?: boolean }): Promise<void> {
+    console.log("@@ DIE");
     if (window.localStorage) {
         // try to save any 3pid invites from being obliterated and registration time
         const pendingInvites = ThreepidInviteStore.instance.getWireInvites();
diff --git a/src/utils/StorageManager.ts b/src/utils/StorageManager.ts
index 1145bcfb15d..94014b15313 100644
--- a/src/utils/StorageManager.ts
+++ b/src/utils/StorageManager.ts
@@ -199,7 +199,11 @@ export async function idbLoad(
     if (!idb) {
         await idbInit();
     }
-    return new Promise((resolve, reject) => {
+    return new Promise((resolve, rejectt) => {
+        const reject = (f) => {
+            console.log("@@F", f);
+            rejectt(f);
+        };
         const txn = idb.transaction([table], "readonly");
         txn.onerror = reject;
 
@@ -218,7 +222,11 @@ export async function idbSave(
     if (!idb) {
         await idbInit();
     }
-    return new Promise((resolve, reject) => {
+    return new Promise((resolve, rejectt) => {
+        const reject = (f) => {
+            console.log("@@F2", f);
+            rejectt(f);
+        };
         const txn = idb.transaction([table], "readwrite");
         txn.onerror = reject;

@duxovni duxovni added the T-Task Tasks for the team like planning label Oct 14, 2022
@turt2live
Copy link
Member Author

Running them in a Vm mostly works (aside from failing tests within the VM, but at least it's not screaming about origin)

image

@turt2live
Copy link
Member Author

This is a local issue - closing as environmental.

@turt2live turt2live closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2022
Web App Team automation moved this from In Progress to Done Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Developer-Experience T-Task Tasks for the team like planning
Projects
No open projects
Development

No branches or pull requests

2 participants