feat(core): add sign out confirm modal (#4592)

This commit is contained in:
JimmFly
2023-10-16 16:44:09 +08:00
committed by GitHub
parent c1d386d932
commit 07b5d18441
13 changed files with 199 additions and 50 deletions

View File

@@ -18,6 +18,7 @@ import {
} from '@affine-test/kit/utils/setting';
import {
clickSideBarAllPageButton,
clickSideBarCurrentWorkspaceBanner,
clickSideBarSettingButton,
} from '@affine-test/kit/utils/sidebar';
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
@@ -189,6 +190,7 @@ test.describe('collaboration', () => {
await clickSideBarSettingButton(page);
await clickUserInfoCard(page);
await page.getByTestId('sign-out-button').click();
await page.getByTestId('confirm-sign-out-button').click();
await page.waitForTimeout(5000);
expect(page.url()).toBe(url);
});
@@ -260,3 +262,26 @@ test.describe('collaboration members', () => {
expect(await page.locator('[data-testid="member-item"]').count()).toBe(3);
});
});
test.describe('sign out', () => {
test('can sign out', async ({ page }) => {
await page.reload();
await waitForEditorLoad(page);
await createLocalWorkspace(
{
name: 'test',
},
page
);
await clickSideBarAllPageButton(page);
const currentUrl = page.url();
await clickSideBarCurrentWorkspaceBanner(page);
await page.getByTestId('workspace-modal-account-option').click();
await page.getByTestId('workspace-modal-sign-out-option').click();
await page.getByTestId('confirm-sign-out-button').click();
await clickSideBarCurrentWorkspaceBanner(page);
const signInButton = page.getByTestId('cloud-signin-button');
await expect(signInButton).toBeVisible();
expect(page.url()).toBe(currentUrl);
});
});

View File

@@ -2,7 +2,10 @@ import { platform } from 'node:os';
import { test } from '@affine-test/kit/electron';
import { getBlockSuiteEditorTitle } from '@affine-test/kit/utils/page-logic';
import { clickSideBarSettingButton } from '@affine-test/kit/utils/sidebar';
import {
clickSideBarCurrentWorkspaceBanner,
clickSideBarSettingButton,
} from '@affine-test/kit/utils/sidebar';
import { expect } from '@playwright/test';
test('new page', async ({ page, workspace }) => {
@@ -156,7 +159,7 @@ test('windows only check', async ({ page }) => {
});
test('delete workspace', async ({ page }) => {
await page.getByTestId('current-workspace').click();
await clickSideBarCurrentWorkspaceBanner(page);
await page.getByTestId('new-workspace').click();
await page
.getByTestId('create-workspace-input')

View File

@@ -1,6 +1,7 @@
import path from 'node:path';
import { test } from '@affine-test/kit/electron';
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
import { expect } from '@playwright/test';
import fs from 'fs-extra';
@@ -85,7 +86,7 @@ test.fixme('export then add', async ({ page, appInfo, workspace }) => {
// add workspace
// we are reusing the same db file so that we don't need to maintain one
// in the codebase
await page.getByTestId('current-workspace').click();
await clickSideBarCurrentWorkspaceBanner(page);
await page.getByTestId('add-or-new-workspace').click();
await page.evaluate(tmpPath => {

View File

@@ -7,7 +7,7 @@ test('goto not found page', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
const currentUrl = page.url();
const invalidUrl = currentUrl.replace('hello-world', 'invalid');
const invalidUrl = currentUrl.concat('invalid');
await page.goto(invalidUrl);
await expect(page.getByTestId('not-found')).toBeVisible({
timeout: 10000,

View File

@@ -9,7 +9,12 @@ import {
} from '@affine-test/kit/utils/sidebar';
import { faker } from '@faker-js/faker';
import { hash } from '@node-rs/argon2';
import type { BrowserContext, Cookie, Page } from '@playwright/test';
import {
type BrowserContext,
type Cookie,
expect,
type Page,
} from '@playwright/test';
import { z } from 'zod';
export async function getCurrentMailMessageCount() {
@@ -176,8 +181,33 @@ export async function enableCloudWorkspace(page: Page) {
await waitForEditorLoad(page);
await clickNewPageButton(page);
}
export async function enableCloudWorkspaceFromShareButton(page: Page) {
await page.getByTestId('local-share-menu-button').click();
const shareMenuButton = page.getByTestId('local-share-menu-button');
expect(await shareMenuButton.isVisible()).toBeTruthy();
// FIXME: this is a workaround for the flaky test
// For unknown reasons,
// the online ci test on GitHub is unable to detect the local-share-menu,
// although it works fine in local testing.
// To ensure the tests pass consistently, Ive made the following temporary adjustments.
// {
const maxAttempts = 5;
let attempt = 0;
let menuVisible = false;
while (!menuVisible && attempt < maxAttempts) {
try {
await shareMenuButton.click();
menuVisible = await page.getByTestId('local-share-menu').isVisible();
} catch (e) {
console.error(`Attempt ${attempt + 1} failed: ${e}`);
attempt += 1;
}
}
expect(menuVisible).toBeTruthy();
// }
await page.getByTestId('share-menu-enable-affine-cloud-button').click();
await page.getByTestId('confirm-enable-affine-cloud-button').click();
// wait for upload and delete local workspace