Skip to content

Commit

Permalink
Update student-add.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedNufais5891 authored Jan 1, 2025
1 parent f833e4c commit 84ed733
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions frontend/test/student-add.test.js
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");
});

0 comments on commit 84ed733

Please sign in to comment.