Skip to content

Commit

Permalink
classification and sharing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp committed Dec 21, 2024
1 parent 58c53a2 commit 5e699d3
Show file tree
Hide file tree
Showing 13 changed files with 393 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
describe("Create Folders Tests", function () {
describe("Activity Editor Tests", function () {
it("correctly restore editor state after clicking view", () => {
// test bug where activity editor was not restoring itself with the correct state
// after one switched to view mode and back

cy.loginAsTestUser();

cy.createActivity("Hello!", "Initial content").then((activityId) => {
cy.createActivity({
activityName: "Hello!",
doenetML: "Initial content",
}).then((activityId) => {
cy.visit(`/activityEditor/${activityId}`);

cy.iframe()
Expand Down
60 changes: 60 additions & 0 deletions client/cypress/e2e/Activities/activityViewer.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
describe("Activity Viewer Tests", function () {
it("classifications shown in activity viewer", () => {
cy.loginAsTestUser();
cy.createActivity({
activityName: "Classifications!",
doenetML: "Hi!",
classifications: [
{
systemShortName: "WeBWorK",
category: "Algebra",
subCategory: "Factoring",
code: "Alg.F.2",
},
{
systemShortName: "Common Core",
category: "HS",
subCategory:
"Seeing Structure in Expressions. Write expressions in equivalent forms to solve problems.",
code: "A.SSE.3 a.",
},
],
}).then((activityId) => {
cy.visit(`/activityViewer/${activityId}`);

cy.get('[data-test="Classifications Footer"]').should(
"contain.text",
"Alg.F.2",
);
cy.get('[data-test="Classifications Footer"]').should(
"contain.text",
"A.SSE.3 a.",
);
cy.get('[data-test="Classifications Footer"]').click();

cy.get('[data-test="Classification 1"]').should(
"contain.text",
"A.SSE.3 a.",
);
cy.get('[data-test="Classification 2"]').should(
"contain.text",
"Alg.F.2",
);

cy.get('[data-test="Close Settings Button"]').click();
cy.get('[data-test="Classification 1"]').should("not.exist");

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

cy.get('[data-test="Classifications"]').click();
cy.get('[data-test="Classification 1"]').should(
"contain.text",
"A.SSE.3 a.",
);
cy.get('[data-test="Classification 2"]').should(
"contain.text",
"Alg.F.2",
);
});
});
});
38 changes: 38 additions & 0 deletions client/cypress/e2e/Activities/codeViewer.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
describe("Code Viewer Tests", function () {
it("classifications shown in code viewer", () => {
cy.loginAsTestUser();
cy.createActivity({
activityName: "Classifications!",
doenetML: "Hi!",
classifications: [
{
systemShortName: "WeBWorK",
category: "Algebra",
subCategory: "Factoring",
code: "Alg.F.2",
},
{
systemShortName: "Common Core",
category: "HS",
subCategory:
"Seeing Structure in Expressions. Write expressions in equivalent forms to solve problems.",
code: "A.SSE.3 a.",
},
],
}).then((activityId) => {
cy.visit(`/codeViewer/${activityId}`);

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

cy.get('[data-test="Classifications"]').click();
cy.get('[data-test="Classification 1"]').should(
"contain.text",
"A.SSE.3 a.",
);
cy.get('[data-test="Classification 2"]').should(
"contain.text",
"Alg.F.2",
);
});
});
});
4 changes: 2 additions & 2 deletions client/cypress/e2e/Activities/sharingActivities.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe("Share Activities Tests", function () {
cy.get('[data-test="Sharing Button"]').click();
cy.get('[data-test="Public Checkbox"]').click();
cy.get('[data-test="Status message"]').should(
"have.text",
"Successfully shared publicly",
"contain.text",
"shared publicly",
);

cy.get('[data-test="Close Share Drawer Button"]').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ describe("Classifications test", function () {
it("add classifications to activity", () => {
cy.loginAsTestUser();

cy.createActivity("Hello!", "Initial content").then((activityId) => {
cy.createActivity({
activityName: "Hello!",
doenetML: "Initial content",
}).then((activityId) => {
cy.visit(`/activityEditor/${activityId}`);

cy.get('[data-test="Settings Button"]').click();
Expand Down Expand Up @@ -87,7 +90,7 @@ describe("Classifications test", function () {

cy.get('[data-test="Add 9.2.3.3"]').should("not.exist");
cy.get('[data-test="Stop Filter By System').click();
cy.get('[data-test="Add 9.2.3.3"]').should("be.visible");
cy.get('[data-test="Add 9.2.3.3"]').scrollIntoView().should("be.visible");
});
});
});
170 changes: 170 additions & 0 deletions client/cypress/e2e/SettingsPanels/share.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
describe("Classifications test", function () {
it("cannot select incompatible license after remix, ShareAlike", () => {
let code = Date.now().toString();
const scrappyEmail = `scrappy${code}@doo`;
const scoobyEmail = `scooby${code}@doo`;

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

cy.createActivity({
activityName: "Share alike",
doenetML: "Shared with ShareAlike",
}).then((activityId) => {
cy.visit(`/activityEditor/${activityId}`);

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

cy.get('[data-test="Public Checkbox"]').click();
cy.get('[data-test="Status message"]').should(
"contain.text",
"shared publicly",
);

cy.get('[data-test="Select License"]').select(
"Creative Commons Attribution-ShareAlike 4.0",
);
cy.get('[data-test="Status message"]').should(
"contain.text",
"changed license",
);

cy.loginAsTestUser({
email: scrappyEmail,
firstNames: "Scrappy",
lastNames: "Doo",
});

cy.visit(`/activityViewer/${activityId}`);
cy.get('[data-test="Copy to Activities Button"]').click();
cy.get('[data-test="Go to Activities"]').click();

cy.get('[data-test="Card Menu Button"]').eq(0).click();
cy.get('[data-test="Share Menu Item"]').click();

cy.get('[data-test="Cannot Change License"]').should(
"contain.text",
"Creative Commons Attribution-ShareAlike 4.0",
);
cy.get('[data-test="Cannot Change License"]').should(
"contain.text",
"Cannot change license",
);
cy.get('[data-test="Select License"]').should("not.exist");
});
});

it("cannot select incompatible license after remix, NonCommercial-ShareAlike", () => {
let code = Date.now().toString();
const scrappyEmail = `scrappy${code}@doo`;
const scoobyEmail = `scooby${code}@doo`;

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

cy.createActivity({
activityName: "Non-commercial share alike",
doenetML: "Shared with NonCommercial-ShareAlike",
}).then((activityId) => {
cy.visit(`/activityEditor/${activityId}`);

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

cy.get('[data-test="Public Checkbox"]').click();
cy.get('[data-test="Status message"]').should(
"contain.text",
"shared publicly",
);

cy.get('[data-test="Select License"]').select(
"Creative Commons Attribution-NonCommercial-ShareAlike 4.0",
);
cy.get('[data-test="Status message"]').should(
"contain.text",
"changed license",
);

cy.loginAsTestUser({
email: scrappyEmail,
firstNames: "Scrappy",
lastNames: "Doo",
});

cy.visit(`/activityViewer/${activityId}`);
cy.get('[data-test="Copy to Activities Button"]').click();
cy.get('[data-test="Go to Activities"]').click();

cy.get('[data-test="Card Menu Button"]').eq(0).click();
cy.get('[data-test="Share Menu Item"]').click();

cy.get('[data-test="Cannot Change License"]').should(
"contain.text",
"Creative Commons Attribution-NonCommercial-ShareAlike 4.0",
);
cy.get('[data-test="Cannot Change License"]').should(
"contain.text",
"Cannot change license",
);
cy.get('[data-test="Select License"]').should("not.exist");
});
});

it("can select license after remix, Dual License", () => {
let code = Date.now().toString();
const scrappyEmail = `scrappy${code}@doo`;
const scoobyEmail = `scooby${code}@doo`;

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

cy.createActivity({
activityName: "Dual license",
doenetML: "Shared with Dual License",
}).then((activityId) => {
cy.visit(`/activityEditor/${activityId}`);

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

cy.get('[data-test="Public Checkbox"]').click();
cy.get('[data-test="Status message"]').should(
"contain.text",
"shared publicly",
);

cy.get('[data-test="Select License"]').should(
"contain.text",
"Dual license Creative Commons Attribution-ShareAlike 4.0 OR Attribution-NonCommercial-ShareAlike 4.0",
);

cy.loginAsTestUser({
email: scrappyEmail,
firstNames: "Scrappy",
lastNames: "Doo",
});

cy.visit(`/activityViewer/${activityId}`);
cy.get('[data-test="Copy to Activities Button"]').click();
cy.get('[data-test="Go to Activities"]').click();

cy.get('[data-test="Card Menu Button"]').eq(0).click();
cy.get('[data-test="Share Menu Item"]').click();

cy.get('[data-test="Select License"]').select(
"Creative Commons Attribution-ShareAlike 4.0",
);
cy.get('[data-test="Status message"]').should(
"contain.text",
"changed license",
);
});
});
});
41 changes: 39 additions & 2 deletions client/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,20 @@ declare global {
/**
* Custom command to create an activity for the logged in user
*/
createActivity(activityName: string, doenetML: string): Chainable<string>;
createActivity({
activityName,
doenetML,
classifications,
}: {
activityName: string;
doenetML: string;
classifications?: {
systemShortName: string;
category: string;
subCategory: string;
code: string;
}[];
}): Chainable<string>;
}
}
}
Expand Down Expand Up @@ -78,14 +91,38 @@ Cypress.Commands.add(

Cypress.Commands.add(
"createActivity",
(activityName: string, doenetML: string) => {
({
activityName,
doenetML,
classifications,
}: {
activityName: string;
doenetML: string;
classifications?: {
systemShortName: string;
category: string;
subCategory: string;
code: string;
}[];
}) => {
cy.request({
method: "POST",
url: "/api/createActivity",
}).then((resp) => {
let activityId: string = resp.body.activityId;
let docId: string = resp.body.docId;

if (classifications) {
cy.request({
method: "POST",
url: "/api/test/addClassificationsByNames",
body: {
id: activityId,
classifications,
},
});
}

cy.request({
method: "POST",
url: "/api/updateContentName",
Expand Down
3 changes: 2 additions & 1 deletion client/src/Tools/_framework/Paths/ActivityViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export function ActivityViewer() {
colorScheme="blue"
icon={<MdOutlineInfo />}
aria-label="Activity information"
data-test="Activity Information"
onClick={() => {
setDisplayInfoTab("general");
infoOnOpen();
Expand Down Expand Up @@ -352,7 +353,7 @@ export function ActivityViewer() {
}}
>
<Heading size="sm">Classifications</Heading>
<List>
<List data-test="Classifications Footer">
{activity.classifications.map((classification) => {
return (
<Tooltip label={classification.description}>
Expand Down
Loading

0 comments on commit 5e699d3

Please sign in to comment.