mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-05-14 02:15:57 -04:00
Update browser extension e2e tests (#1404)
This commit is contained in:
@@ -228,6 +228,7 @@ const AddFieldMenu: React.FC<AddFieldMenuProps> = ({
|
||||
<div className="relative">
|
||||
<button
|
||||
type="button"
|
||||
id="add-field-menu"
|
||||
onClick={() => setIsOpen(!isOpen)}
|
||||
className="w-full px-4 py-2 border-2 border-dashed border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 rounded-md hover:border-primary-500 hover:text-primary-600 dark:hover:text-primary-400 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500 transition-colors flex items-center justify-center gap-2"
|
||||
>
|
||||
|
||||
@@ -620,6 +620,11 @@ const ItemAddEdit: React.FC = () => {
|
||||
|
||||
let updatedItem: Item = {
|
||||
...item,
|
||||
/*
|
||||
* For create mode, always generate a fresh ID to prevent UNIQUE constraint
|
||||
* violations if form persistence restored a previously saved item's ID.
|
||||
*/
|
||||
Id: isEditMode ? item.Id : crypto.randomUUID().toUpperCase(),
|
||||
Fields: fields,
|
||||
UpdatedAt: new Date().toISOString()
|
||||
};
|
||||
|
||||
@@ -176,6 +176,8 @@ export class TestClient {
|
||||
*/
|
||||
async goToVault(): Promise<this> {
|
||||
await this.popup.locator('#nav-vault').click();
|
||||
// Wait for the vault list to be ready (items list or add button visible)
|
||||
await this.popup.locator(ButtonSelectors.ADD_NEW_ITEM).waitFor({ state: 'visible', timeout: Timeouts.MEDIUM });
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -249,7 +251,7 @@ export class TestClient {
|
||||
*/
|
||||
async clickCredential(name: string): Promise<this> {
|
||||
await this.popup.locator(`text=${name}`).click();
|
||||
await this.popup.locator('button[title="Edit Credential"]').waitFor({ state: 'visible', timeout: Timeouts.SHORT });
|
||||
await this.popup.locator(ButtonSelectors.EDIT_ITEM).waitFor({ state: 'visible', timeout: Timeouts.SHORT });
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -257,7 +259,7 @@ export class TestClient {
|
||||
* Open the edit form for the currently viewed credential.
|
||||
*/
|
||||
async openEditForm(): Promise<this> {
|
||||
const editButton = this.popup.locator(ButtonSelectors.EDIT_CREDENTIAL);
|
||||
const editButton = this.popup.locator(ButtonSelectors.EDIT_ITEM);
|
||||
await expect(editButton).toBeVisible({ timeout: Timeouts.SHORT });
|
||||
await editButton.click();
|
||||
await expect(this.popup.locator(FieldSelectors.LOGIN_USERNAME)).toBeVisible({ timeout: Timeouts.MEDIUM });
|
||||
@@ -297,11 +299,17 @@ export class TestClient {
|
||||
|
||||
if (!isVisible) {
|
||||
// Click the add field menu button (dashed border button)
|
||||
await this.popup.click(ButtonSelectors.ADD_FIELD_MENU);
|
||||
// Click the Notes option in the dropdown
|
||||
await this.popup.click('button:has-text("Notes")');
|
||||
const addFieldButton = this.popup.locator(ButtonSelectors.ADD_FIELD_MENU);
|
||||
await expect(addFieldButton).toBeVisible({ timeout: Timeouts.SHORT });
|
||||
await addFieldButton.click();
|
||||
|
||||
// Wait for menu to appear and click the Notes option
|
||||
const notesOption = this.popup.locator('button:has-text("Notes")');
|
||||
await expect(notesOption).toBeVisible({ timeout: Timeouts.SHORT });
|
||||
await notesOption.click();
|
||||
|
||||
// Wait for notes field to appear
|
||||
await expect(this.popup.locator(FieldSelectors.LOGIN_NOTES)).toBeVisible({ timeout: Timeouts.SHORT });
|
||||
await expect(this.popup.locator(FieldSelectors.LOGIN_NOTES)).toBeVisible({ timeout: Timeouts.MEDIUM });
|
||||
}
|
||||
|
||||
return this.fillField(FieldSelectors.LOGIN_NOTES, notes);
|
||||
|
||||
@@ -17,7 +17,7 @@ export const FieldKey = {
|
||||
LoginUsername: 'login.username',
|
||||
LoginPassword: 'login.password',
|
||||
LoginUrl: 'login.url',
|
||||
MetadataNotes: 'metadata.notes',
|
||||
NotesContent: 'notes.content',
|
||||
CardNumber: 'card.number',
|
||||
CardCardholderName: 'card.cardholder_name',
|
||||
CardExpiryMonth: 'card.expiry_month',
|
||||
@@ -53,8 +53,8 @@ export const FieldSelectors = {
|
||||
LOGIN_PASSWORD: `input#${escapeFieldKey(FieldKey.LoginPassword)}`,
|
||||
LOGIN_URL: `input#${escapeFieldKey(FieldKey.LoginUrl)}-0`, // Multi-value field uses -0 suffix for first entry
|
||||
|
||||
// Metadata fields (shared across item types)
|
||||
LOGIN_NOTES: `textarea#${escapeFieldKey(FieldKey.MetadataNotes)}`,
|
||||
// Notes field (shared across item types)
|
||||
LOGIN_NOTES: `textarea#${escapeFieldKey(FieldKey.NotesContent)}`,
|
||||
|
||||
// Card fields
|
||||
CARD_NUMBER: `input#${escapeFieldKey(FieldKey.CardNumber)}`,
|
||||
@@ -82,7 +82,7 @@ export const FieldSelectors = {
|
||||
*/
|
||||
export const ButtonSelectors = {
|
||||
ADD_NEW_ITEM: 'button[title="Add new item"]',
|
||||
EDIT_CREDENTIAL: 'button[title="Edit Credential"]',
|
||||
EDIT_ITEM: 'button[title="Edit Item"]',
|
||||
SAVE: 'button#save-credential',
|
||||
ADD_FIELD_MENU: 'button.border-dashed',
|
||||
ADD_FIELD_MENU: 'button#add-field-menu',
|
||||
} as const;
|
||||
|
||||
Reference in New Issue
Block a user