Add account deletion process and improve tests

The commit introduces a message to indicate the account deletion process. It also enhances the tests by reducing code redundancy in the e2e tests, creating a more random name for team accounts, and improving the navigation process after account deletions. The commit also includes code cleanup tasks, such as the removal of unused imports.
This commit is contained in:
giancarlo
2024-04-12 21:30:13 +08:00
parent 2bad506d75
commit 21fba33462
6 changed files with 13 additions and 21 deletions

View File

@@ -55,10 +55,6 @@ test.describe('Account Deletion', () => {
await account.setup(); await account.setup();
await account.deleteAccount(); await account.deleteAccount();
await page.waitForURL('http://localhost:3000', { await account.auth.goToSignIn();
timeout: 5000,
});
expect(page.url()).toEqual('http://localhost:3000/');
}); });
}); });

View File

@@ -37,10 +37,6 @@ export class TeamAccountsPageObject {
await this.page.click('[data-test="create-team-account-trigger"]'); await this.page.click('[data-test="create-team-account-trigger"]');
await this.page.fill('[data-test="create-team-form"] input', teamName); await this.page.fill('[data-test="create-team-form"] input', teamName);
await this.page.click('[data-test="create-team-form"] button:last-child'); await this.page.click('[data-test="create-team-form"] button:last-child');
await this.page.waitForURL(`http://localhost:3000/home/${slug}`, {
timeout: 5000,
});
} }
async updateName(name: string) { async updateName(name: string) {
@@ -58,7 +54,7 @@ export class TeamAccountsPageObject {
} }
createTeamName() { createTeamName() {
const random = (Math.random() * 10).toFixed(0); const random = (Math.random() * 100000000).toFixed(0);
const teamName = `Team-Name-${random}`; const teamName = `Team-Name-${random}`;
const slug = `team-name-${random}`; const slug = `team-name-${random}`;

View File

@@ -8,11 +8,11 @@ test.describe('Team Accounts', () => {
test.beforeAll(async ({ browser }) => { test.beforeAll(async ({ browser }) => {
page = await browser.newPage(); page = await browser.newPage();
teamAccounts = new TeamAccountsPageObject(page); teamAccounts = new TeamAccountsPageObject(page);
await teamAccounts.setup();
}); });
test('user can update their team name (and slug)', async () => { test('user can update their team name (and slug)', async () => {
await teamAccounts.setup();
const {teamName, slug} = teamAccounts.createTeamName(); const {teamName, slug} = teamAccounts.createTeamName();
await teamAccounts.goToSettings(); await teamAccounts.goToSettings();
@@ -35,12 +35,6 @@ test.describe('Account Deletion', () => {
await teamAccounts.deleteAccount(params.teamName); await teamAccounts.deleteAccount(params.teamName);
await page.waitForURL('http://localhost:3000/home', {
timeout: 5000,
});
expect(page.url()).toEqual('http://localhost:3000/home');
await expect(await teamAccounts.getTeamFromSelector(params.slug)).not.toBeVisible(); await expect(await teamAccounts.getTeamFromSelector(params.slug)).not.toBeVisible();
}); });
}); });

View File

@@ -131,6 +131,7 @@
"dangerZone": "Danger Zone", "dangerZone": "Danger Zone",
"dangerZoneDescription": "Some actions cannot be undone. Please be careful.", "dangerZoneDescription": "Some actions cannot be undone. Please be careful.",
"deleteAccount": "Delete your Account", "deleteAccount": "Delete your Account",
"deletingAccount": "Deleting account. Please wait...",
"deleteAccountDescription": "This will delete your account and the organizations you own. Furthermore, we will immediately cancel any active subscriptions. This action cannot be undone. You will be asked to confirm this action in the next step.", "deleteAccountDescription": "This will delete your account and the organizations you own. Furthermore, we will immediately cancel any active subscriptions. This action cannot be undone. You will be asked to confirm this action in the next step.",
"deleteProfileConfirmationInputLabel": "Type DELETE to confirm", "deleteProfileConfirmationInputLabel": "Type DELETE to confirm",
"deleteAccountErrorHeading": "Sorry, we couldn't delete your account", "deleteAccountErrorHeading": "Sorry, we couldn't delete your account",

View File

@@ -142,7 +142,11 @@ function DeleteAccountSubmitButton() {
name={'action'} name={'action'}
variant={'destructive'} variant={'destructive'}
> >
<Trans i18nKey={'account:deleteAccount'} /> {pending ? (
<Trans i18nKey={'account:deletingAccount'} />
) : (
<Trans i18nKey={'account:deleteAccount'} />
)}
</Button> </Button>
); );
} }

View File

@@ -1,7 +1,7 @@
'use server'; 'use server';
import { revalidatePath } from 'next/cache'; import { revalidatePath } from 'next/cache';
import { RedirectType, redirect } from 'next/navigation'; import { redirect } from 'next/navigation';
import { z } from 'zod'; import { z } from 'zod';
@@ -66,10 +66,11 @@ export async function deletePersonalAccountAction(formData: FormData) {
// sign out the user after deleting their account // sign out the user after deleting their account
await client.auth.signOut(); await client.auth.signOut();
// clear the cache for all pages
revalidatePath('/', 'layout'); revalidatePath('/', 'layout');
// redirect to the home page // redirect to the home page
redirect('/', RedirectType.replace); redirect('/');
} }
function getEmailSettingsFromEnvironment() { function getEmailSettingsFromEnvironment() {