Skip to content

Commit

Permalink
Merge pull request #44 from modern-sapien/checkly-implementation
Browse files Browse the repository at this point in the history
refinements
  • Loading branch information
modern-sapien authored May 22, 2023
2 parents fa8c9a6 + 39790e9 commit f3b635d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 164 deletions.
59 changes: 0 additions & 59 deletions .github/workflows/checkly-fail-safe.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,3 @@
# name: Checkly Fail Safe
# on:
# pull_request:
# types:
# - closed
# jobs:
# test-e2e:
# if: github.event.pull_request.merged == true
# name: Merge Test Deploy
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# - name: Restore or cache node_modules
# id: cache-node-modules
# uses: actions/cache@v3
# with:
# path: node_modules
# key: node-modules-${{ hashFiles('package-lock.json') }}
# - name: Install dependencies
# if: steps.cache-node-modules.outputs.cache-hit != 'true'
# run: cd next-webstore && npm ci
# - name: Set Environment Variables
# run: |
# if [ ${{ github.ref }} = 'refs/heads/main' ]; then
# echo "NEXT_PUBLIC_NODE_ENV=production" >> $GITHUB_ENV
# else if [ ${{ github.ref }} = 'refs/heads/staging' ]; then
# echo "NEXT_PUBLIC_NODE_ENV=staging" >> $GITHUB_ENV
# else
# echo "NEXT_PUBLIC_NODE_ENV=test" >> $GITHUB_ENV
# fi
# - name: Run checks
# id: run-checks
# working-directory: next-webstore
# run: NEXT_PUBLIC_NODE_ENV=${{ env.NEXT_PUBLIC_NODE_ENV }} npx checkly test
# -e NEXT_PUBLIC_NODE_ENV=${{ env.NEXT_PUBLIC_NODE_ENV }} NEXT_PUBLIC_ENVIRONMENT_URL=${{ env.ENVIRONMENT_URL }} \
# --reporter=github
# --record
# - name: Create summary
# id: create-summary
# run: cat checkly-github-report.md > $GITHUB_STEP_SUMMARY
# - name: Deploy checks
# id: deploy-checks
# if: steps.run-checks.outcome == 'success' && github.ref == 'refs/heads/main'
# working-directory: next-webstore
# run: NEXT_PUBLIC_NODE_ENV=${{ env.NEXT_PUBLIC_NODE_ENV }} npx checkly deploy --force -e NEXT_PUBLIC_NODE_ENV=${{ env.NEXT_PUBLIC_NODE_ENV }} NEXT_PUBLIC_ENVIRONMENT_URL=${{ env.ENVIRONMENT_URL }}
# - name: Rollback
# if: steps.run-checks.outcome != 'success' && github.ref == 'refs/heads/main'
# run: |
# git revert HEAD
# git push origin main

# - name: Deploy checks
# if: steps.run-checks.outcome == 'success'
# working-directory: next-webstore
# run: |
# echo "yes" | NEXT_PUBLIC_NODE_ENV=${{ env.NEXT_PUBLIC_NODE_ENV }} npx checkly deploy --force -e NEXT_PUBLIC_NODE_ENV=${{ env.NEXT_PUBLIC_NODE_ENV }} NEXT_PUBLIC_ENVIRONMENT_URL=${{ env.ENVIRONMENT_URL }}


name: Checkly Fail Safe
on:
pull_request:
Expand Down
94 changes: 0 additions & 94 deletions next-webstore/app/components/bookCards.jsx
Original file line number Diff line number Diff line change
@@ -1,97 +1,3 @@
// "use client";

// import Link from "next/link";
// import BookProfile from "./bookProfile";
// import { useState, useEffect } from "react";

// async function fetchBooks() {
// try {
// const response = await fetch(`${NEXT_PUBLIC_ENVIRONMENT_URL}/api/v1/books`);
// const responseJSON = await response.json();
// const books = await responseJSON.data;
// return books;
// } catch (error) {
// console.log(error);
// }
// }

// const BookCards = () => {
// const [books, setBooks] = useState(null);

// useEffect(() => {
// async function getBooks() {
// const books = await fetchBooks();
// setBooks(books);
// }

// getBooks();
// }, []);

// const [selectedBook, setSelectedBook] = useState(null);

// const handleBookClick = (book) => {
// setSelectedBook(book);
// };

// return (
// <>
// {!selectedBook && (
// <div className="right-column">
// {books ? (
// <>
// {books.map((book) => (
// <div
// className="card"
// data-test={book.title}
// key={book.id}
// onClick={() => handleBookClick(book)}
// >
// <div
// data-test="book-div"
// style={{ display: "flex", justifyContent: "center", flexDirection: "column" }}
// >
// <h3 style={{ display: "flex", justifyContent: "center" }}>{book.title}</h3>
// <img
// style={{ display: "flex", justifyContent: "center" }}
// src="./gatsbycover.png"
// width="200"
// height="200"
// alt="User profile picture"
// />
// </div>

// <ul>
// <li> Author: {book.author}</li>
// <li> Publisher: {book.publisher}</li>
// <li>Genre: {book.genre}</li>
// <li> Price: {book.price}</li>
// </ul>
// <button className="btn" data-test="add-to-cart">
// add to cart
// </button>
// </div>
// ))}
// </>
// ) : (
// <h1>LOADING</h1>
// )}
// </div>
// )}
// {selectedBook && (
// <BookProfile
// id={selectedBook.id}
// author={selectedBook.author}
// publisher={selectedBook.publisher}
// title={selectedBook.title}
// genre={selectedBook.genre}
// />
// )}
// </>
// );
// };

// export default BookCards;

"use client";

import Link from "next/link";
Expand Down
4 changes: 1 addition & 3 deletions next-webstore/checkly.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { defineConfig } from 'checkly'
import {defaults} from './tests/defaults'
// set path in terminal when testing locally
require('dotenv').config()

const config = defineConfig({
Expand All @@ -18,7 +16,7 @@ const config = defineConfig({
checkMatch: "*/**/*.check.ts",
ignoreDirectoriesMatch: [],
browserChecks: {
frequency: 60,
frequency: 5,
testMatch: "*/**/*.spec.ts",
},
},
Expand Down
10 changes: 8 additions & 2 deletions next-webstore/tests/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
export const defaults = {
testTime: process.env.NEXT_PUBLIC_NODE_ENV === "production" || "staging" ? 60000 : 45000,
waitTime: process.env.NEXT_PUBLIC_NODE_ENV === "production" || "staging" ? 10000 : 5000,
testTime:
process.env.NEXT_PUBLIC_NODE_ENV === "production" || "staging"
? 60000
: 45000,
waitTime:
process.env.NEXT_PUBLIC_NODE_ENV === "production" || "staging"
? 10000
: 5000,
projectName: process.env.NEXT_PUBLIC_NODE_ENV,
testUser:
process.env.NEXT_PUBLIC_NODE_ENV === "production"
Expand Down
5 changes: 2 additions & 3 deletions next-webstore/tests/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defaults } from "./defaults";
test("login", async ({ page }) => {
test.setTimeout(defaults.testTime);

await page.goto(defaults.pageUrl)
await page.goto(defaults.pageUrl);

await page.getByRole("link", { name: "login" }).click();
await page.waitForLoadState("networkidle");
Expand All @@ -15,8 +15,7 @@ test("login", async ({ page }) => {
await page.getByRole("button", { name: "Login" }).click();

const response = await page.waitForResponse((response) => {
console.log(response.url(), "response url being hit")
// return response.url().includes(`${defaults.apiUrl}/auth/login`);
console.log(response.url(), "response url being hit");
return response.url().includes(`/auth/login`);
});
const responseBody = await response.json();
Expand Down
6 changes: 3 additions & 3 deletions next-webstore/tests/visit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { defaults } from "./defaults";
test("has title", async ({ page }) => {
test.setTimeout(60000);

console.log(defaults.pageUrl, "pageUrl")
await page.goto(defaults.pageUrl)
console.log(defaults.pageUrl, "pageUrl");

await page.goto(defaults.pageUrl);

const response = await page.waitForResponse(`${defaults.apiUrl}/books`);

Expand Down

2 comments on commit f3b635d

@vercel
Copy link

@vercel vercel bot commented on f3b635d May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f3b635d May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

next-danube-webshop – ./next-webstore

next-danube-webshop.vercel.app
next-danube-webshop-git-main-modern-sapien.vercel.app
next-danube-webshop-modern-sapien.vercel.app

Please sign in to comment.