Compare commits
26 Commits
feature/in
...
fix/refact
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cb5038c00 | ||
|
|
c6070dffeb | ||
|
|
de88a320d7 | ||
|
|
1b8235e3a5 | ||
|
|
8b94d14088 | ||
|
|
e844613eec | ||
|
|
a994cd8266 | ||
|
|
ff4ff4c587 | ||
|
|
3bbdf90ccf | ||
|
|
9659d93556 | ||
|
|
309e174a46 | ||
|
|
cfba9672ef | ||
|
|
1c6e96e94c | ||
|
|
c133603e43 | ||
|
|
5845bbeca3 | ||
|
|
f62012c13d | ||
|
|
e0daee72da | ||
|
|
4020b33293 | ||
|
|
88a6969f2f | ||
|
|
4ba36081d2 | ||
|
|
4c2576052f | ||
|
|
841c416a93 | ||
|
|
08a1beff07 | ||
|
|
380478d20a | ||
|
|
4fce9ab108 | ||
|
|
fc6793df06 |
26
.github/workflows/todos.yml
vendored
Normal file
26
.github/workflows/todos.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Sync TODOs with Issues
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
sync_todos:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Sync TODOs
|
||||
uses: Solo-Web-Works/TODO-Sync@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
summary_file: TODO_SUMMARY.md
|
||||
dry_run: false
|
||||
commit: false
|
||||
@@ -4,7 +4,11 @@
|
||||
|
||||
const isValidDomain = (domain) => {
|
||||
// Regular expression to validate a domain name
|
||||
const domainRegex = /^(?!:\/\/)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
|
||||
// const domainRegex = /^(?!:\/\/)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
|
||||
|
||||
// Regular expression to validate a domain name. Requires http or https prefix.
|
||||
// Allows for optional path after the domain.
|
||||
const domainRegex = /^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(\/[^\s]*)?\/?$/;
|
||||
return domainRegex.test(domain);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ class SiteModel {
|
||||
/**
|
||||
* Inserts a new site into the database.
|
||||
*
|
||||
* @param {string} name - The name of the site.
|
||||
* @param {string} domainName - The domain name of the site.
|
||||
*
|
||||
* @returns {Promise<Object>} - The result of the insert operation.
|
||||
@@ -20,7 +19,7 @@ class SiteModel {
|
||||
async insert(domainName) {
|
||||
// validate inputs
|
||||
if (!domainName) {
|
||||
throw new Error('Name and domain name are required to insert a site.');
|
||||
throw new Error('Domain name is required to insert a site.');
|
||||
}
|
||||
|
||||
// validate domain name format
|
||||
@@ -58,6 +57,8 @@ class SiteModel {
|
||||
throw error;
|
||||
}
|
||||
|
||||
data.reverse(); // Reverse the order to show the most recent sites first
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
20
package-lock.json
generated
20
package-lock.json
generated
@@ -24,6 +24,7 @@
|
||||
"@tailwindcss/cli": "^4.1.7",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"concurrently": "^8.2.0",
|
||||
"daisyui": "^5.0.37",
|
||||
"tailwindcss": "^4.1.7"
|
||||
}
|
||||
},
|
||||
@@ -1200,6 +1201,8 @@
|
||||
},
|
||||
"node_modules/cssstyle": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.3.1.tgz",
|
||||
"integrity": "sha512-ZgW+Jgdd7i52AaLYCriF8Mxqft0gD/R9i9wi6RWBhs1pqdPEzPjym7rvRKi397WmQFf3SlyUsszhw+VVCbx79Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@asamuzakjp/css-color": "^3.1.2",
|
||||
@@ -1209,8 +1212,20 @@
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/daisyui": {
|
||||
"version": "5.0.37",
|
||||
"resolved": "https://registry.npmjs.org/daisyui/-/daisyui-5.0.37.tgz",
|
||||
"integrity": "sha512-PLc+MhWAqTwolygEGPDi+ac+OsFqIt9nZylTIiyVlEx8loYL7Pt7hNWb8cp5pQQ9dhjYnda1ERiuM6OsJmvPGw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/saadeghi/daisyui?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/data-urls": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz",
|
||||
"integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"whatwg-mimetype": "^4.0.0",
|
||||
@@ -1222,6 +1237,8 @@
|
||||
},
|
||||
"node_modules/data-urls/node_modules/tr46": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz",
|
||||
"integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"punycode": "^2.3.1"
|
||||
@@ -1232,6 +1249,8 @@
|
||||
},
|
||||
"node_modules/data-urls/node_modules/whatwg-url": {
|
||||
"version": "14.2.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz",
|
||||
"integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tr46": "^5.1.0",
|
||||
@@ -1246,6 +1265,7 @@
|
||||
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz",
|
||||
"integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.21.0"
|
||||
},
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
"ejs": "^3.1.10",
|
||||
"express": "~4.16.1",
|
||||
"http-errors": "~1.6.3",
|
||||
"morgan": "~1.9.1",
|
||||
"jsdom": "^26.1.0"
|
||||
"jsdom": "^26.1.0",
|
||||
"morgan": "~1.9.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/cli": "^4.1.7",
|
||||
"@tailwindcss/typography": "^0.5.16",
|
||||
"tailwindcss": "^4.1.7",
|
||||
"concurrently": "^8.2.0"
|
||||
"concurrently": "^8.2.0",
|
||||
"daisyui": "^5.0.37",
|
||||
"tailwindcss": "^4.1.7"
|
||||
}
|
||||
}
|
||||
|
||||
1
public/favicon.ico
Normal file
1
public/favicon.ico
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,13 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const SiteModel = require('../models/SiteModel');
|
||||
const sitesModel = new SiteModel();
|
||||
|
||||
/* GET home page. */
|
||||
router.get('/', async function(req, res, next) {
|
||||
const sites = await sitesModel.getAll();
|
||||
console.log('Sites:', sites);
|
||||
res.render('index', { title: 'Express', sites: sites });
|
||||
// console.log('Sites:', sites);
|
||||
res.render('index', { title: 'Playwright Testing Dashboard', sites: sites, msg: '' });
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -53,12 +53,10 @@ router.get('/domain/:domain', async function(req, res, next) {
|
||||
return res.status(400).send('Error fetching site: ' + error.message);
|
||||
}
|
||||
|
||||
console.log('Site found:', sites);
|
||||
|
||||
if (!sites || sites.length === 0) {
|
||||
return res.status(404).send('Site not found');
|
||||
} else {
|
||||
res.json(sites[0]); // Return the first match
|
||||
res.render('sites', { title: 'Playwright Testing Dashboard', sites: sites });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -84,7 +82,9 @@ router.post('/add', async function(req, res, next) {
|
||||
if (!newSite) {
|
||||
res.status(400).send('Error creating site');
|
||||
} else {
|
||||
res.status(201).json(newSite);
|
||||
// res.status(201).json(newSite);
|
||||
const sites = await siteModel.getAll();
|
||||
res.render('index', { title: 'Playwright Testing Dashboard', sites: sites, msg: 'Site created successfully!' });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
@import 'tailwindcss';
|
||||
@source "./views/*.ejs";
|
||||
@source "./styles/*.css";
|
||||
|
||||
@import './colors.css';
|
||||
@import './typography.css';
|
||||
|
||||
@plugin "daisyui";
|
||||
@plugin "@tailwindcss/typography";
|
||||
|
||||
@@ -108,12 +108,15 @@ p {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
li ul, li ol { margin: 0 1rem; }
|
||||
|
||||
ul { list-style-type: disc; }
|
||||
|
||||
#main-nav ul { list-style-type: none; }
|
||||
|
||||
ol { list-style-type: decimal; }
|
||||
|
||||
li ul, li ol { margin: 0 1rem; }
|
||||
|
||||
ol ol { list-style: lower-alpha; }
|
||||
|
||||
ol ol ol { list-style: lower-roman; }
|
||||
|
||||
12
views/add-form.ejs
Normal file
12
views/add-form.ejs
Normal file
@@ -0,0 +1,12 @@
|
||||
<form action="/sites/add" method="POST" class="w-full">
|
||||
<fieldset class="fieldset bg-base-100 rounded-box px-8 py-4 shadow-md">
|
||||
<legend class="fieldset-legend h3">Start a new test</legend>
|
||||
<div class="flex gap-0">
|
||||
<div class="w-fit m-0 p-0">
|
||||
<input type="text" class="input w-full border-r-0 rounded-r-none" name="domain" id="domain" placeholder="https://example.com/" />
|
||||
<p class="label pt-2">Single URL or link to sitemap, including "http" or "https"</p>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-info">Test</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
49
views/domain-cards.ejs
Normal file
49
views/domain-cards.ejs
Normal file
@@ -0,0 +1,49 @@
|
||||
<%
|
||||
// Helper function to format date
|
||||
function formatDate(dateString) {
|
||||
let date = new Date(dateString);
|
||||
return date.toLocaleString('en-CA', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit'
|
||||
});
|
||||
}
|
||||
|
||||
// Group data by unique domain_name
|
||||
let groupedDomains = {};
|
||||
data.forEach(item => {
|
||||
let domain = item.domain_name?.trim();
|
||||
if (!domain) return;
|
||||
if (!groupedDomains[domain]) {
|
||||
groupedDomains[domain] = [];
|
||||
}
|
||||
groupedDomains[domain].push(item);
|
||||
});
|
||||
%>
|
||||
|
||||
<div class="card-container grid gap-6 grid-cols-1 md:grid-cols-3 lg:grid-cols-4">
|
||||
<% Object.keys(groupedDomains).forEach(domain => { %>
|
||||
<%
|
||||
// Sort entries by created_at descending and limit to 5
|
||||
let sortedEntries=groupedDomains[domain]
|
||||
.sort((a, b) => new Date(b.created_at) - new Date(a.created_at))
|
||||
.slice(0, 5);
|
||||
%>
|
||||
<div class="card w-full bg-base-100 card-lg shadow-sm wrap-anywhere">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title"><%= domain %></h2>
|
||||
<% sortedEntries.forEach(entry => { %>
|
||||
<div class="flex font-normal">
|
||||
<p class="w-fit"><%= entry.id %></p>
|
||||
<p class="flex-grow-1"><%= formatDate(entry.created_at) %></p>
|
||||
</div>
|
||||
<% }) %>
|
||||
<div class="card-actions justify-end mt-auto">
|
||||
<a href="/sites/domain/<%= encodeURIComponent(domain) %>" class="btn btn-info text-info-content! hover:text-info-content!">View All Tests</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% }) %>
|
||||
</div>
|
||||
@@ -1,3 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Raleway:wght@100..900&display=swap">
|
||||
|
||||
<title>
|
||||
Playwright Dashboard - ERROR
|
||||
</title>
|
||||
|
||||
<link rel='stylesheet' href='/stylesheets/style.css' />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="">
|
||||
<header class="bg-gray-200 w-full">
|
||||
<div class="container mx-auto flex justify-between items-center text-gray-800 py-4">
|
||||
<div class="flex items-center">
|
||||
<!-- <img src="/images/logo.png" alt="Logo" class="h-8 mr-2"> -->
|
||||
<h1 class="">
|
||||
Playwright Dashboard - ERROR
|
||||
</h1>
|
||||
</div>
|
||||
<nav>
|
||||
<ul class="flex space-x-4">
|
||||
<li><a href="/" class="text-white hover:text-gray-400">Home</a></li>
|
||||
<li><a href="/about" class="text-white hover:text-gray-400">About</a></li>
|
||||
<li><a href="/contact" class="text-white hover:text-gray-400">Contact</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<article class="container mx-auto py-4 min-h-[70dvh]">
|
||||
<h1><%= message %></h1>
|
||||
<h2><%= error.status %></h2>
|
||||
<pre><%= error.stack %></pre>
|
||||
</article>
|
||||
|
||||
<footer class="bg-gray-800 text-white p-4 mt-8">
|
||||
<div class="container mx-auto text-center">
|
||||
<div class="flex justify-center gap-8 items-center mb-4">
|
||||
<p>© <%= new Date().getFullYear() %>
|
||||
Playwright Dashboard. All rights reserved.</p>
|
||||
<p>Powered by <a href="https://example.com" class="text-bodylinks">Your Company</a></p>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<a href="/privacy" class="text-blue-400">Privacy Policy</a> |
|
||||
<a href="/terms" class="text-blue-400">Terms of Service</a>
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
<div class="container mx-auto flex justify-between items-center text-gray-800 py-4">
|
||||
<div class="flex items-center">
|
||||
<!-- <img src="/images/logo.png" alt="Logo" class="h-8 mr-2"> -->
|
||||
<h1 class=""><%= title %></h1>
|
||||
<h1 class=""><a class="no-underline!" href="/"><%= title %></a></h1>
|
||||
</div>
|
||||
<nav>
|
||||
<nav id="main-nav" class="flex items-center">
|
||||
<ul class="flex space-x-4">
|
||||
<li><a href="/" class="text-white hover:text-gray-400">Home</a></li>
|
||||
<!-- TODO: Make these routes/pages -->
|
||||
<li><a href="/about" class="text-white hover:text-gray-400">About</a></li>
|
||||
<li><a href="/contact" class="text-white hover:text-gray-400">Contact</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
<%- include('header'); -%>
|
||||
|
||||
<article class="container mx-auto py-4 min-h-[70dvh]">
|
||||
<h2>Welcome to the <%= title %> EJS Template</h2>
|
||||
<p>This is a simple example of using EJS for templating.</p>
|
||||
<h2>Welcome to <%= title %></h2>
|
||||
|
||||
<ul>
|
||||
<% for (let i = 0; i < sites.length; i++) { %>
|
||||
<li><%= sites[i].domain_name %></li>
|
||||
<%- include('add-form'); -%>
|
||||
<% if (msg) { %>
|
||||
<div class="alert alert-success mt-4">
|
||||
<div class="text-xl"><%= msg %></div>
|
||||
</div>
|
||||
<% } %>
|
||||
</ul>
|
||||
|
||||
<h2 class="text-25px font-bold mt-8">Your Tests</h2>
|
||||
|
||||
<div class="mt-8">
|
||||
<%- include('domain-cards', { data: sites }); -%>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<%- include('footer'); -%>
|
||||
|
||||
15
views/sites.ejs
Normal file
15
views/sites.ejs
Normal file
@@ -0,0 +1,15 @@
|
||||
<%- include('header'); -%>
|
||||
|
||||
<article class="container mx-auto py-4 min-h-[70dvh]">
|
||||
<h2>Welcome to <%= title %></h2>
|
||||
|
||||
<%- include('add-form'); -%>
|
||||
|
||||
<h2 class="text-25px font-bold mt-8">Tests for <%= sites[0].domain_name %></h2>
|
||||
|
||||
<div class="mt-8">
|
||||
<%- include('test-list', { sites: sites }); -%>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<%- include('footer'); -%>
|
||||
23
views/test-list.ejs
Normal file
23
views/test-list.ejs
Normal file
@@ -0,0 +1,23 @@
|
||||
<%
|
||||
// Helper function to format date
|
||||
function formatDate(dateString) {
|
||||
let date = new Date(dateString);
|
||||
return date.toLocaleString('en-CA', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit'
|
||||
});
|
||||
}
|
||||
%>
|
||||
|
||||
<ul class="list bg-base-100 rounded-box shadow-md mt-8">
|
||||
<% for (let i=0; i < sites.length; i++) { %>
|
||||
<li class="list-row list-none items-center gap-8">
|
||||
<h3 class="text-slate-300 m-0 p-0"><a href="/test/<%= i %>" class="text-slate-300 link">Test <%= i+1 %></a></h3>
|
||||
<span class="site-name list-col-grow text-18px"><%= sites[i].domain_name %> - <%= formatDate(sites[i].created_at) %></span>
|
||||
<span class="badge badge-info">In Progress</span>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user