bitburner-src/test/cypress/integration/netscript.spec.ts

52 lines
1.8 KiB
TypeScript
Raw Normal View History

export {};
2021-09-05 19:04:44 +02:00
describe("netscript", () => {
it("creates and runs a NetScript 2.0 script", () => {
2021-09-19 09:13:49 +02:00
cy.findByRole("button", { name: "SKIP TUTORIAL" }).click();
2021-09-05 19:04:44 +02:00
cy.findByRole("textbox").type("connect n00dles{enter}");
cy.findByText(/connected to n00dles/i);
2021-09-05 19:04:44 +02:00
cy.findByRole("textbox").type("run NUKE.exe{enter}");
cy.findByText(/gained root access/i);
2021-09-05 19:04:44 +02:00
cy.findByRole("textbox").type("home{enter}");
cy.findByText(/connected to home/i);
2021-09-05 19:04:44 +02:00
cy.findByRole("textbox").type("nano script.js{enter}");
2021-09-05 19:04:44 +02:00
// monaco can take a bit
cy.findByRole("code", { timeout: 15_000 }).type("{ctrl}a{del}").type(`export const main = async (ns) => {{}
2021-09-05 19:04:44 +02:00
while(true) {{}
await ns.hack("n00dles");`);
2021-09-05 19:04:44 +02:00
cy.findByText("RAM: 1.70GB");
cy.findByRole("button", { name: /Save \(Ctrl\/Cmd \+ s\)/i }).click();
cy.findByRole("button", { name: /Close \(Ctrl\/Cmd \+ b\)/i }).click();
2021-09-05 19:04:44 +02:00
cy.findByRole("textbox").type("run script.js{enter}");
cy.findByText(/Running script with 1 thread/);
2021-09-05 19:04:44 +02:00
cy.findByRole("textbox").type("ps{enter}");
cy.findByText(/\(PID - 1\) script.js/);
});
it("errors and shows a dialog box when static RAM !== dynamic RAM", () => {
2021-09-19 09:13:49 +02:00
cy.findByRole("button", { name: "SKIP TUTORIAL" }).click();
2021-09-05 19:04:44 +02:00
cy.findByRole("textbox").type("nano script.js{enter}");
// monaco can take a bit
cy.findByRole("code", { timeout: 15_000 }).type("{ctrl}a{del}").type(`export const main = async (ns) => {{}
2021-09-05 19:04:44 +02:00
const command = "hack";
ns[command]("n00dles");`);
cy.findByText("RAM: 1.60GB");
cy.findByRole("button", { name: /Save \(Ctrl\/Cmd \+ s\)/i }).click();
cy.findByRole("button", { name: /Close \(Ctrl\/Cmd \+ b\)/i }).click();
2021-09-05 19:04:44 +02:00
cy.findByRole("textbox").type("run script.js{enter}");
2021-09-09 05:47:34 +02:00
cy.findByText(/Dynamic RAM usage calculated to be greater than initial RAM usage on fn: hack./i);
2021-09-05 19:04:44 +02:00
});
});