Merge pull request #2813 from jamie-mac/fix/cypress-tests

Fix: Cypress tests for dev (updates to match UI changes)
This commit is contained in:
hydroflame 2022-01-26 00:31:00 -05:00 committed by GitHub
commit 0f2dd23eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 20 deletions

@ -3,7 +3,6 @@ export {};
describe("netscript", () => { describe("netscript", () => {
it("Do naviguation", () => { it("Do naviguation", () => {
cy.findByRole("button", { name: "SKIP TUTORIAL" }).click(); cy.findByRole("button", { name: "SKIP TUTORIAL" }).click();
cy.findByText("Got it!").click();
cy.findByText("Dev").click(); cy.findByText("Dev").click();
cy.findByText(/Source-Files/i).click(); cy.findByText(/Source-Files/i).click();
@ -23,11 +22,11 @@ describe("netscript", () => {
cy.findByText(/Experience/i).click(); cy.findByText(/Experience/i).click();
cy.findByText(/Tons of exp/i).click(); cy.findByText(/Tons of exp/i).click();
cy.findByText("Create Script").click(); cy.findByText("Script Editor").click();
cy.findByText(/Script name:/i); cy.findByText(/No Open Files/i);
cy.findByText("Active Scripts").click(); cy.findByText("Active Scripts").click();
cy.findByText(/Total online production of/i); cy.findByText(/Total production since last Augment/i);
cy.findByText("Create Program").click(); cy.findByText("Create Program").click();
cy.findByText(/This page displays/i); cy.findByText(/This page displays/i);
@ -65,9 +64,9 @@ describe("netscript", () => {
cy.findByText(/don't reward you for/i); cy.findByText(/don't reward you for/i);
cy.findByText("Tutorial").click(); cy.findByText("Tutorial").click();
cy.findByText(/AKA Links to/i); cy.findByText(/Tutorial \/ Documentation/i);
cy.findByText("Options").click(); cy.findByText("Options").click();
cy.findByText(/Netscript exec time/i); cy.findByText(/\.script exec time/i);
}); });
}); });

@ -3,7 +3,6 @@ export {};
describe("netscript", () => { describe("netscript", () => {
it("creates and runs a NetScript 2.0 script", () => { it("creates and runs a NetScript 2.0 script", () => {
cy.findByRole("button", { name: "SKIP TUTORIAL" }).click(); cy.findByRole("button", { name: "SKIP TUTORIAL" }).click();
cy.findByText("Got it!").click();
cy.findByRole("textbox").type("connect n00dles{enter}"); cy.findByRole("textbox").type("connect n00dles{enter}");
cy.findByText(/connected to n00dles/i); cy.findByText(/connected to n00dles/i);
@ -17,12 +16,13 @@ describe("netscript", () => {
cy.findByRole("textbox").type("nano script.js{enter}"); cy.findByRole("textbox").type("nano script.js{enter}");
// monaco can take a bit // monaco can take a bit
cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}").type(`export const main = async (ns) => {{} cy.findByRole("code", { timeout: 15_000 }).type("{ctrl}a{del}").type(`export const main = async (ns) => {{}
while(true) {{} while(true) {{}
await ns.hack("n00dles");`); await ns.hack("n00dles");`);
cy.findByText("RAM: 1.70GB"); cy.findByText("RAM: 1.70GB");
cy.findByRole("button", { name: /Save & Close/i }).click(); cy.findByRole("button", { name: /Save \(Ctrl\/Cmd \+ s\)/i }).click();
cy.findByRole("button", { name: /Close \(Ctrl\/Cmd \+ b\)/i }).click();
cy.findByRole("textbox").type("run script.js{enter}"); cy.findByRole("textbox").type("run script.js{enter}");
cy.findByText(/Running script with 1 thread/); cy.findByText(/Running script with 1 thread/);
@ -33,17 +33,17 @@ describe("netscript", () => {
it("errors and shows a dialog box when static RAM !== dynamic RAM", () => { it("errors and shows a dialog box when static RAM !== dynamic RAM", () => {
cy.findByRole("button", { name: "SKIP TUTORIAL" }).click(); cy.findByRole("button", { name: "SKIP TUTORIAL" }).click();
cy.findByText("Got it!").click();
cy.findByRole("textbox").type("nano script.js{enter}"); cy.findByRole("textbox").type("nano script.js{enter}");
// monaco can take a bit // monaco can take a bit
cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}").type(`export const main = async (ns) => {{} cy.findByRole("code", { timeout: 15_000 }).type("{ctrl}a{del}").type(`export const main = async (ns) => {{}
const command = "hack"; const command = "hack";
ns[command]("n00dles");`); ns[command]("n00dles");`);
cy.findByText("RAM: 1.60GB"); cy.findByText("RAM: 1.60GB");
cy.findByRole("button", { name: /Save & Close/i }).click(); cy.findByRole("button", { name: /Save \(Ctrl\/Cmd \+ s\)/i }).click();
cy.findByRole("button", { name: /Close \(Ctrl\/Cmd \+ b\)/i }).click();
cy.findByRole("textbox").type("run script.js{enter}"); cy.findByRole("textbox").type("run script.js{enter}");
cy.findByText(/Dynamic RAM usage calculated to be greater than initial RAM usage on fn: hack./i); cy.findByText(/Dynamic RAM usage calculated to be greater than initial RAM usage on fn: hack./i);

@ -55,7 +55,7 @@ describe("tutorial", () => {
// monaco can take a bit // monaco can take a bit
cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}").type("while(true) {{}{enter}hack('n00dles');"); cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}").type("while(true) {{}{enter}hack('n00dles');");
cy.findByRole("button", { name: /Save & Close/i }).click(); cy.findByRole("button", { name: /Save \(Ctrl\/Cmd \+ s\)/i }).click();
cy.findByText(/now we'll run the script/i); cy.findByText(/now we'll run the script/i);
cy.findByRole("textbox").type("free{enter}"); cy.findByRole("textbox").type("free{enter}");
@ -89,8 +89,7 @@ describe("tutorial", () => {
cy.findByText(/a lot of different documentation about the game/i); cy.findByText(/a lot of different documentation about the game/i);
cy.findByRole("button", { name: "FINISH TUTORIAL" }).click(); cy.findByRole("button", { name: "FINISH TUTORIAL" }).click();
cy.findByText("Got it!").click();
cy.findByText(/Tutorial \(AKA Links to Documentation\)/i); cy.findByText(/Tutorial \/ Documentation/i);
}); });
}); });

@ -1,9 +1,10 @@
export {}; export {};
beforeEach(() => { beforeEach(() => {
cy.visit("/"); cy.visit("/", {
cy.clearLocalStorage(); onBeforeLoad(win: Cypress.AUTWindow) {
cy.window().then((win) => { win.indexedDB.deleteDatabase("bitburnerSave");
win.indexedDB.deleteDatabase("bitburnerSave"); }
}); });
cy.clearLocalStorage();
}); });

@ -85,7 +85,7 @@ function BitNodePortal(props: IPortalProps): React.ReactElement {
</Typography> </Typography>
} }
> >
<span onClick={() => setPortalOpen(true)} className={cssClass}> <span onClick={() => setPortalOpen(true)} className={cssClass} aria-label={`enter-bitnode-${bitNode.number.toString()}`}>
<b>O</b> <b>O</b>
</span> </span>
</Tooltip> </Tooltip>