Skip to main content

Unit Tests

Frontend

All frontend testing will be done with vitest. Vitest was chosen as it is designed to work with our chosen dev framework, vite.

Due to the nature of react, only non-react functions, such as helper functions, will be subject to unit tests. Components will be tested through integration tests instead.

App

FunctionGoal
makeEmptyScene()returns a valid, empty SceneData object
makeNewSketchPage(index)returns valid SketchPage object with the given index

Collector

FunctionGoal
Collector(string)given a sample html string, returns array of parsed elements

Backend

All backend testing will be done with Pytest. Mock django objects will be used for anything not being directly tested.

Testing Procedure

From ROOT folder

cd backend/sketch_api
pytest

Mockup Generation API:

GoalInputOutput
POST returns successBlank POST requestSuccess response
POST returns mockup idBlank POST requestMockup ID of response
GET returns errorBlank GET requestHTTP 405
PUT returns errorBlank PUT requestHTTP 405

Frontend View:

GoalInputOutput
Renders appropriate templateGET "/"registered render of "frontend/src/index.html"
Accepts GET requestsGET "/"registered access of render function
Returns result from renderGET "/"response matching preset test response

Generate View:

GoalInputOutput
Error on missing filePOST with no fileHTTP 400
Error on massive filePOST with file > 10MBHTTP 413
Error on incorrect file typePOST with text fileHTTP 400
Successful generationPOST with PNGHTTP 200 + generated html in response
Prompt parameter processedPOST with PNG and promptMock LLM API registers additional prompt
File conversion errors handledPOST with PNG and simulated errorHTTP 500
Accepts different file typesPOST with JPGHTTP 200