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 cbe7bb0 commit 4343a79
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions frontend/test/student-add.test.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
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 => {
// Input student details
await t.navigateTo("/dbinitialize");
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.click("#student-add");

// Wait for the table to update after adding the student
const table = Selector('#student-table');
const rowCount = await table.find('tr').count;
await t.navigateTo("/dbinitialize");

// Get the last row's text and validate it
const lastRowText = await table.find('tr').nth(rowCount - 1).innerText;
const table = Selector('#student-table')
const rowCount = await table.find('tr').count;

// 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");
let tdText = await table.find('tr').nth(rowCount - 1).innerText;
await t.expect(tdText).contains("dbinitialize");
});


0 comments on commit 4343a79

Please sign in to comment.