-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* get all that weak shit outta here boi * rewrite nn assign form * write test * o you gotta throw it * no password * custom msg * pretty * chom * oops needed OnSubmit
- Loading branch information
1 parent
467e0d9
commit f901942
Showing
5 changed files
with
222 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { test, expect } from "@/tests/mock/test"; | ||
|
||
import { | ||
sampleData, | ||
fillOutJoinForm, | ||
submitSuccessExpected, | ||
submitFailureExpected, | ||
submitConfirmationDialogExpected, | ||
sampleNJData, | ||
submitAndCheckToast, | ||
expectSuccess, | ||
} from "@/tests/util"; | ||
|
||
const timeout = 10000; | ||
const clickTimeout = 1000; | ||
|
||
// Unit tests for the Join Form. | ||
// | ||
// These tests will mock a connection to MeshDB. It is simply making sure that | ||
// the form creates a good-looking payload and can hit a mock API. | ||
|
||
test("nn assign happy", async ({ page }) => { | ||
test.setTimeout(timeout); | ||
await page.goto("/nn-assign"); | ||
|
||
await expect(page).toHaveTitle(/Assign a Network Number/); | ||
|
||
await page.getByPlaceholder("Install Number").fill("20000"); | ||
await page.getByPlaceholder("Pre-Shared Key").fill("localdev"); | ||
|
||
await page.getByRole("button", { name: /Submit/i }).click(); | ||
await page.waitForTimeout(clickTimeout); | ||
|
||
await expect(page.locator("[id='alert-network-number']")).toBeVisible(); | ||
await expect(page.locator("[id='assigned-network-number']")).toHaveText( | ||
"420", | ||
); | ||
}); | ||
|
||
test("nn assign already assigned", async ({ page }) => { | ||
test.setTimeout(timeout); | ||
await page.goto("/nn-assign"); | ||
|
||
await expect(page).toHaveTitle(/Assign a Network Number/); | ||
|
||
await page.getByPlaceholder("Install Number").fill("30000"); | ||
await page.getByPlaceholder("Pre-Shared Key").fill("localdev"); | ||
|
||
await page.getByRole("button", { name: /Submit/i }).click(); | ||
await page.waitForTimeout(clickTimeout); | ||
|
||
await expect(page.locator("[id='alert-network-number']")).toBeVisible(); | ||
await expect(page.locator("[id='nn-message']")).toHaveText( | ||
"This Install Number (30000) already has a Network Number (520) associated with it!", | ||
); | ||
await expect(page.locator("[id='assigned-network-number']")).toHaveText( | ||
"520", | ||
); | ||
}); | ||
|
||
test("nn assign wrong password", async ({ page }) => { | ||
test.setTimeout(timeout); | ||
await page.goto("/nn-assign"); | ||
|
||
await expect(page).toHaveTitle(/Assign a Network Number/); | ||
|
||
await page.getByPlaceholder("Install Number").fill("20000"); | ||
await page.getByPlaceholder("Pre-Shared Key").fill("badpassword"); | ||
|
||
await page.getByRole("button", { name: /Submit/i }).click(); | ||
await page.waitForTimeout(clickTimeout); | ||
|
||
await expect(page.locator("[id='alert-network-number']")).toBeHidden(); | ||
await expect(page.locator("[id='assigned-network-number']")).toHaveText(""); | ||
}); | ||
|
||
test("nn assign no password", async ({ page }) => { | ||
test.setTimeout(timeout); | ||
await page.goto("/nn-assign"); | ||
|
||
await expect(page).toHaveTitle(/Assign a Network Number/); | ||
|
||
await page.getByPlaceholder("Install Number").fill("20000"); | ||
|
||
await expect(page.getByRole("button", { name: /Submit/i })).toBeDisabled(); | ||
await page.waitForTimeout(clickTimeout); | ||
|
||
await expect(page.locator("[id='alert-network-number']")).toBeHidden(); | ||
await expect(page.locator("[id='assigned-network-number']")).toHaveText(""); | ||
}); |