generated from OpenUOM/Capstone-Project-Tasks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f833e4c
commit 84ed733
Showing
1 changed file
with
16 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
import { Selector } from 'testcafe'; | ||
|
||
process.env.NODE_ENV = "test"; | ||
|
||
fixture`Testing Student UI` | ||
.page`http://localhost:4401/student` | ||
.page`http://localhost:4401/student`; | ||
|
||
test('Testing add students', async t => { | ||
// Navigate to database initialization page | ||
await t.navigateTo("/dbinitialize"); | ||
|
||
// Input student details | ||
await t.typeText("#student-id", "999999"); | ||
await t.typeText("#student-name", "Pasindu Basnayaka"); | ||
await t.typeText("#student-age", "45"); | ||
await t.typeText("#student-Hometown", "Catholic"); | ||
await t.typeText("#student-hometown", "Catholic"); | ||
await t.click("#student-add"); | ||
|
||
await t.navigateTo("/dbinitialize"); | ||
// Navigate back to ensure the database reflects changes | ||
await t.navigateTo("/student"); | ||
|
||
const table = Selector('#student-table') | ||
// Verify the new student entry in the table | ||
const table = Selector('#student-table'); | ||
const rowCount = await table.find('tr').count; | ||
const lastRowText = await table.find('tr').nth(rowCount - 1).innerText; | ||
|
||
let tdText = await table.find('tr').nth(rowCount - 1).innerText; | ||
await t.expect(tdText).contains("dbinitialize"); | ||
// Assert that the last row contains the newly added student's details | ||
await t.expect(lastRowText).contains("999999"); | ||
await t.expect(lastRowText).contains("Pasindu Basnayaka"); | ||
await t.expect(lastRowText).contains("45"); | ||
await t.expect(lastRowText).contains("Catholic"); | ||
}); |