view php/test.html @ 3141:335bc77627e0 tip

fixing discrete interface to allow labels to display
author Dave Moffat <me@davemoffat.com>
date Mon, 26 Jul 2021 12:15:24 +0100
parents 260efd43fe52
children
line wrap: on
line source
<html lang="en">

<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">


    <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
		Remove this if you use the .htaccess -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <title>Web Audio Evaluation Tool</title>
    <meta name="description" content="" />
    <meta name="author" content="" />

    <!-- Load up the default core JS and CSS files-->
    <link rel='stylesheet' type='text/css' href='../css/core.css'>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.5.2/mocha.min.css" integrity="sha256-Flo6sV8k+IPfHh6Hx97ReUJDLOwIwvhdGlKOz3UgHRE=" crossorigin="anonymous" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <!-- Use jQuery hosted from Google CDN -->
    <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>-->
    <script type="text/javascript" src="../js/showdown.min.js"></script>
    <script type="text/javascript" src="../js/jquery-2.1.4.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.1.2/chai.min.js" integrity="sha256-iP6sMGdjKeRM2DuED2Lsi/n7MNTKhGpkhuSdCHXIgYc=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.5.2/mocha.min.js" integrity="sha256-rw/35Nx9y5f+fLTdO7Tipm6ju+tRGwnplU1CJyPM3nE=" crossorigin="anonymous"></script>
    <script>
        mocha.setup('bdd');
        var expect = chai.expect;
        var should = chai.should();
        var key1;
        describe("requestKey.php", function() {
            it("should give a key", function(done) {
                var xhr = new XMLHttpRequest();
                xhr.open("GET", "requestKey.php");
                xhr.onload = function() {
                    var doc = xhr.response;
                    var state = doc.querySelector("state").textContent;
                    key1 = doc.querySelector("key").textContent;
                    expect(state).to.equal("OK");
                    done();
                }
                xhr.responseType = "document";
                xhr.send();
            });
            it("should create an empty file with that key", function(done) {
                var xhr = new XMLHttpRequest();
                xhr.open("GET", "../saves/save-" + key1 + ".xml");
                xhr.onload = function() {
                    var parser = new DOMParser();
                    doc = parser.parseFromString(xhr.responseText, "text/xml");
                    var state = doc.querySelector("waetresult").getAttribute("key");
                    expect(state).to.equal(key1);
                    done();
                }
                xhr.responseType = "";
                xhr.send();
            });
            it("should give a different key on second request", function(done) {
                var xhr = new XMLHttpRequest();
                xhr.open("GET", "requestKey.php");
                xhr.onload = function() {
                    var doc = xhr.response;
                    var state = doc.querySelector("state").textContent;
                    var key = doc.querySelector("key").textContent;
                    expect(state).to.equal("OK");
                    expect(key).not.to.equal(key1);
                    done();
                }
                xhr.responseType = "document";
                xhr.send();
            });
        });
        describe("Saves permissions", function() {
            it("should write \"test-save.xml\" to saves and delete", function(done) {
                var xhr = new XMLHttpRequest();
                xhr.open("GET", "test_write.php");
                xhr.onload = function() {
                    var doc = xhr.response;
                    var response = doc.querySelector("response");
                    var message = doc.querySelector("message");
                    expect(response.getAttribute("state")).to.equal("OK");
                    done();
                }
                xhr.responseType = "document";
                xhr.send();
            });
        });
        window.onload = function() {
            mocha.run();
        }

    </script>
</head>

<body class="container">
    <div>
        <h1>WAET PHP Server Tests</h1>
        <p class="lead">This page will test your PHP server for any implementation issues.</p>
        <p>Make sure your <span>saves</span> directory is clean before testing and that you empty it afterwards as intermediary files will be made there.</p>

    </div>
    <div id="mocha"></div>
</body>

</html>