HGustavs / LenaSYS

Code Viewer and Course Organization System used in some courses at University of Skövde
57 stars 31 forks source link

Write tests for services in codeviewerService #13392

Closed b21kurar closed 1 year ago

b21kurar commented 1 year ago

Go through the code, focusing on services, and write tests that traverses all paths in the code. A step by step text file containing what actions to perform and evaluate the tests.

You should do thorough research of the logs, testing out different actions and what values are sent, if logging in or not changes behaviour. The models and functional requirements may also be applicable.

Follow the template in the README under backend-models/service-tests/README.md

See the process of work done in issue #13343!!!

Ignore "Retrieve Information"

b21ricni commented 1 year ago

Will not be able to produce any visible work by the end of the day, but getting a grasp of what we need to do and note. hopefully will come somewhere by the end of the day

b21ricni commented 1 year ago

For the first time since the beginning of dawn, i finally made progress!

b21ricni commented 1 year ago

So far as i understand, It fetches data from codeexempel where example id matches the chosen id, it updates templateid in codeexempel. It also updates data in box, it inserts, delete data in impwordlist.

So i assume this file is for editing the created templates for when creating new code exempels, havnt found where you can change them tho

b21ricni commented 1 year ago

i did something :)


Update templateid:


Templateid have eleven ids[0,1,2,3,4,5,6,7,8,9,10], need to do test for each to check that they all work

//Prints out so we know starting value SELECT exampleid, templateid FROM codeexample;

//Update, test if templates work UPDATE codeexample SET templateid = (Number you wanna test) where exampleid = (exampleId of testsubject);

//Prints out so we can see if update was successfull SELECT exampleid, templateid FROM codeexample;

d21erisu commented 1 year ago

i have come to help the master with this issue, i come with skills provided by JP

b21ricni commented 1 year ago

If example name is changed in MySql it stays the same in the menu where you can select the codexample, but when you enter the code example you can see the changed name on top, the menu file have a visual name stored elsewhere

b21ricni commented 1 year ago

It also seems we can create and store example codes that are hidden to anyone, might be a bug

d21erisu commented 1 year ago

Regarding insertions into tables, counting the number of objects in table before insert, doing insert and then doing a count again can't test if the insert was successful.

b21ricni commented 1 year ago

We following a temporarily structure so we can get through the code a bit faster, seems to work for now but need to confirm with leader if its an acceptable structure

d21erisu commented 1 year ago

We following a temporarily structure so we can get through the code a bit faster, seems to work for now but need to confirm with leader if its an acceptable structure

It has come to our attention that the template might not be "correct" and that we will change the structure which is why we are following our own.

b21ricni commented 1 year ago

So the uppers have decided to change what they ask for in the tests. So we are back to square one, but at least we know the code by head so it should be at least a little bit less painful, worst case we'll end up chain-smoking outside the library

d21erisu commented 1 year ago

So the uppers have decided to change what they ask for in the tests. So we are back to square one, but at least we know the code by head so it should be at least a little bit less painful, worst case we'll end up chain-smoking outside the library

The progress we have made so far might be useful to some extent. It needs rework to fit the template.

b21ricni commented 1 year ago

The creators of the code has successfully made it a pain to be able to get the json data for editcontent and edittitle, top 10 "i wanna cry" moments :)

a19hakja commented 1 year ago

Is there nothing to be found in the response in the browser inspector?

d21erisu commented 1 year ago

Is there nothing to be found in the response in the browser inspector?

as soon as we press save it refreshes the page thus updating and losing the content in the browser inspector.

b21ricni commented 1 year ago

We'll try to find a solution tomorrow, nothing we tried have worked so far. Worst case scenario we'll need to run a program that downloads the json

b21ricni commented 1 year ago

So we have three possible solutions. Wireshark, https://www.tassos.gr/joomla-extensions/convert-forms/docs/how-to-automatically-save-each-submission-to-a-json-file, or potentially removing the refresh function temporarily

d21erisu commented 1 year ago

We are trying to use wireshark, unclear if it will work as intended

b21ricni commented 1 year ago

Its soon been an issue we stared at for over a week with minimal progress, feels bad man

d21erisu commented 1 year ago

We are trying to use wireshark, unclear if it will work as intended

wireshark did not work

b21ricni commented 1 year ago
image

So no files are found anymore after merge?

b21ricni commented 1 year ago

Added delay on reload and all the problems just disappeared

d21erisu commented 1 year ago

image

by changing set timeout to a higher value, we have time enough to retrieve the json data

b21ricni commented 1 year ago

Reminder to set setTimeout("location.reload()", 500); again, currently on 10000

b21ricni commented 1 year ago

New issue, in codeexample, you cant target the change text 99% of the time to change it. And when we can target it you can't save by pressing enter, you also can't save it that way, the value turns null

image
d21erisu commented 1 year ago

We tried to re-install Lenasys since the other group has made some changes. However nothing changed for the better, it actually got worse.

b21ricni commented 1 year ago

Thinking of adding a "onkeypress" function

b21ricni commented 1 year ago
image

This is pain in a bottle

b21ricni commented 1 year ago

EDITTITLE Line 281 —--------------------------------------------------------------------------------- Does this even work? Broken feature. Useless until fixed

b21ricni commented 1 year ago

Not sure how to test codeexampleservice.php row: 373 - 418, its the function to display information in the drop down

edit: for the before and after id

b21ricni commented 1 year ago

The closest to get any sort of information i found is to either check the drop down physically or through elements in the inspector

b21ricni commented 1 year ago

After having a conversation with JP about what is missing and what not in the document we reach the conclusion that we might need to add mySQL code as well to double check that the data works. Conveniently thats the first thing we did so we just need to merge the documents in a nice and clean way.

there might be an issue with { (checklogin = true) && (hasAccess($userid, $courseId, 'w') || hasAccess($userid, $courseId, 'st')) == true} give $writeAccess="w";, else $writeAccess="s"; but neither have a clue how to fix it, we'll come back to it when document is done and do one final check to see that its okay

a19hakja commented 1 year ago

We're currently working on a testAPI which purpose is to implement functionality that bypasses these conditions. This should things easier for testing in general. @c21alest I believe is currently working on this API and may have more relevant information.

We also recently installed something called php curl, which is supposed to make it easier to test stuff. Once again @c21alest is probably your guy to talk to this about.

b21ricni commented 1 year ago

If the testAPI is currently under development, should we put the creation of the documentation on hold or should we try to install php curl and contact @c21alest about how to continue the testing?

d21erisu commented 1 year ago

If the testAPI is currently under development, should we put the creation of the documentation on hold or should we try to install php curl and contact @c21alest about how to continue the testing?

We could convert the document we have now to txt so that it at least is available in the group branch and accessible through github. At the moment only a few have access to the document. We can make the unfinished version available for everyone.

b21ricni commented 1 year ago

Roses are red, violets are blue, we can't continue without an answer or two

d21erisu commented 1 year ago

Roses are red, violets are blue, we can't continue without an answer or two

It has come to our attention that it's specified in the issue description that part "Retrieve information" shall be ignored. So now we can complete it :)