From 4343a79c6ec28dfc0472be4e413981a472ea2776 Mon Sep 17 00:00:00 2001 From: Mohamed Nufais <125565667+MohamedNufais5891@users.noreply.github.com> Date: Thu, 2 Jan 2025 02:17:48 +0530 Subject: [PATCH] Update student-add.test.js --- frontend/test/student-add.test.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/frontend/test/student-add.test.js b/frontend/test/student-add.test.js index 32084c2..589d260 100644 --- a/frontend/test/student-add.test.js +++ b/frontend/test/student-add.test.js @@ -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"); }); - -