How to replace cy.wait() with assertions in Cypress for dropdown menu visibility?

I’m having an issue with my Cypress test where I use cy.wait() to ensure a dropdown menu is fully loaded before interacting with it. However, I know that using cy.wait() is not a best practice. Here’s the relevant part of my code – I’m using TypeScript:

 cy.get(this.searchBarDropdownOptions).within(() => {
  // searchBarDropdownOptions = ".cdk-overlay-connected-position-bounding-box";
  cy.wait(1000);
  cy.contains("li", siteName).click();
  cy.wait(1000);
  cy.contains("li", location).click();
  cy.wait(1000);
  cy.contains("li", connectionStatus).click();
  cy.wait(1000);
  cy.contains("li", offline).click();
});

Problem:

The test fails because the dropdown menu is not always loaded and visible when Cypress tries to interact with it. I want to replace cy.wait() with a more reliable method, such as assertions, to wait for the elements to be visible.

Question:

How can I replace cy.wait() with assertions or a better approach to ensure the dropdown menu is fully loaded and visible before interacting with it?

What I’ve Tried:

I’ve already tried the following methods, but none of them worked reliably:

Using { timeout: 1000 }

cy.get(‘li’).contains(…).should(‘be.visible’)

cy.get(‘li’).contains(…).should(‘exist’)

cy.waitUntil(() => …)

FAQ with SANITY. IO

Well i’m tyring to create a schema in sanity that suppose to be like FAQ but i cant edit it or anything any help please?

// faq.js

export default {
  name: 'faq',
  type: 'object',
  title: 'Frequently asked question',
  fields: [
    {
      name: 'question',
      type: 'string',
      title: 'Question'
    },
    {
      name: 'answer',
      type: 'text',
      title: 'Answer',
    }
  ]
}

i tried this

// faq.js

export default {
  name: 'faq',
  type: 'object',
  title: 'Frequently asked question',
  fields: [
    {
      name: 'question',
      type: 'string',
      title: 'Question'
    },
    {
      name: 'answer',
      type: 'text',
      title: 'Answer',
    }
  ]
}

and i dont know how to take next step

Images Not Displaying on Frontend Despite Correct API Response in React App (Strapi, Vite)

I am building a React app with Vite that fetches property data, including image URLs, from a Strapi backend. The API response contains the correct image URLs, and I can access the images directly through their URLs in a browser. However, the images are not displaying in the frontend. Instead, the message “No images available” is shown.

When I access the API endpoint http://localhost:1337/api/properties?populate[images][fields][0]=url, I get the following response for property 21:

{
  "id": 21,
  "address": "example 1",
  "price": 4,
  "images": [
    {
      "id": 2,
      "url": "/uploads/chicago_background_70fff5f0ee.jpg"
    },
    {
      "id": 1,
      "url": "/uploads/property_showcase_6363007fdf.png"
    }
  ]
}

I can access the images directly via URLs like:
http://localhost:1337/uploads/chicago_background_70fff5f0ee.jpg

Despite the correct API response, the console logs show an empty images array for property 21:
Property 21 Images: Array []

Code Snippet:

import React, { useEffect, useState } from "react";
import axios from "axios";

const CarouselSection = ({ title }) => {
    const [properties, setProperties] = useState([]);
    const [loading, setLoading] = useState(true);
    const [error, setError] = useState(null);

    useEffect(() => {
        const fetchProperties = async () => {
            try {
                const apiUrl = import.meta.env.VITE_API_URL;
                console.log("API URL:", apiUrl);

                const response = await axios.get(`${apiUrl}/api/properties?populate[images][fields][0]=url`);
                console.log("Full Response:", response.data);

                const propertiesData = response.data?.data || [];
                if (!Array.isArray(propertiesData) || propertiesData.length === 0) {
                    throw new Error("No properties found or invalid response structure");
                }

                const parsedProperties = propertiesData.map((property) => {
                    const images =
                        Array.isArray(property.images) && property.images.length > 0
                            ? property.images.map((image) => `${apiUrl}${image.url.startsWith('/') ? image.url : `/${image.url}`}`)
                            : [];

                    console.log(`Images for property ID: ${property.id} URLs:`, images);

                    return {
                        id: property.id,
                        address: property.address || "No Address Available",
                        price: property.price !== null ? `$${property.price}` : "N/A",
                        bedrooms: property.bedrooms || 0,
                        bathrooms: property.bathrooms || 0,
                        sqft: property.sqft || 0,
                        listingstatus: property.listingstatus || "Unknown",
                        zillowlink: property.zillowlink || "#",
                        images,
                    };
                });

                setProperties(parsedProperties);
            } catch (err) {
                setError("Failed to fetch property data");
                console.error("Error fetching properties:", err.response ? err.response.data : err.message);
            } finally {
                setLoading(false);
            }
        };

        fetchProperties();
    }, []);

    if (loading) return <p>Loading...</p>;
    if (!properties.length) return <p>No properties available</p>;

    return (
        <section className="carousel-section">
            <h1 className="title">{title}</h1>
            <div className="carousel-container">
                {properties.map((property) => (
                    <article key={property.id} className="carousel-card">
                        {property.images && property.images.length > 0 ? (
                            <div className="carousel-images">
                                {property.images.map((src, index) => (
                                    <img key={index} src={src} alt={`Property ${property.id} Image ${index + 1}`} />
                                ))}
                            </div>
                        ) : (
                            <p>No images available</p>
                        )}
                        <p>{property.address}</p>
                        <p>{property.price}</p>
                    </article>
                ))}
            </div>
        </section>
    );
};

export default CarouselSection;

Issue:

  • The backend API response contains valid image URLs, and they are accessible in the browser directly.
  • However, when fetching the data in the React app, the property.images array appears empty, which causes the frontend to display “No images available.”

Environment:

  • Frontend: React with Vite
  • Backend: Strapi (running locally at http://localhost:1337)
  • API Base URL: VITE_API_URL=http://localhost:80

Why are the images not being processed correctly in the frontend, even when the backend API response is valid?

How can I fix this so that the images display as expected on the frontend?

Images Not Displaying on Frontend Despite Correct API Response in React App

I’m working on a React app that fetches property data, including image URLs, from a Strapi backend. The API response contains the correct data, and I can directly access the images via their URLs in a browser, but the images are not displaying in the frontend. Instead, it shows “No images available”

When I access the API endpoint http://localhost:1337/api/properties?populate[images][fields][0]=url, I get the following response for property 21:

{
"id": 21,
"address": "example 1",
"price": 4,
"images": [
    {
        "id": 2,
        "url": "/uploads/chicago_background_70fff5f0ee.jpg"
    },
    {
        "id": 1,
        "url": "/uploads/property_showcase_6363007fdf.png"
    }
]

}

I can access the images directly via URLs like:
http://localhost:1337/uploads/chicago_background_70fff5f0ee.jpg

Despite the correct API response, the console logs show an empty images array for property 21:

Property 21 Images: Array []



import React, { useEffect, useState } from "react";
import axios from "axios";

const CarouselSection = ({ title }) => {
    const [properties, setProperties] = useState([]);
    const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);

useEffect(() => {
    const fetchProperties = async () => {
        try {
            const apiUrl = import.meta.env.VITE_API_URL;
            console.log("API URL:", apiUrl);

            const response = await axios.get(`${apiUrl}/api/properties?populate[images][fields][0]=url`);
            console.log("Full Response:", response.data);

            const propertiesData = response.data?.data || [];
            if (!Array.isArray(propertiesData) || propertiesData.length === 0) {
                throw new Error("No properties found or invalid response structure");
            }

            const parsedProperties = propertiesData.map((property) => {
                const images =
                    Array.isArray(property.images) && property.images.length > 0
                        ? property.images.map((image) => `${apiUrl}${image.url.startsWith('/') ? image.url : `/${image.url}`}`)
                        : [];

                console.log(`Images for property ID: ${property.id} URLs:`, images);

                return {
                    id: property.id,
                    address: property.address || "No Address Available",
                    price: property.price !== null ? `$${property.price}` : "N/A",
                    bedrooms: property.bedrooms || 0,
                    bathrooms: property.bathrooms || 0,
                    sqft: property.sqft || 0,
                    listingstatus: property.listingstatus || "Unknown",
                    zillowlink: property.zillowlink || "#",
                    images,
                };
            });

            setProperties(parsedProperties);
        } catch (err) {
            setError("Failed to fetch property data");
            console.error("Error fetching properties:", err.response ? err.response.data : err.message);
        } finally {
            setLoading(false);
        }
    };

    fetchProperties();
}, []);

if (loading) return <p>Loading...</p>;
if (!properties.length) return <p>No properties available</p>;

return (
    <section className="carousel-section">
        <h1 className="title">{title}</h1>
        <div className="carousel-container">
            {properties.map((property) => (
                <article key={property.id} className="carousel-card">
                    {property.images && property.images.length > 0 ? (
                        <div className="carousel-images">
                            {property.images.map((src, index) => (
                                <img key={index} src={src} alt={`Property ${property.id} Image ${index + 1}`} />
                            ))}
                        </div>
                    ) : (
                        <p>No images available</p>
                    )}
                    <p>{property.address}</p>
                    <p>{property.price}</p>
                </article>
            ))}
        </div>
    </section>
);

};

export default CarouselSection;

I’ve verified that the backend API response contains the correct image URLs., confirmed the images are accessible directly via their URLs in the browser, and logged property.images in the frontend, but it always shows an empty array ([]) for all properties.

Environment:

Frontend Framework: React with Vite
Backend: Strapi dev
Development Server: Running locally on http://localhost:80
Strapi API: Running locally on http://localhost:1337
API Base URL: VITE_API_URL=http://localhost:80

The images for property 21 (and others with valid images) should display in the frontend but the frontend displays “No images available” even when the API response contains valid image data.

Why are the images not being processed correctly in the frontend? How can I fix this so that the images display as expected?

Possible rearrangement of 2 combined arrays [closed]

Write javascript recursion for the combination of 2 arrays:

let tokens = [A, B, C];
let dice =[1, 2, 3]

The result should be something like this. Also take note that there is no repeat:

A1 B2 C3, A2 B1 C3, A3 B1 C2,

B1 A2 C3, B2 A1 C3, B3 A1 C2,

C1 A2 B3, C2 A1 B3, C3 A1 B2,

A12 B3, A12 C3,

A13 B2, A13 C2,

A23 B1, A23 C1,

B12 A3, B12 C3,

B13 A2, B13 C2,

B23 A1, B23 C1,

C12 A3, C12 B3,

C13 A2, C13 B2,

C23 A1, C23 B2

A123, B123, C123

Azure Blob Storage Static Website React SPA Routing Fails After Webpack Compression Changes

I’m hosting a React SPA on Azure Blob Storage Static Website. My /dist folder originally contained both compressed and non-compressed assets. To optimize my build, I configured Webpack’s CompressionPlugin to compress specific files, delete the original assets, and use a script to remove the .gz extension from the compressed files. (As per Azure documentation, only non-compressed file extensions should be served directly.)

Here’s my Webpack compression configuration:

new CompressionPlugin({
    algorithm: "gzip",
    exclude: /env//,
    test: /.(js|json|xml|svg|txt|eot|ttf|css|html)$/,
    minRatio: Number.MAX_SAFE_INTEGER,
    deleteOriginalAssets: true,
}),

Issue

When running the app locally with webpack serve or http-server -g, everything works correctly as expected— client-side routing functions. However, after building and deploying to Azure, navigating directly to a route like /about results in a 404 Page Not Found error instead of the expected client-side navigation.

Observations

Before making these changes, I noticed that when directly accessing a React Router path (e.g., /about), the browser DevTools logs a 404 error, but the app still updates the VDOM correctly. After my compression and Webpack changes, the app does not update the VDOM, and the 404 page remains.

Potential Cause

One notable change I made was removing the publicPath from my Webpack output configuration, leaving it as:

output: {
    path: helpers.root("dist"),
    filename: "[name].[contenthash].js",
    chunkFilename: "chunk.[contenthash].js",
    clean: true,
},

Question

What could be causing Azure Blob Storage Static Website to break client-side routing after applying compression and Webpack configuration changes?

  • Is the removal of publicPath affecting routing?
  • Did deleting original assets cause missing file issues?
  • Can Azure Blob Storage settings be adjusted to support React Router?

Any help would be appreciated!

Have read more button hide elements before being clicked

I have a basic understanding of html but I’ll be honest I don’t understand javascript at all and I copied this code from somewhere else. It works except everything under the ‘read more’ is visible on default and when you click the button it hides the elements. I want to know if there’s a way to edit the code so when you open the page everything under the ‘read more’ is hidden and when you click it the elements appear.

Here’s the code

<script>
function toggle(button){

    // this works because the button is immediately after the "moreDetails" element it pertains to
    let Text = button.previousElementSibling;

    // this would work if you move the button so it is not immediately after moreDetails, but still in the same parent div.
    //let Text = button.parentElement.querySelector(".moreDetails");
    
    if(Text.style.display == "block"){
        Text.style.display= "none";
    }
    else {
        Text.style.display = "none";
    }
}

const moreDetailses = document.querySelectorAll(".moreDetails");
for (let i = 0; i < moreDetailses.length; i++) {
  moreDetailses[i].style.display = "none";
}
</script>

Angular + Tauri: SyntaxError: Unexpected token ‘=’ promiseReactionJob on macOS 10.15.7 or older

I am working on an Angular 17 + Tauri application, and I encountered the following error when running the app on macOS 10.15.7 or lower:

SyntaxError: Unexpected token '=' promiseReactionJob

Observations:

  1. The app works perfectly on macOS versions newer than 10.15.7.
  2. The error occurs specifically on macOS 10.15.7 and lower.
  3. Removing the following browserslist section from package.json does not affect the issue—I still get the same error regardless of the macOS version:

“browserslist”: [
“> 0.5%”,
“last 2 versions”,
“Firefox ESR”,
“not dead”,
“not IE 11”,
“not kaios 2.5”,
“not op_mini all”
]

What I Have Tried:

  1. Removing browserslist from package.json → no change.
  2. Checking Tauri and Angular compatibility for older macOS versions.
  3. Ensuring that the Angular app is compiled properly before bundling with Tauri.

Questions:

  1. Why does this error occur specifically on macOS 10.15.7 and lower?
  2. Could this be related to the system’s WebView version not supporting some modern JavaScript syntax?
  3. How can I make the Angular + Tauri app work on older macOS versions without errors?

Any help would be greatly appreciated!

Navigator.sendBeacon vs fetch keepalive: reliability upon browser or tab close

I’m trying to make a network request when a user closes their browser or tab. If you search here on stackoverflow, you’ll find one method is to use beforeunload or window.onbeforeunload. If you return undefined from your onbeforeunload callback, no dialog will appear and your code will be executed.

However, this is not intended to make network requests but to confirm with the user whether they mean to leave the page. For example, if a user has filled out a long form and you want to confirm with them that they didn’t close on accident.

It follows that you shouldn’t rely on onbeforeunload because there isn’t any guarantee that the request will complete. It was apparently not designed to execute requests. I have found many such answers directing people away from onbeforeunload and instead to Navigator.sendBeacon:

The browser API Navigator: sendBeacon was designed for this purpose. sendBeacon accepts a url and an optional data parameter which it will POST to. There are no options to either use a different HTTP method such as GET or DELETE nor does it accept a callback where you could use the fetch API to do so. You are limited to only posting data.

On the MDN docs for Navigator.sendBeacon, it even mentions this:

Note: For use cases that need the ability to send requests with methods other than POST, or to change any request properties, or that need access to the server response, instead use the fetch() method with keepalive set to true.

Does this mean that making requests in onbeforeunload is indeed reliable so long as you use the fetch API with keepalive:true? Which should be used? If I need to make a non-POST request, set headers, or access the request’s response is keepalive:true with fetch enough?

The MDN docs for beforeunload event essentially say that it’s not recommended to use this event for anything but preventing a user from losing data. If not beforeunload, what’s the best way to reliably make a non-POST network request when a user closes a browser tab?

I know there are more robust ways of detecting this with websockets, but what’s the client-only method that would work at least nearly as well as sendBeacon?

How to prevent the AbortError: signal is aborted without reason

I am getting a AbortError: signal is aborted without reason.

In the past I believe I was able to call abort on the signal even after fetch returned but now I’m getting this error. Maybe it is because I’m calling it twice?

Is there a way to prevent this error? I’ve checked if signal.aborted is true but that would be checking if it was aborted not if the request was completed.
Is there a property with the controller or signal that I can use to check if the fetch is done or can I simply catch the error (since it seems like it’s more of a warning) and discard it?

if (this.controllers) {
   this.controllers.forEach((value, key, map) => {
       if (value.signal.aborted == false) {
           value.abort();
       }
   });
}

INVALID_ARGUMENT in Google Analytics

Unable to retrieve event parameters associated with events.

I am integrating Google Analytics into my website and trying to fetch events using the Analytics Data API. However, the parameters I sent with these events are not included in the API response.

Additionally, my events are being deleted from the Google Analytics dashboard, but they still appear in the API results.

I am doing it this way:

async function runRealtimeReport() {
  const [response] = await analyticsDataClient.runRealtimeReport({
    property: `properties/${propertyId}`,
    dimensions: [
      { name: "eventName" },
      { name: "eventParams.video_id" }, // I also tried {name: "customEvent:video_id"}
      { name: "eventParams.duration" }, // {name: "customEvent:duration"}
    ],
    metrics: [{ name: "eventCount" }],
  });

  console.log("Report result:", JSON.stringify(response, null, 2));
  printRunReportResponse(response);
}

I initially did not include eventParams.video_id and duration, but after realizing that my parameters were missing from the response, I added them. I also tried registering my custom dimensions with an event scope, but they are still not working

Angular + tauri details

getting error
SyntaxError: Unexpected toke '=' promiseReactionJob
on old macOS 10.15.7 and works just fine on newer versions, can someone tell me what could be the reason of this?
also if i remove these lines i get the same errors in every version (package,json) "browserslist": [ "> 0.5%", "last 2 versions", "Firefox ESR", "not dead", "not IE 11", "not kaios 2.5", "not op_mini all" ]

How can I programmatically add markdown cells in Google Colab using a given markdown script?

I am working on a project where I need to write text in markdown cells one after another. However, manually adding and editing cells becomes tedious. I am looking for a way to programmatically add new markdown cells with a given markdown script.

I have tried multiple approaches using ChatGPT, but they didn’t work.

Please help. Thank you!

I tried ChatGPT approaches which mainly used IPython.core.display methods. But none worked out.

Change CSS with JS button

So, I wanted to create two buttons and when one is pressed it would go bigger and bigger with each press until it covers the whole screen and I want them to be next to each other. The other button would different things that I know how to do.

I’m new to JS and I don’t get it too much yet but I tried to change the size of the button with “transofrm” rule and it did work but I don’t want the button to go over the first one, I want it to be shifted and stay next to the first button without covering it.