Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#716 | [TASK]: Refactor Multiplayer & Typing Logic #721

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bdd3949
refactored wss, client that interacts with wss
Ragudos Sep 6, 2023
ff2b1ca
fix type errors
Ragudos Sep 6, 2023
20eab7c
fix to type errors (i think it's import aliases)
Ragudos Sep 6, 2023
92b9097
added proper memory (no db yet), refactor roompage
Ragudos Sep 6, 2023
e998545
refactor room creation lifecycle, need fix bug
Ragudos Sep 7, 2023
6ccbecc
room owner, game countdown, statushandling
Ragudos Sep 8, 2023
d311979
just ran format using prettier, added raceDispatch
Ragudos Sep 8, 2023
41a3e99
refactored typing logic and practice room
Ragudos Sep 9, 2023
c326928
organizing folders in results && prettier
Ragudos Sep 9, 2023
72b316f
refactored racefunctionality, removed topten
Ragudos Sep 9, 2023
cc66e43
implemented memory abstraction
Ragudos Sep 9, 2023
5bdf86d
incorporated implemented store to game
Ragudos Sep 10, 2023
16755b8
fixed bugs & cleaned room handling
Ragudos Sep 10, 2023
93c299d
(untested) typing realtime, fix replaybug
Ragudos Sep 10, 2023
abe0b1f
fix: socket.id undefined on room creation
Ragudos Sep 11, 2023
905d845
added progress tracking multiplayer
Ragudos Sep 11, 2023
50e3387
added waiting screen for finsihedplayer
Ragudos Sep 11, 2023
d11cab0
finished multiplayer feature prototype
Ragudos Sep 11, 2023
9e8f2c9
multiplayer now hidden on prod
Ragudos Sep 11, 2023
12fd38a
hide likedislike on anonymous user
Ragudos Sep 11, 2023
8c50b7d
docs and some cleaning on game.ts
Ragudos Sep 12, 2023
d316c8a
fix: not removing runninggame on dc
Ragudos Sep 12, 2023
1b306ff
fix: bug game full on game reset
Ragudos Sep 12, 2023
30af8ef
added force dc on server
Ragudos Sep 12, 2023
3f80b6c
fix formatting errors on readme
Ragudos Sep 12, 2023
2333ac5
fix: proper formula for cpm
Ragudos Sep 12, 2023
fe4fd87
Merge branch 'refactor-multiplayer' of https://github.com/Ragudos/cod…
Ragudos Sep 21, 2023
2383275
fix type errors
Ragudos Sep 21, 2023
58531ff
added type for previousNode
Ragudos Sep 21, 2023
48b7cc1
fix minor bugs
Ragudos Sep 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"dev:db": "npm run db --workspace @code-racer/app",
"dev:wss": "cross-env PORT=3001 npm run dev --workspace @code-racer/wss",
"deploy:wss": "source packages/wss/.env && fly deploy --build-arg DATABASE_URL=$DATABASE_URL --config packages/wss/fly.toml --dockerfile packages/wss/Dockerfile",
"pr:precheck": "npm run lint -w @code-racer/app && npm run type-check -w @code-racer/app && npm run build -w @code-racer/app"
"pr:precheck": "npm run lint -w @code-racer/app && npm run type-check -w @code-racer/app && npm run build -w @code-racer/app",
"format:write": "echo 'Formatting app' && npm run format:write --workspace @code-racer/app && echo 'Formatting server...' && npm run format:write --workspace @code-racer/wss",
"e2e:app": "npm run e2e --workspace @code-racer/app"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"quotes": ["error", "double", { "allowTemplateLiterals": true }],
"react/react-in-jsx-scope": "off",
"jsx-a11y/anchor-is-valid": "off",
"no-unused-vars": "warn",
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-explicit-any": "warn",

Expand Down
7 changes: 7 additions & 0 deletions packages/app/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,11 @@ export default defineConfig({
baseUrl: "http://localhost:3000",
scrollBehavior: "center",
},

component: {
devServer: {
framework: "next",
bundler: "webpack",
},
},
});
4 changes: 2 additions & 2 deletions packages/app/cypress/component/TestComponentName.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe("ComponentName.cy.tsx", () => {
it("playground", () => {
// cy.mount()
})
})
});
});
63 changes: 31 additions & 32 deletions packages/app/cypress/e2e/business-layer/raceBL.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
import { RacePage } from "../page-objects/pages/RacePage";
export class RaceBL {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public static runTypingRace(spans: any): RacePage{
const NEW_LINE = "⏎\n";
let code = "";
let isIndentWhiteSpace = false;
for (let i = 0; i < spans.length; i++) {
const char = spans[i].innerText;
if (char !== " " && isIndentWhiteSpace) {
// Encounter non-whitespace character when isIndentWhiteSpace=true
// Unset isIndentWhiteSpace back to false
isIndentWhiteSpace = false;
}
if (char === " " && isIndentWhiteSpace) {
continue;
}
code += char === NEW_LINE ? "\n" : char;
if (char === NEW_LINE) {
// When we encounter new line, the following whitespace up to
// encounting non-whitespace character will be considered indent whitespace.
// Since our app auto indent, we don't type it
isIndentWhiteSpace = true;
}
}
cy.get("[data-cy=\"race-practice-input\"]").type(code, {
force: true,
parseSpecialCharSequences: false,
delay: 30,
waitForAnimations: true,
});
return new RacePage();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public static runTypingRace(spans: Array<HTMLSpanElement>): RacePage {
const NEW_LINE = "⏎\n";
let code = "";
let isIndentWhiteSpace = false;
for (let i = 0; i < spans.length; ++i) {
const char = spans[i].innerText;
if (char !== " " && isIndentWhiteSpace) {
// Encounter non-whitespace character when isIndentWhiteSpace=true
// Unset isIndentWhiteSpace back to false
isIndentWhiteSpace = false;
}
if (char === " " && isIndentWhiteSpace) {
continue;
}
code += char === NEW_LINE ? "\n" : char;
if (char === NEW_LINE) {
// When we encounter new line, the following whitespace up to
// encounting non-whitespace character will be considered indent whitespace.
// Since our app auto indent, we don't type it
isIndentWhiteSpace = true;
}
}
}
cy.get("[data-cy='race-practice-input']").type(code, {
force: true,
parseSpecialCharSequences: false,
delay: 30,
waitForAnimations: true,
});
return new RacePage();
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { siteConfig } from "../../../../src/config/site";
const headerLinks = siteConfig.getHeaderLinks(false);
export class NavbarComponent {
race(): Cypress.Chainable {
return cy.get("[data-cy='Race-main-nav-link']");
}

race(): Cypress.Chainable{ return cy.get(`[data-cy="${
headerLinks.find((e) => e.title.includes("Race"))?.title ?? "Race"
}-main-nav-link"]`,
)}

leaderboard(): Cypress.Chainable{ return cy.get(`[data-cy="${
headerLinks.find((e) => e.title.includes("Leaderboard"))?.title ?? "Leaderboard"
}-main-nav-link"]`,
)}
}
leaderboard(): Cypress.Chainable {
return cy.get("[data-cy='Leaderboard-main-nav-link']");
}
}
29 changes: 19 additions & 10 deletions packages/app/cypress/e2e/page-objects/pages/ContributorsPage.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
export class ContributorsPage{
export class ContributorsPage {
contributorCard(): Cypress.Chainable {
return cy.get('[data-cy="contributor-card"]');
}
contributorName(): Cypress.Chainable {
return cy.get('[data-cy="contributor-name"]');
}
commitDisplay(): Cypress.Chainable {
return cy.get('[data-cy="github-commit-display"]');
}
commitLink(): Cypress.Chainable {
return cy.get('[data-cy="github-commit-link"]');
}

contributorCard(): Cypress.Chainable{ return cy.get("[data-cy=\"contributor-card\"]") }
contributorName(): Cypress.Chainable{ return cy.get("[data-cy=\"contributor-name\"]") }
commitDisplay(): Cypress.Chainable{ return cy.get("[data-cy=\"github-commit-display\"]") }
commitLink(): Cypress.Chainable{ return cy.get("[data-cy=\"github-commit-link\"]") }

public contributorCardText(contributorCard: Cypress.Chainable): Cypress.Chainable{
return contributorCard.find("[data-cy=\"contributor-name\"]").invoke("text")
}
}
public contributorCardText(
contributorCard: Cypress.Chainable
): Cypress.Chainable {
return contributorCard.find('[data-cy="contributor-name"]').invoke("text");
}
}
21 changes: 14 additions & 7 deletions packages/app/cypress/e2e/page-objects/pages/LeaderboardPage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
export class LeaderboardPage{
export class LeaderboardPage {
userRow(): Cypress.Chainable {
return cy.get(".table-row");
}
user(): Cypress.Chainable {
return cy.get(".flex.items-center.gap-2");
}
rowDropdown(): Cypress.Chainable {
return cy.get('[role="combobox"]');
}

userRow(): Cypress.Chainable{ return cy.get(".table-row") }
user(): Cypress.Chainable{ return cy.get(".flex.items-center.gap-2") }
rowDropdown(): Cypress.Chainable{ return cy.get("[role=\"combobox\"]") }

rowDropdownElement(): Cypress.Chainable{ return cy.get("[role=\"option\"]") }
}
rowDropdownElement(): Cypress.Chainable {
return cy.get('[role="option"]');
}
}
4 changes: 3 additions & 1 deletion packages/app/cypress/e2e/page-objects/pages/RacePage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export class RacePage {
practiceCardLanguageDropdown(): Cypress.Chainable {
return cy.get("[data-cy='practice-card'] [data-cy='language-dropdown']");
return cy.get(
"[data-cy='practice-card'] [data-cy='language-dropdown'] [data-cy='search-language-input']"
);
}
cppLanguageOption(): Cypress.Chainable {
return cy.get("[data-cy='c++-value']");
Expand Down
Loading
Loading