SIS-Team-24 / 2023-SIS-Team-24

Using Natural Language Processing, Text Insights examines and provides insights to text.
1 stars 0 forks source link

added cypress test for share URL feature #204

Closed srujankarthik closed 1 year ago

srujankarthik commented 1 year ago

I've tried implementing the code in a way it opens the URL using custom JS

but [ As Cypress runs inside the browser, there will never be support for multiple browser tabs in Cypress (As per cypress's official documentation). - IS WHAT IS SAID ON GOOGLE ]

Screenshot 2023-10-25 at 1 57 41 pm Screenshot 2023-10-25 at 2 02 30 pm
henrygoodman commented 1 year ago

To this this feature, we want to:

(Test the URL encoding sets and loads initial state)

(Test encoded URL can load state in a fresh tab/browser)

srujankarthik commented 1 year ago

To this this feature, we want to:

(Test the URL encoding sets and loads initial state)

  • change any state, and then reload the page (with the same URL, so find a way to get the current URL with the state param included) and assert the state remains the same (font, text, sentiment stuff)

    • previously, reloading the page would return to / and wipe out any current state

(Test encoded URL can load state in a fresh tab/browser)

  • create a separate test with a predefined URL (create this manually), navigate to that new URL (this simulates opening a new tab) and then asserting the state is as expected
describe("Share URL", () => {
  it("Sharing URL feature", () => {
    cy.visit("/");

    cy.get("#inputted-text").type(
      "Machine learning (ML) is an umbrella term for solving problems for which development of algorithms by human programmers would be cost-prohibitive, and instead the problems are solved by helping machines discover their own algorithms, without needing to be explicitly told what to do by any human-developed algorithms. Recently, generative artificial neural networks have been able to surpass results of many previous approaches. Machine-learning approaches have been applied to large language models, computer vision, speech recognition, email filtering, agriculture and medicine, where it is too costly to develop algorithms to perform the needed tasks. The mathematical foundations of ML are provided by mathematical optimisation (mathematical programming) methods. Data mining is a related (parallel) field of study, focusing on exploratory data analysis through unsupervised learning.",
      { delay: 0 }
    );

    cy.get("#summarise-button-id").click();

    cy.visit(
      "/?state=N4IgLgpgHmCSB2AHArmEAuEIA0ICWSqAagIYA2yEGWuA7gPYBOAJgML3LxroAMuAzhC54AtkLAAVaGAAKZEgGMIAC3plmERtRwgII+mDz145KTDmKVajVsw7BwsVzPcaIB4adgAygqZVeXABrCABPBhZ+DGAAX1w9AyN4ABkSACMIMm0BTIgFSGYAMWNueGQyMhigA"
    );

    cy.visit("/");

    cy.url().should(
      "include",
      "state=N4IgLgpgHmCSB2AHArmEAuEIA0ICWSqAagIYA2yEGWuA7gPYBOAJgML3LxroAMuAzhC54AtkLAAVaGAAKZEgGMIAC3plmERtRwgII+mDz145KTDmKVajVsw7BwsVzPcaIB4adgAygqZVeXABrCABPBhZ+DGAAX1w9AyN4ABkSACMIMm0BTIgFSGYAMWNueGQyMhigA"
    );
  });
});

is this how you want it to be?