From 54a99bdf2fff3ec7f6c210f191d3b6417daa999f Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 15 Feb 2024 19:38:11 +0000 Subject: [PATCH 1/5] test(playwright): add CRUD test --- .../pages/Account/Authentication.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/playwright/pages/Account/Authentication.ts b/tests/playwright/pages/Account/Authentication.ts index 13ff61bc4d..162254687e 100644 --- a/tests/playwright/pages/Account/Authentication.ts +++ b/tests/playwright/pages/Account/Authentication.ts @@ -44,7 +44,7 @@ export class AccountAuthenticationPage extends BasePage { }); } - async toggleProvider(provider: 'saml' | 'oidc', title: string) { + async toggleProvider(provider: 'saml' | 'oidc' | 'google', title: string) { await this.waitForResponse({ uiAction: () => this.get().locator(`.nc-${provider}-${title}-enable .nc-switch`).click(), httpMethodsToMatch: ['PATCH'], @@ -159,4 +159,25 @@ export class AccountAuthenticationPage extends BasePage { requestUrlPathToMatch: '/api/v2/sso-client', }); } + + async createGoogleProvider(p: { clientId: string; clientSecret: string }) { + await this.rootPage.locator(`.nc-google-more-option`).click(); + await this.rootPage.locator(`[data-test-id="nc-google-edit"]`).click(); + + const googleModal = this.accountPage.rootPage.locator('.nc-google-modal'); + // wait until redirect url is generated + await googleModal.locator('[data-test-id="nc-google-redirect-url"]:has-text("http://")').waitFor(); + + await googleModal.locator('[data-test-id="nc-google-client-id"]').fill(p.clientId); + + await googleModal.locator('[data-test-id="nc-google-client-secret"]').fill(p.clientSecret); + + await this.waitForResponse({ + uiAction: () => googleModal.locator('[data-test-id="nc-google-save-btn"]').click(), + httpMethodsToMatch: ['GET'], + requestUrlPathToMatch: '/api/v2/sso-client', + }); + } + + async verifyGoogleProviderCount(param: { count: number }) {} } From 358b160100406fc03efd0eb744e8b8cdcf8a83a3 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 15 Feb 2024 19:38:11 +0000 Subject: [PATCH 2/5] test(playwright): google signin verification --- .../pages/SsoIdpPage/GoogleLoginPage.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/playwright/pages/SsoIdpPage/GoogleLoginPage.ts diff --git a/tests/playwright/pages/SsoIdpPage/GoogleLoginPage.ts b/tests/playwright/pages/SsoIdpPage/GoogleLoginPage.ts new file mode 100644 index 0000000000..23aedca43f --- /dev/null +++ b/tests/playwright/pages/SsoIdpPage/GoogleLoginPage.ts @@ -0,0 +1,31 @@ +import { Page } from '@playwright/test'; +import BasePage from '../Base'; +import { ProjectsPage } from '../ProjectsPage'; +import { expect } from '@playwright/test'; + +export class GoogleLoginPage extends BasePage { + readonly projectsPage: ProjectsPage; + + constructor(rootPage: Page) { + super(rootPage); + this.projectsPage = new ProjectsPage(rootPage); + } + + async goto(title = 'test') { + // reload page to get latest app info + await this.rootPage.reload({ waitUntil: 'networkidle' }); + // click sign in with SAML + await this.rootPage.locator(`button:has-text("Sign in with google")`).click(); + + await this.rootPage.waitForNavigation({ url: /accounts\.google\.com/ }); + } + + get() { + return this.rootPage.locator('html'); + } + + async signIn(_: { email: string }) { + // skipping for now as it requires google account + // todo: later we can mock backend(google oauth2 endpoint calls) to test this + } +} From a1712b8967a452a8f9a8831af89e3906ead13a95 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 15 Feb 2024 19:38:12 +0000 Subject: [PATCH 3/5] test(playwright): classname correction --- tests/playwright/pages/Account/Authentication.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/playwright/pages/Account/Authentication.ts b/tests/playwright/pages/Account/Authentication.ts index 162254687e..498ffa1775 100644 --- a/tests/playwright/pages/Account/Authentication.ts +++ b/tests/playwright/pages/Account/Authentication.ts @@ -35,8 +35,10 @@ export class AccountAuthenticationPage extends BasePage { return this.rootPage.locator(`[data-test-id="nc-${provider}-provider-${title}"]`); } - async deleteProvider(provider: 'saml' | 'oidc', title: string) { - await this.rootPage.locator(`.nc-${provider}-${title}-more-option`).click(); + async deleteProvider(provider: 'saml' | 'oidc' | 'google', title: string) { + await this.rootPage + .locator(provider === 'google' ? '.nc-google-more-option' : `.nc-${provider}-${title}-more-option`) + .click(); await this.waitForResponse({ uiAction: () => this.rootPage.locator(`[data-test-id="nc-${provider}-delete"]`).click(), httpMethodsToMatch: ['DELETE'], From 515585091c72e3628c5cd74718ed273f07c2365a Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 15 Feb 2024 19:38:12 +0000 Subject: [PATCH 4/5] test(playwright): change button selector with `a` --- tests/playwright/pages/SsoIdpPage/GoogleLoginPage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/playwright/pages/SsoIdpPage/GoogleLoginPage.ts b/tests/playwright/pages/SsoIdpPage/GoogleLoginPage.ts index 23aedca43f..c6925639ce 100644 --- a/tests/playwright/pages/SsoIdpPage/GoogleLoginPage.ts +++ b/tests/playwright/pages/SsoIdpPage/GoogleLoginPage.ts @@ -15,7 +15,7 @@ export class GoogleLoginPage extends BasePage { // reload page to get latest app info await this.rootPage.reload({ waitUntil: 'networkidle' }); // click sign in with SAML - await this.rootPage.locator(`button:has-text("Sign in with google")`).click(); + await this.rootPage.locator(`a:has-text("Sign in with google")`).click(); await this.rootPage.waitForNavigation({ url: /accounts\.google\.com/ }); } From b14492ac178128598ac6eef60679f6a0fa4b5db9 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 15 Feb 2024 19:38:12 +0000 Subject: [PATCH 5/5] fix: wrap with div if root element is NuxtLayout to avoid navigation error --- packages/nc-gui/layouts/general.vue | 8 +- packages/nc-gui/pages/account/index.vue | 292 +++++++++--------- packages/nc-gui/pages/forgot-password.vue | 107 ++++--- .../pages/index/[typeOrId]/form/[viewId].vue | 66 ++-- .../nc-gui/pages/profile/[[username]].vue | 264 ++++++++-------- packages/nc-gui/pages/projects/index.vue | 154 ++++----- packages/nc-gui/pages/reset/[id].vue | 118 +++---- packages/nc-gui/pages/signin.vue | 190 ++++++------ packages/nc-gui/pages/signup/[[token]].vue | 216 ++++++------- 9 files changed, 721 insertions(+), 694 deletions(-) diff --git a/packages/nc-gui/layouts/general.vue b/packages/nc-gui/layouts/general.vue index e5afe7638a..03f1c0bd50 100644 --- a/packages/nc-gui/layouts/general.vue +++ b/packages/nc-gui/layouts/general.vue @@ -5,7 +5,9 @@ export default { diff --git a/packages/nc-gui/pages/account/index.vue b/packages/nc-gui/pages/account/index.vue index c5794cb785..14c803ad3f 100644 --- a/packages/nc-gui/pages/account/index.vue +++ b/packages/nc-gui/pages/account/index.vue @@ -28,177 +28,179 @@ const logout = async () => {