Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

Commit bc4c292

Browse files
authored
Merge pull request #41 from HellPat/better-reloads
tests with recursion
2 parents 15b81ef + e59c862 commit bc4c292

7 files changed

Lines changed: 36 additions & 21 deletions

File tree

.github/workflows/main.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,7 @@ jobs:
7272
shell: bash
7373
run: |
7474
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
75-
- uses: actions/cache@v4
76-
name: Setup pnpm cache
77-
with:
78-
path: ${{ env.STORE_PATH }}
79-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
80-
restore-keys: |
81-
${{ runner.os }}-pnpm-store-
75+
# TODO: add cache for node_modules
8276
- name: Install dependencies
8377
run: pnpm install --frozen-lockfile --strict-peer-dependencies
8478
- shell: nix-shell --pure --run "bash -euxo pipefail {0}"

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ symfony: rr serve -p -c .rr.dev.yaml --debug
77
# TODO: rethink limits and restarts.
88
# I set a time limit and a limit of jobs to process, to easy using xdebug.
99
# Xdebug listening must be started in the IDE, and the long running process must be restarted to take effect.
10-
symfony-message-consumer: symfony run --watch=config,src,vendor bin/console messenger:consume async --limit=10 --time-limit=300 --no-interaction -vv
10+
symfony-message-consumer: bin/console messenger:consume async --limit=100 --time-limit=3000 --no-interaction -vv
1111

1212
stripe: stripe listen --skip-verify --forward-to localhost:8000/webhook/stripe
1313
tailwindcss: tailwindcss -i assets/styles/app.css -o assets/styles/app.tailwind.css --watch
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// <reference types="cypress" />
22
import Stripe from 'stripe';
33
import { ulid } from 'ulid';
4+
import 'cypress-recurse/commands'
45

56
// TODO: move to environment variable
67
// set your api key with an environment variable `CYPRESS_API_KEY` or configure using `env` property in config file
@@ -21,18 +22,23 @@ describe('customers', () => {
2122

2223
it('it adds new stripe users to the list', async () => {
2324
const email = `customer-${ulid()}@e2e.com`;
24-
const customer = (await stripe.customers.create({
25+
await stripe.customers.create({
2526
email: email,
26-
}))
27-
28-
const id = customer.id;
27+
})
2928

30-
// TODO: retry the reload until it's there
31-
// waiting is bad, as it slows down the tests
32-
cy.wait(5000)
33-
cy.reload()
34-
35-
// check if the email address is visible in the list of customers
36-
cy.get('[data-test="customer.list"] tbody > tr').contains(email)
29+
cy.recurse(
30+
() => cy.get(`[data-test-customer-email="${email}"]`).should(Cypress._.noop),
31+
(el) => {
32+
return el && el.text() === email
33+
},
34+
{
35+
limit: 10,
36+
delay: 2000, // sleep for 2 second before reloading the page
37+
timeout: 60000, // retry for 60 seconds
38+
post: () => {
39+
cy.reload()
40+
},
41+
},
42+
)
3743
})
3844
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"packageManager": "pnpm@8.14.3",
33
"devDependencies": {
44
"cypress": "^13.6.3",
5+
"cypress-recurse": "^1.35.2",
56
"stripe": "^14.13.0",
67
"ulid": "^2.3.0"
78
}

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pkgs.mkShell {
5252
];
5353

5454
shellHook = ''
55+
export OVERMIND_AUTO_RESTART=all
5556
export MYSQL_HOME=''${PWD}/storage/mysql
5657
export MYSQL_DATADIR=''${PWD}/storage/mysql/data
5758
export MYSQL_UNIX_PORT=''${PWD}/.mysql.sock

templates/customer/list.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% block main %}
44
<h1>Customers</h1>
55

6-
<table data-test="customer.list">
6+
<table>
77
<thead>
88
<tr>
99
<th>id</th>
@@ -16,7 +16,7 @@
1616
{% for customer in customers %}
1717
<tr>
1818
<td>{{ customer.id }}</td>
19-
<td>{{ customer.email }}</td>
19+
<td data-test-customer-email="{{ customer.email }}">{{ customer.email }}</td>
2020
<td>{{ customer.name }}</td>
2121
<td>{{ customer.createdAt|date }}</td>
2222
</tr>

0 commit comments

Comments
 (0)