Skip to content

Commit

Permalink
Set up cypress tests (#2477)
Browse files Browse the repository at this point in the history
* allow test logins in dev mode
* submit share on blur
* cannot share with self
* change site header activity/assigned names
  • Loading branch information
dqnykamp authored Aug 20, 2024
1 parent 713b667 commit 965f321
Show file tree
Hide file tree
Showing 17 changed files with 459 additions and 494 deletions.
18 changes: 9 additions & 9 deletions client/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { defineConfig } from "cypress";

export default defineConfig({
numTestsKeptInMemory: 20,
defaultCommandTimeout: 30000,
defaultCommandTimeout: 10000,
e2e: {
setupNodeEvents(on, config) {
on("before:browser:launch", (browser = {}, launchOptions) => {
Expand All @@ -41,12 +41,12 @@ export default defineConfig({

baseUrl: "http://localhost:8000",
},
env: {
db: {
host: "localhost",
user: "root",
password: "helloworld",
database: "doenet_local",
},
},
// env: {
// db: {
// host: "localhost",
// user: "root",
// password: "helloworld",
// database: "doenet_local",
// },
// },
});
81 changes: 81 additions & 0 deletions client/cypress/e2e/Folders/createFolders.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
describe("Create Folders Tests", function () {
before(() => {});

beforeEach(() => {});

// TODO: this test is unfinished, but waiting until
// the folder UI redesign
it("create and share folder", () => {
let code = Date.now().toString();
const scrappyEmail = `scrappy${code}@doo`;
const scoobyEmail = `scooby${code}@doo`;

// create scrappy account so can share content with it
cy.loginAsTestUser({
email: scrappyEmail,
firstNames: "Scrappy",
lastNames: "Doo",
});

cy.loginAsTestUser({
email: scoobyEmail,
firstNames: "Scooby",
lastNames: "Doo",
});

cy.visit("/");

cy.get('[data-test="Activities"]').click();
cy.get('[data-test="New Button"]').click();
cy.get('[data-test="Add Folder Button"]').click();

cy.get('[data-test="Editable Title"]').type("My new folder{enter}");
cy.get('[data-test="Activity Link"]').click();

cy.get('[data-test="Folder Heading"]').should(
"contain.text",
"My new folder",
);

cy.get('[data-test="New Button"]').click();
cy.get('[data-test="Add Folder Button"]').click();
cy.get('[data-test="Editable Title"]').type(`Private folder${code}{enter}`);

cy.get('[data-test="New Button"]').click();
cy.get('[data-test="Add Folder Button"]').click();
cy.get('[data-test="Editable Title"]')
.eq(1)
.type(`Shared folder${code}{enter}`);

cy.get('[data-test="Card Menu Button"]').eq(1).click();
cy.get('[data-test="Share Menu Item"]').eq(1).click({ force: true });
cy.get('[data-test="Email address"]').type(`${scrappyEmail}{enter}`);
cy.get('[data-test="Status message"]').should("contain.text", scrappyEmail);
cy.get('[data-test="Close Share Drawer Button"]').click();

cy.get('[data-test="Activity Link"]').eq(1).click();
cy.get('[data-test="Folder Heading"]').should(
"contain.text",
`Shared folder${code}`,
);

cy.get('[data-test="New Button"]').click();
cy.get('[data-test="Add Activity Button"]').click();

cy.get('[data-test="Activity Name Editable"]').type(
"Shared activity{enter}",
);

cy.iframe().find(".cm-editor").type(`Hello${code}!{enter}`);
cy.iframe().find('[data-test="Viewer Update Button"]').click();
cy.iframe().find(".doenet-viewer").should("contain.text", `Hello${code}!`);

cy.loginAsTestUser({
email: scrappyEmail,
});
cy.visit("/");

cy.get('[data-test="Community"]').click();
cy.get('[data-test="Search"]').type(`folder${code}{enter}`);
});
});
Loading

0 comments on commit 965f321

Please sign in to comment.