Add test for static/dynamic RAM check

This commit is contained in:
David Edmondson 2021-09-05 10:04:44 -07:00
parent d0ca2d8c36
commit 20062b11b9
2 changed files with 45 additions and 21 deletions

@ -1,5 +1,6 @@
{
"baseUrl": "http://localhost:8000",
"fixturesFolder": false,
"trashAssetsBeforeRuns": true,
"screenshotsFolder": ".cypress/screenshots",
"videosFolder": ".cypress/videos",

@ -1,5 +1,6 @@
export {};
describe("netscript", () => {
it("creates and runs a NetScript 2.0 script", () => {
cy.findByRole("button", { name: "Exit Tutorial" }).click();
cy.findByText("Got it!").click();
@ -30,3 +31,25 @@ await ns.hack("n00dles");`);
cy.findByRole("textbox").type("ps{enter}");
cy.findByText(/\(PID - 1\) script.js/);
});
it("errors and shows a dialog box when static RAM !== dynamic RAM", () => {
cy.findByRole("button", { name: "Exit Tutorial" }).click();
cy.findByText("Got it!").click();
cy.findByRole("textbox").type("nano script.js{enter}");
// monaco can take a bit
cy.findByRole("code", { timeout: 15_000 }).type("{selectall}{del}")
.type(`export const main = async (ns) => {{}
const command = "hack";
ns[command]("n00dles");`);
cy.findByText("RAM: 1.60GB");
cy.findByRole("button", { name: /Save & Close/i }).click();
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,
);
});
});