Skip to content

Commit

Permalink
Add page instance
Browse files Browse the repository at this point in the history
  • Loading branch information
benmalcom committed Aug 2, 2024
1 parent eea4bb8 commit fccdca1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
29 changes: 15 additions & 14 deletions packages/near-fast-auth-signer-e2e-tests/pages/AuthCallBackPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,23 @@ class AuthCallBackPage {
return emailData.uidl;
}

async handleInPageAccountCreation(email: string) {
await expect(this.page.getByText('Oops! This account doesn\'t seem to exist. Please create one below.')).toBeVisible();
await expect(this.page.locator('[data-testid="email_create"]')).toHaveValue(email);
await expect(this.page.locator('[data-testid="username_create"]')).toHaveValue(getEmailId(email));
await this.page.waitForSelector('button:has-text("Continue"):enabled');
await this.page.click('button:has-text("Continue")');
// eslint-disable-next-line class-methods-use-this
async handleInPageAccountCreation(email: string, page: Page) {
await expect(page.getByText('Oops! This account doesn\'t seem to exist. Please create one below.')).toBeVisible();
await expect(page.locator('[data-testid="email_create"]')).toHaveValue(email);
await expect(page.locator('[data-testid="username_create"]')).toHaveValue(getEmailId(email));
await page.waitForSelector('button:has-text("Continue"):enabled');
await page.click('button:has-text("Continue")');

await this.page.locator('text=Loading...').waitFor({ state: 'visible' });
await expect(this.page.getByText('Loading...')).toBeVisible();
await this.page.locator('text=Loading...').waitFor({ state: 'hidden' });
await expect(this.page.getByText('Loading...')).not.toBeVisible();
await page.locator('text=Loading...').waitFor({ state: 'visible' });
await expect(page.getByText('Loading...')).toBeVisible();
await page.locator('text=Loading...').waitFor({ state: 'hidden' });
await expect(page.getByText('Loading...')).not.toBeVisible();

await this.page.locator('text=Redirecting to app...').waitFor({ state: 'visible' });
await expect(this.page.getByText('Redirecting to app...')).toBeVisible();
await this.page.locator('text=Redirecting to app...').waitFor({ state: 'hidden' });
await expect(this.page.getByText('Redirecting to app...')).not.toBeVisible();
await page.locator('text=Redirecting to app...').waitFor({ state: 'visible' });
await expect(page.getByText('Redirecting to app...')).toBeVisible();
/* await page.locator('text=Redirecting to app...').waitFor({ state: 'hidden' });
await expect(page.getByText('Redirecting to app...')).not.toBeVisible(); */
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ test('should create account if logged in with an unregistered account details ',
creationKeypair: KeyPair.fromRandom('ED25519'),
retrievalKeypair: KeyPair.fromRandom('ED25519'),
});
await pm.getAuthCallBackPage().handleInPageAccountCreation(email);
await pm.getAuthCallBackPage().handleInPageAccountCreation(email, page);
await pm.getAppPage().isLoggedIn();
});

0 comments on commit fccdca1

Please sign in to comment.