Skip to content

Commit

Permalink
feat: update probe adoption selector
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Nov 25, 2024
1 parent a67dd37 commit 26a869a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"prepare": "husky install || echo 'Failed to install husky'; rm -f .eslintcache",
"test:e2e": "npm run test:e2e:build:directus && npm run test:e2e:build:dash && npm run test:e2e:run",
"test:e2e:build:directus": "docker compose -f docker-compose.e2e.yml up --build -d && pnpm run init:e2e && docker compose -f docker-compose.e2e.yml stop",
"test:e2e:build:dash": "git clone -b e2e https://github.com/jsdelivr/globalping-dash.git test/e2e/globalping-dash; cd test/e2e/globalping-dash && git add . && git reset --hard && git pull --force && pnpm install --ignore-workspace && dotenv -e ../../../.env -- pnpm build; cd ../../../;",
"test:e2e:build:dash": "git clone -b e2e https://github.com/jsdelivr/globalping-dash.git test/e2e/globalping-dash; cd test/e2e/globalping-dash && git reset --hard origin/e2e && git pull --force && pnpm install --ignore-workspace && dotenv -e ../../../.env -- pnpm build; cd ../../../;",
"test:e2e:run": "pnpm exec playwright test --grep-invert='.*generate-test\\.spec\\.ts'",
"test:e2e:generate": "pnpm exec playwright test test/e2e/generate-test.spec.ts --headed"
},
Expand Down
24 changes: 19 additions & 5 deletions test/e2e/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const addData = async (user: User) => {
user_updated: null,
adopted_probe: probeId,
},
...[ -20, -50, -80 ].map(daysAgo => ({
...[ -2, -32, -62 ].map(daysAgo => ({
amount: 1000,
comment: 'Recurring $5 sponsorship.',
consumed: 1,
Expand All @@ -83,11 +83,8 @@ const addData = async (user: User) => {
await sql('gp_credits').where({ user_id: user.id }).update({ amount: sql.raw('amount - ?', [ 1000 ]) });
};

test.beforeEach(async ({ user }) => {
test('Index page', async ({ page, user }) => {
await addData(user);
});

test('Index page', async ({ page }) => {
await page.goto('/');
await expect(page.locator('h1')).toHaveText('Overview');
await expect(page.getByLabel('Profile')).toHaveText('johndoe');
Expand All @@ -98,3 +95,20 @@ test('Index page', async ({ page }) => {
await expect(page.getByTestId('credits-from-probes')).toHaveText('+300');
await expect(page.getByTestId('credits-from-sponsorship')).toHaveText('+1,000');
});

test('Show recurring sponsorships up to 35 days ago', async ({ page, user }) => {
await sql('gp_credits_additions').insert([
...[ -32 ].map(daysAgo => ({
amount: 1000,
comment: 'Recurring $5 sponsorship.',
consumed: 1,
date_created: relativeDayUtc(daysAgo),
github_id: user.external_identifier,
user_updated: null,
adopted_probe: null,
})),
]);

await page.goto('/');
await expect(page.getByTestId('credits-from-sponsorship')).toHaveText('+1,000');
});
2 changes: 1 addition & 1 deletion test/e2e/tests/probes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test('Probe adoption', async ({ page }) => {
await page.getByLabel('Next step').click();
await page.getByPlaceholder('Enter IP address of your probe').fill('2.2.2.2');
await page.getByLabel('Send adoption code').click();
await page.locator('input:nth-child(3)').fill('111111');
await page.getByTestId('adoption-code').locator('input').first().fill('111111');
await page.getByLabel('Verify the code').click();
await page.getByLabel('Finish').click();
await expect(page.getByText('probe-bf-ouagadougou-01').first()).toBeVisible();
Expand Down

0 comments on commit 26a869a

Please sign in to comment.