Skip to content

Commit

Permalink
[test] Add test switch account
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusefendi52 committed Dec 6, 2024
1 parent fa44d4a commit d9de085
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion components/BottomMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const items = ref([{
})
}
}])
if (process.client) {
if (import.meta.client) {
const userTokens = useLocalStorage<UserTokenInfo[]>(userTokensKey, [])
watchEffect(() => {
items.value = [
Expand Down
2 changes: 1 addition & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const router = useRouter()
const cookie = useCookie(cookieAuthKey)
const isLoggedIn = computed(() => cookie.value ? true : false)
if (isLoggedIn.value) {
if (process.client) {
if (import.meta.client) {
const userToken = route.query.usr?.toString()
const userEmail = route.query.e?.toString()
const userTokens = useLocalStorage<UserTokenInfo[]>(userTokensKey, [])
Expand Down
4 changes: 2 additions & 2 deletions plugins/vue-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export default defineNuxtPlugin((nuxt) => {

nuxt.vueApp.use(VueQueryPlugin, options)

if (process.server) {
if (import.meta.server) {
nuxt.hooks.hook('app:rendered', () => {
vueQueryState.value = dehydrate(queryClient)
})
}

if (process.client) {
if (import.meta.client) {
nuxt.hooks.hook('app:created', () => {
hydrate(queryClient, vueQueryState.value)
})
Expand Down
8 changes: 8 additions & 0 deletions tests-e2e/home-not-signed.test.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from '@nuxt/test-utils/playwright'

test.use({ storageState: { cookies: [], origins: [] } });

test('Can open distapp and show get started', async ({ page, goto, context }) => {
await goto('/')
await expect(page.getByText('Get Started')).toHaveCount(1)
})
6 changes: 0 additions & 6 deletions tests-e2e/home.test.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { expect, test } from '@nuxt/test-utils/playwright'

test('Can open distapp and show get started', async ({ page, goto, context }) => {
await context.clearCookies()
await goto('/')
await expect(page.getByText('Get Started')).toHaveCount(1)
})

test('Logged in user open distapp and show go to apps', async ({ page, goto, context }) => {
await goto('/')
await expect(page.getByText('Go To Apps')).toHaveCount(1)
Expand Down
10 changes: 9 additions & 1 deletion tests-e2e/switch-account.test.mts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { expect, test } from '@nuxt/test-utils/playwright'

test.skip('Add and switch account', async ({ page, goto, context }) => {
test.use({ storageState: { cookies: [], origins: [] } });

test('Add and switch account', async ({ page, goto, context }) => {
await goto('/')
await page.getByText('Get Started').click()

await page.locator('[name="username"]').fill('usertest1')
await page.locator('[name="password"]').fill('a5756f781e0e433986364b82de545c3b')
await page.getByTestId('sign_in_btn').click()

await page.getByText('Go To Apps').click()

await page.getByTestId('b_more_btn').click()
Expand Down

0 comments on commit d9de085

Please sign in to comment.