Skip to content

Commit

Permalink
Merge pull request #405 from sandboxnu/dc-limbo-fsm
Browse files Browse the repository at this point in the history
Priority Queue
  • Loading branch information
NEUDitao committed Nov 14, 2020
2 parents 66c419d + ea3bae2 commit aa72ed8
Show file tree
Hide file tree
Showing 37 changed files with 1,479 additions and 427 deletions.
70 changes: 35 additions & 35 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -12,7 +12,7 @@ on:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 17 * * 4'
- cron: "0 17 * * 4"

jobs:
analyze:
Expand All @@ -24,48 +24,48 @@ jobs:
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['javascript']
language: ["javascript"]
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yml
Expand Up @@ -28,7 +28,7 @@ jobs:
record: ${{ github.event_name == 'pull_request' }}
start: yarn ci:start
wait-on: "http://localhost:3000"
command-prefix: 'yarn run percy exec'
command-prefix: "yarn run percy exec"
env:
CYPRESS_USE_LIVE_API: true
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Expand Up @@ -33,7 +33,7 @@ jobs:
## Ensure no new changes have been pushed in the time we spent building
- run: git fetch && echo "::set-output name=version::$(git rev-parse origin/master)"
id: post-version
- if: steps.pre-version.outputs.version == steps.post-version.outputs.version
- if: steps.pre-version.outputs.version == steps.post-version.outputs.version
uses: EndBug/add-and-commit@v4
with:
add: "packages"
Expand Down
141 changes: 141 additions & 0 deletions cypress/integration/student/cant_find_test.spec.js
@@ -0,0 +1,141 @@
describe("can't be found", () => {
beforeEach(() => {
// Set the state
cy.request("POST", "/api/v1/seeds/createUser", { role: "student" })
.then((res) => res.body)
.as("student");

cy.get("@student").then((student) => {
cy.request("POST", "/api/v1/seeds/createQueue", {
courseId: student.course.id,
allowQuestions: true,
})
.then((res) => res.body)
.as("queue");
});

//creates TA
cy.get("@student").then((student) => {
cy.request("POST", "/api/v1/seeds/createUser", {
role: "ta",
courseId: student.course.id,
})
.then((res) => res.body)
.as("ta");
});

cy.get("@queue").then((queue) => {
cy.get("@ta").then((ta) => {
cy.visit(`/api/v1/login/dev?userId=${ta.user.id}`);

// Check the TA into the queue
cy.request(
"POST",
`/api/v1/courses/${queue.course.id}/ta_location/${queue.room}`
);
});
});

// Login the student
cy.get("@student").then((student) => {
cy.visit(`/api/v1/login/dev?userId=${student.user.id}`);
});

// Visit the queue page and create a question
cy.get("@queue").then((queue) =>
cy.visit(`/course/${queue.courseId}/queue/${queue.id}`).then(() => {
// Click "Join Queue"
cy.get("body").should("contain", "Join Queue");
cy.get('[data-cy="join-queue-button"]').click();

// Fill out the question form
cy.get("body").should("contain", "Concept");
cy.get("label").contains("Concept").click({
force: true,
});
cy.get("[data-cy='questionText']").type(
"How do I use the design recipe?"
);

// Click Submit
cy.get("[data-cy='finishQuestion']").click();
})
);

//TA opens the student's question
cy.get("@queue").then((queue) => {
cy.get("@ta").then((ta) => {
cy.visit(`/api/v1/login/dev?userId=${ta.user.id}`);

cy.get(".ant-modal-close-x").click();
// Visit the queue page
cy.visit(`/course/${queue.courseId}/queue/${queue.id}`);
});
});
});

it("Can't find student and student leaves the queue", () => {
cy.get("@queue").then((queue) => {
cy.get("@ta").then((ta) => {
cy.get("body").should("contain", "Help Next");
cy.get("button").contains("Help Next").click();

// Click Can't Find
cy.get("body").should("contain", "Can't Find");
cy.get("button").contains("Can't Find").click();

cy.get("body").should("contain", "Yes");
cy.get("button").contains("Yes").click();
});
});

// Login the student
cy.get("@student").then((student) => {
cy.visit(`/api/v1/login/dev?userId=${student.user.id}`);
});
cy.get("@queue").then((queue) =>
cy.visit(`course/${queue.courseId}/queue/${queue.id}`).then(() => {
cy.get("body").should(
"contain",
"A TA tried to help you, but couldn't reach you. Are you still in the queue? If you are, make sure you have Teams open, and rejoin the queue."
);

//cy.get(".ant-modal").should("contain", "Leave Queue");
cy.get("button").contains("Leave Queue").click();
})
);
});

it("Can't find student and student rejoins the queue", () => {
cy.get("@queue").then((queue) => {
cy.get("@ta").then((ta) => {
cy.get("body").should("contain", "Help Next");
cy.get("button").contains("Help Next").click();
// Click Can't Find
cy.get("body").should("contain", "Can't Find");
cy.get("button").contains("Can't Find").click();

cy.get("body").should("contain", "Yes");
cy.get("button").contains("Yes").click();
});
});

// Login the student
cy.get("@student").then((student) => {
cy.visit(`/api/v1/login/dev?userId=${student.user.id}`);
});
cy.get("@queue").then((queue) =>
cy.visit(`course/${queue.courseId}/queue/${queue.id}`).then(() => {
cy.get("body").should(
"contain",
"A TA tried to help you, but couldn't reach you. Are you still in the queue? If you are, make sure you have Teams open, and rejoin the queue."
);

cy.get("button").contains("Rejoin Queue").click();
cy.contains(
"You are now in a priority queue, you will be helped soon. You were last helped by User."
);
})
);
});
});
Expand Up @@ -98,15 +98,17 @@ describe("Removed from queue", () => {
cy.visit(`course/${queue.courseId}/queue/${queue.id}`).then(() => {
cy.get("body").should(
"contain",
"You've been removed from the queue by a TA. If you have any questions, please reach out to the TA. If you'd like to join back into the queue with your previous question, click Rejoin Queue, otherwise click Leave Queue."
"A TA tried to help you, but couldn't reach you. Are you still in the queue? If you are, make sure you have Teams open, and rejoin the queue."
);

cy.get("body").should("contain", "Rejoin Queue");
cy.percySnapshot("Student Queue Page - Rejoin Queue Modal");
cy.get("button").contains("Rejoin Queue").click();

// Check that the student was sucessfully but back into the queue
cy.contains("You are 1st");
cy.contains(
"You are now in a priority queue, you will be helped soon. You were last helped by User."
);
})
);
});
Expand Down Expand Up @@ -144,69 +146,4 @@ describe("Removed from queue", () => {
})
);
});

/*
it("Can't find student and student leaves the queue", () => {
cy.get("@queue").then((queue) => {
cy.get("@ta").then((ta) => {
// Click Can't Find
cy.get("body").should("contain", "Can't Find");
cy.get("button").contains("Can't Find").click();
cy.get("body").should("contain", "Yes");
cy.get("button").contains("Yes").click();
});
});
// Login the student
cy.get("@student").then((student) => {
cy.visit(`/api/v1/login/dev?userId=${student.user.id}`);
});
cy.get("@queue").then((queue) =>
cy.visit(`course/${queue.courseId}/queue/${queue.id}`).then(() => {
cy.get("body").should(
"contain",
"A TA tried to help you, but couldn't reach you. Are you still in the queue? If you are, make sure you have Teams open, and rejoin the queue."
);
//cy.get(".ant-modal").should("contain", "Leave Queue");
cy.get("button").contains("Leave Queue").click();
})
);
});
it("Can't find student and student rejoins the queue", () => {
cy.get("@queue").then((queue) => {
cy.get("@ta").then((ta) => {
// Click Can't Find
cy.get("body").should("contain", "Can't Find");
cy.get("button").contains("Can't Find").click();
cy.get("body").should("contain", "Yes");
cy.get("button").contains("Yes").click();
});
});
// Login the student
cy.get("@student").then((student) => {
cy.visit(`/api/v1/login/dev?userId=${student.user.id}`);
});
cy.get("@queue").then((queue) =>
cy.visit(`course/${queue.courseId}/queue/${queue.id}`).then(() => {
cy.get("body").should(
"contain",
"A TA tried to help you, but couldn't reach you. Are you still in the queue? If you are, make sure you have Teams open, and rejoin the queue."
);
//cy.get("body").should("contain", "Rejoin Queue");
cy.get("button").contains("Rejoin Queue").click();
})
);
});
*/
});

1 comment on commit aa72ed8

@vercel
Copy link

@vercel vercel bot commented on aa72ed8 Nov 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.