Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Add automated test.
Browse files Browse the repository at this point in the history
Make application testable by adding success message element to DOM that is hidden when page loads but becomes visible when XHR upload to bucket finishes. Add automated test that uses Puppeteer to select a test file (stored in this repo under test/1x1.png) and click the upload button to upload it. The test is considered successful as long as the XHR for the file upload succeeds. Added GitHub Actions workflow that occasionally clears out the contents of the bucket which was created only for this automated test.
  • Loading branch information
mattwelke committed Sep 28, 2023
1 parent 0720502 commit dc9272b
Show file tree
Hide file tree
Showing 14 changed files with 4,582 additions and 1,366 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
- package-ecosystem: npm
directory: "/backend"
schedule:
interval: "daily"
interval: "weekly"
31 changes: 31 additions & 0 deletions .github/workflows/empty_b2_bucket.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow periodically empties out the B2 bucket used for the automated
# test. Each time the test runs, a file revision is uploaded to the bucket, so
# I need to clear the revisions out once in a while. Here, it happens every
# month.

name: Empty test bucket

on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:

jobs:
test:
name: Empty bucket
runs-on: ubuntu-latest
steps:
- run: |
echo "Downloading B2 CLI..."
wget -q https://github.com/Backblaze/B2_Command_Line_Tool/releases/latest/download/b2-linux
mv b2-linux b2
chmod +x b2
echo "Done."
echo "Authenticating CLI..."
./b2 authorize_account $B2_KEY_ID $B2_APPLICATION_KEY
echo "Done."
echo "Emptying test bucket contents..."
./b2 rm --versions --recursive $B2_BUCKET_NAME
echo "Done."
14 changes: 7 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Run Tests
on: [push]

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm test
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm test
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
.vscode
dist
dist
run_tests.sh
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [ "${workspaceFolder}/test/index.spec.js" ]
}
]
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org>
For more information, please refer to <http://unlicense.org>
Loading

0 comments on commit dc9272b

Please sign in to comment.