feat: convert "user token" tests to Playwright (#54939)

This commit is contained in:
Sem Bauke
2024-05-24 22:55:29 +02:00
committed by GitHub
parent 1f9da71b5e
commit 263fc81b62
3 changed files with 39 additions and 39 deletions
+35
View File
@@ -0,0 +1,35 @@
import { execSync } from 'child_process';
import { test, expect } from '@playwright/test';
test.use({ storageState: 'playwright/.auth/development-user.json' });
test.beforeEach(() => {
execSync('node ./tools/scripts/seed/seed-demo-user');
});
test.afterAll(() => {
execSync('node ./tools/scripts/seed/seed-demo-user certified-user');
});
test.describe('Initially', () => {
test('should not render', async ({ page }) => {
await page.goto('/settings');
await expect(page.getByTestId('user-token')).not.toBeVisible();
});
});
test.describe('After creating token', () => {
test('should allow you to delete your token', async ({ page }) => {
await page.goto(
'/learn/relational-database/learn-bash-by-building-a-boilerplate/build-a-boilerplate'
);
await page.getByRole('button', { name: 'Start the course' }).click();
await page.goto('/settings');
await expect(page.getByTestId('user-token')).toBeVisible();
await page.getByRole('button', { name: 'Delete my user token' }).click();
await expect(page.getByTestId('flash-message')).toContainText(
/Your user token has been deleted./
);
await expect(page.getByTestId('user-token')).not.toBeVisible();
});
});