Skip to content

Commit

Permalink
Merge remote-tracking branch 'Emilio/vite-bugfix' into deployVite2
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyanthropos committed Apr 7, 2023
2 parents 7001361 + 33c4426 commit cfd2ab8
Show file tree
Hide file tree
Showing 960 changed files with 16,575 additions and 20,685 deletions.
23 changes: 13 additions & 10 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,28 @@

// Uncomment the next line to run commands after the container is created - for example installing curl.
"initializeCommand": "docker compose -f docker-compose.yml -f .devcontainer/docker-compose.extend.yml down",
"postCreateCommand": "npm install",
"postCreateCommand": "npm install && npx vite optimize",
// "postStartCommand": "",

// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "root",
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"ms-azuretools.vscode-docker",
"esbenp.prettier-vscode",
"styled-components.vscode-styled-components",
"meganrogge.template-string-converter",
"GitHub.vscode-pull-request-github",
"eamodio.gitlens",
"DotJoshJohnson.xml"
],
"dbaeumer.vscode-eslint",
"ms-azuretools.vscode-docker",
"esbenp.prettier-vscode",
"styled-components.vscode-styled-components",
"meganrogge.template-string-converter",
"GitHub.vscode-pull-request-github",
"eamodio.gitlens",
"DotJoshJohnson.xml",
"wix.vscode-import-cost",
"bmewburn.vscode-intelephense-client"
],
"settings": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"extensions.verifySignature": false
}
}
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/docker-compose.extend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ services:
environment:
- CYPRESS_CACHE_FOLDER=/home/node/workspace/.cache/Cypress
- SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
- NODE_OPTIONS=--max-old-space-size=4098
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
cap_add:
- SYS_PTRACE
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
./.cache/
./.devcontainer/
.env
./.git/
Expand Down
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');
});

})

})
Loading

0 comments on commit cfd2ab8

Please sign in to comment.