Skip to content

Commit

Permalink
dark mode support in core styles and test environments (Doenet#2006)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp authored Apr 4, 2023
1 parent bd04a17 commit 541f71f
Show file tree
Hide file tree
Showing 178 changed files with 9,894 additions and 7,979 deletions.
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = defineConfig({
on('task', { queryDb: query => { return queryTestDb(query, config) }, }); //For running sql query
},

baseUrl: 'http://localhost',
baseUrl: 'http://localhost:8000',
},
env: {
db: {
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/ActivityViewer/activityVariants.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Activity variants tests', function () {

beforeEach(() => {
cy.clearIndexedDB();
cy.visit('/cypressTest')
cy.visit('/src/Tools/cypressTest/')
})


Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/ActivityViewer/compiledActivity.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Compiled activity tests', function () {

beforeEach(() => {
cy.clearIndexedDB();
cy.visit('/cypressTest')
cy.visit('/src/Tools/cypressTest/')
})


Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/ActivityViewer/relationshipsAmongPages.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Relationships among pages tests', function () {

beforeEach(() => {
cy.clearIndexedDB();
cy.visit('/cypressTest')
cy.visit('/src/Tools/cypressTest/')
})

it("Problem numbering continues across pages", () => {
Expand Down
34 changes: 17 additions & 17 deletions cypress/e2e/AsStudent/assignedActivity.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('Assigned Activity Tests', function () {
const doenetId = "activity1id";
const pageDoenetId = "_page1id";

before(()=>{
before(() => {
cy.signin({ userId });
cy.clearAllOfAUsersCoursesAndItems({ userId });
cy.clearAllOfAUsersCoursesAndItems({ userId: studentUserId });
Expand All @@ -16,8 +16,8 @@ describe('Assigned Activity Tests', function () {
cy.clearIndexedDB();
cy.clearAllOfAUsersActivities({ userId });
cy.clearAllOfAUsersActivities({ userId: studentUserId });
cy.createActivity({ courseId, doenetId, parentDoenetId:courseId, pageDoenetId });
cy.visit(`http://localhost/course?tool=editor&doenetId=${doenetId}&pageId=${pageDoenetId}`);
cy.createActivity({ courseId, doenetId, parentDoenetId: courseId, pageDoenetId });
cy.visit(`/course?tool=editor&doenetId=${doenetId}&pageId=${pageDoenetId}`);
})


Expand All @@ -30,12 +30,12 @@ describe('Assigned Activity Tests', function () {

// Formatting the date to be 'mm/dd/yyyy' WITH leading zeros
// Ex: '09/12/2022' for September 12, 2022
function formatDateWithYear(date,prefixZero) {
function formatDateWithYear(date, prefixZero) {
const yyyy = date.getFullYear();
let mm = date.getMonth() + 1; // Months start at 0!
let dd = date.getDate();
if (mm < 10) mm = '0' + mm;
if (prefixZero){
if (prefixZero) {
if (mm < 10) mm = '0' + mm;
if (dd < 10) dd = '0' + dd;
}

Expand All @@ -52,7 +52,7 @@ describe('Assigned Activity Tests', function () {
}

function getDayOfWeek(date) {
const weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
const weekday = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
return weekday[date.getDay()];
}

Expand Down Expand Up @@ -82,30 +82,30 @@ describe('Assigned Activity Tests', function () {
return hr + ':' + min + ' ' + ampm;
}


it('Activity contains due date in Content page', () => {

const assignedDate = new Date();
let dueDate = new Date(assignedDate.getTime() + 7 * 24 * 60 * 60 * 1000); // One week from now
dueDate.setSeconds(0); //To prevent rounding up false tests

// Update the activity as the owner
cy.get('[data-test="AssignmentSettingsMenu Menu"]').click();
cy.get('[data-test="Due Date Checkbox"]').click();
cy.get('[data-test="Due Date"]').should('have.value', formatDateWithYear(dueDate,true) + ' ' + formatTime(dueDate));
cy.get('[data-test="Due Date"]').should('have.value', formatDateWithYear(dueDate, true) + ' ' + formatTime(dueDate));
cy.get('[data-test="Assigned Date Checkbox"]').click();
cy.get('[data-test="Assign Activity"]').click();
cy.get('[data-test="Unassign Activity"]').should('be.visible'); //Wait for activity to be saved

// Sign in as a student
cy.signin({ userId: studentUserId });
cy.visit(`http://localhost/course?tool=navigation&courseId=${courseId}`)
cy.visit(`/course?tool=navigation&courseId=${courseId}`)

// Check if the Content page contains the correct activity with the due date
cy.get('.navigationRow').should('have.length', 1); // Need this to wait for the row to appear
cy.get('[data-test="rowLabel"]').contains('Cypress Activity');
cy.get('.navigationRow').eq(0).get('.navigationColumn2').contains(formatDateWithYear(dueDate,false) + ', ' + formatHours(dueDate) + ':' + formatMinutes(dueDate) + ':00');
cy.get('.navigationRow').eq(0).get('.navigationColumn2').contains(formatDateWithYear(dueDate, false) + ', ' + formatHours(dueDate) + ':' + formatMinutes(dueDate) + ':00');

})


Expand All @@ -117,23 +117,23 @@ describe('Assigned Activity Tests', function () {
// Update the activity as the owner
cy.get('[data-test="AssignmentSettingsMenu Menu"]').click();
cy.get('[data-test="Assigned Date Checkbox"]').click();
cy.get('[data-test="Assigned Date"]').should('have.value', formatDateWithYear(assignedDate,true) + ' ' + formatTime(assignedDate));
cy.get('[data-test="Assigned Date"]').should('have.value', formatDateWithYear(assignedDate, true) + ' ' + formatTime(assignedDate));
cy.get('[data-test="Due Date Checkbox"]').click();
cy.get('[data-test="Due Date"]').should('have.value', formatDateWithYear(dueDate,true) + ' ' + formatTime(dueDate));
cy.get('[data-test="Due Date"]').should('have.value', formatDateWithYear(dueDate, true) + ' ' + formatTime(dueDate));
cy.get('[data-test="Assign Activity"]').click();
cy.get('[data-test="Unassign Activity"]').should('be.visible'); //Wait for activity to be saved


// Sign in as a student
// Check if the Content By Week page contains the correct activity with the assigned date and due date
cy.signin({ userId: studentUserId });
cy.visit(`http://localhost/course?tool=dashboard&courseId=${courseId}`);
cy.visit(`/course?tool=dashboard&courseId=${courseId}`);
cy.get('[data-test="next week button"]').click();
cy.get('table').should('have.length', 1); // Need this to wait for the row to appear
cy.get('[data-test="cbw assignment label 0"]').contains('Cypress Activity');
cy.get('[data-test="cbw assigned date 0"]').contains(formatDateWithoutYear(assignedDate) + ' ' + formatTime(assignedDate)); // Add the 'M' back to AM/PM
cy.get('[data-test="cbw due date 0"]').contains(formatDateWithoutYear(dueDate) + ' ' + formatTime(dueDate));

})

})
13 changes: 6 additions & 7 deletions cypress/e2e/AsStudent/previousAndNext.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('Previous and Next Activty Button Tests', () => {
});
if (isAssigned) {
cy.visit(
`http://localhost/course?tool=editor&doenetId=${doenetId}&pageId=${`_pageDoenetId${i}.1`}`,
`/course?tool=editor&doenetId=${doenetId}&pageId=${`_pageDoenetId${i}.1`}`,
);
cy.get('[data-test="AssignmentSettingsMenu Menu"]')
.should('be.visible')
Expand All @@ -150,7 +150,7 @@ describe('Previous and Next Activty Button Tests', () => {

it('Next button goes to from first to second', () => {
cy.visit(
`http://localhost/course?tool=assignment&doenetId=${genIdsInContnetOrder[0].doenetId}&pageId=${genIdsInContnetOrder[0].firstPageId}`,
`/course?tool=assignment&doenetId=${genIdsInContnetOrder[0].doenetId}&pageId=${genIdsInContnetOrder[0].firstPageId}`,
);
cy.get('[data-test="Previous Activity Button"]').should('be.disabled');
cy.get('[data-test="Next Activity Button"]').should('be.enabled').click();
Expand All @@ -161,7 +161,7 @@ describe('Previous and Next Activty Button Tests', () => {

it('Previous button goes to from second to first', () => {
cy.visit(
`http://localhost/course?tool=assignment&doenetId=${genIdsInContnetOrder[1].doenetId}&pageId=${genIdsInContnetOrder[1].firstPageId}`,
`/course?tool=assignment&doenetId=${genIdsInContnetOrder[1].doenetId}&pageId=${genIdsInContnetOrder[1].firstPageId}`,
);
cy.get('[data-test="Next Activity Button"]').should('be.enabled');
cy.get('[data-test="Previous Activity Button"]')
Expand All @@ -178,15 +178,15 @@ describe('Previous and Next Activty Button Tests', () => {
);
expect(procIdx).to.not.equal(-1);
cy.visit(
`http://localhost/course?tool=assignment&doenetId=${genIdsInContnetOrder[procIdx].doenetId}&pageId=${genIdsInContnetOrder[procIdx].firstPageId}`,
`/course?tool=assignment&doenetId=${genIdsInContnetOrder[procIdx].doenetId}&pageId=${genIdsInContnetOrder[procIdx].firstPageId}`,
);
cy.get('[data-test="Next Activity Button"]').should('be.disabled');
cy.get('[data-test="Previous Activity Button"]').should('be.disabled');
});

it('Next button from first to last, skipping unassigned', () => {
cy.visit(
`http://localhost/course?tool=assignment&doenetId=${genIdsInContnetOrder[0].doenetId}&pageId=${genIdsInContnetOrder[0].firstPageId}`,
`/course?tool=assignment&doenetId=${genIdsInContnetOrder[0].doenetId}&pageId=${genIdsInContnetOrder[0].firstPageId}`,
);
cy.get('[data-test="Previous Activity Button"]').should('be.disabled');
let i;
Expand All @@ -210,8 +210,7 @@ describe('Previous and Next Activty Button Tests', () => {

it('Previous button goes to from last to first, skipping unassigned and proctored', () => {
cy.visit(
`http://localhost/course?tool=assignment&doenetId=${
genIdsInContnetOrder[activityOptions.length - 1].doenetId
`/course?tool=assignment&doenetId=${genIdsInContnetOrder[activityOptions.length - 1].doenetId
}&pageId=${genIdsInContnetOrder[activityOptions.length - 1].firstPageId}`,
);
cy.get('[data-test="Next Activity Button"]').should('be.disabled');
Expand Down
90 changes: 45 additions & 45 deletions cypress/e2e/AsStudent/signIn.cy.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
describe('Student Sign-In Test', function () {
const userId = "cyuserId";
// const studentUserId = "cyStudentUserId";
const courseId = "courseid1";
// const doenetId = "activity1id";
// const pageDoenetId = "_page1id";
before(()=>{
cy.signin({ userId });
cy.clearAllOfAUsersCoursesAndItems({ userId });
const userId = "cyuserId";
// const studentUserId = "cyStudentUserId";
const courseId = "courseid1";
// const doenetId = "activity1id";
// const pageDoenetId = "_page1id";

before(() => {
cy.signin({ userId });
cy.clearAllOfAUsersCoursesAndItems({ userId });
// cy.clearAllOfAUsersCoursesAndItems({ userId: studentUserId });
cy.createCourse({ userId, courseId });
})
beforeEach(() => {
cy.signin({ userId });
cy.clearIndexedDB();
cy.clearAllOfAUsersActivities({ userId });
cy.createCourse({ userId, courseId });
})
beforeEach(() => {
cy.signin({ userId });
cy.clearIndexedDB();
cy.clearAllOfAUsersActivities({ userId });
// cy.clearAllOfAUsersActivities({ userId: studentUserId });
// cy.createActivity({ courseId, doenetId, parentDoenetId:courseId, pageDoenetId });
cy.visit(`http://localhost/course?tool=people&courseId=${courseId}`);
})
Cypress.on('uncaught:exception', (err, runnable) => {
// Returning false here prevents Cypress from failing the test
return false;
})
it('Student can sign in after being added to a course', () => {
const emailAddress = "[email protected]";
cy.get('[data-test="First"]').type("Scooby");
cy.get('[data-test="Last"]').type("Doo");
cy.get('[data-test="Email"]').type(emailAddress);
cy.get('[data-test="Add User"]').click();
cy.visit(`http://localhost/settings`)
cy.get('[data-test="sign out button"]').click();
cy.get('[data-test="homepage button"]').should('be.visible');
cy.visit(`http://localhost/SignIn`)
cy.get('[data-test="email input"]').type(emailAddress);
cy.get('[data-test="sendEmailButton"]').click();
cy.task('queryDb', `SELECT signInCode FROM user_device ORDER BY id DESC LIMIT 1`).then((result)=>{
const code = result[0].signInCode;
cy.get('[data-test="signinCodeInput"]').type(code);
cy.get('[data-test="signInButton"]').click();
cy.get('[data-test="Nav to course"]').should('be.visible');
});
})
cy.visit(`/course?tool=people&courseId=${courseId}`);
})


Cypress.on('uncaught:exception', (err, runnable) => {
// Returning false here prevents Cypress from failing the test
return false;
})


it('Student can sign in after being added to a course', () => {
const emailAddress = "[email protected]";
cy.get('[data-test="First"]').type("Scooby");
cy.get('[data-test="Last"]').type("Doo");
cy.get('[data-test="Email"]').type(emailAddress);
cy.get('[data-test="Add User"]').click();
cy.visit(`/settings`)
cy.get('[data-test="sign out button"]').click();
cy.get('[data-test="homepage button"]').should('be.visible');
cy.visit(`/SignIn`)
cy.get('[data-test="email input"]').type(emailAddress);
cy.get('[data-test="sendEmailButton"]').click();
cy.task('queryDb', `SELECT signInCode FROM user_device ORDER BY id DESC LIMIT 1`).then((result) => {
const code = result[0].signInCode;
cy.get('[data-test="signinCodeInput"]').type(code);
cy.get('[data-test="signInButton"]').click();
cy.get('[data-test="Nav to course"]').should('be.visible');
});

})

})
12 changes: 6 additions & 6 deletions cypress/e2e/AssignedActivity/creditAchievedMenu.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Credit achieved menu tests', function () {

cy.createActivity({ courseId, doenetId, parentDoenetId: courseId, pageDoenetId, doenetML });

cy.visit(`http://localhost/course?tool=navigation&courseId=${courseId}`)
cy.visit(`/course?tool=navigation&courseId=${courseId}`)

cy.get('.navigationRow').should('have.length', 1); //Need this to wait for the row to appear
cy.get('.navigationRow').eq(0).get('.navigationColumn1').click();
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('Credit achieved menu tests', function () {
doenetML1, doenetML2, doenetML3, doenetML4
});

cy.visit(`http://localhost/course?tool=navigation&courseId=${courseId}`)
cy.visit(`/course?tool=navigation&courseId=${courseId}`)

cy.get('.navigationRow').should('have.length', 1); //Need this to wait for the row to appear
cy.get('.navigationRow').eq(0).get('.navigationColumn1').click();
Expand Down Expand Up @@ -194,7 +194,7 @@ describe('Credit achieved menu tests', function () {
doenetML1, doenetML2, doenetML3, doenetML4
});

cy.visit(`http://localhost/course?tool=navigation&courseId=${courseId}`)
cy.visit(`/course?tool=navigation&courseId=${courseId}`)

cy.get('.navigationRow').should('have.length', 1); //Need this to wait for the row to appear
cy.get('.navigationRow').eq(0).get('.navigationColumn1').click();
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('Credit achieved menu tests', function () {
doenetML1, doenetML2, doenetML3, doenetML4
});

cy.visit(`http://localhost/course?tool=navigation&courseId=${courseId}`)
cy.visit(`/course?tool=navigation&courseId=${courseId}`)

cy.get('.navigationRow').should('have.length', 1); //Need this to wait for the row to appear
cy.get('.navigationRow').eq(0).get('.navigationColumn1').click();
Expand Down Expand Up @@ -388,7 +388,7 @@ describe('Credit achieved menu tests', function () {
doenetML1, doenetML2, doenetML3
});

cy.visit(`http://localhost/course?tool=navigation&courseId=${courseId}`)
cy.visit(`/course?tool=navigation&courseId=${courseId}`)

cy.get('.navigationRow').should('have.length', 1); //Need this to wait for the row to appear
cy.get('.navigationRow').eq(0).get('.navigationColumn1').click();
Expand Down Expand Up @@ -486,7 +486,7 @@ describe('Credit achieved menu tests', function () {
doenetML1, doenetML2, doenetML3
});

cy.visit(`http://localhost/course?tool=navigation&courseId=${courseId}`)
cy.visit(`/course?tool=navigation&courseId=${courseId}`)

cy.get('.navigationRow').should('have.length', 1); //Need this to wait for the row to appear
cy.get('.navigationRow').eq(0).get('.navigationColumn1').click();
Expand Down
Loading

0 comments on commit 541f71f

Please sign in to comment.