Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creates tests workflows file and adjusts article dates and toasts #1

Merged
merged 9 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/trigger-cypress-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# name: Trigger Cypress Tests

# on:
# pull_request:
# branches:
# - main

# jobs:
# trigger-tests:
# runs-on: ubuntu-latest

# permissions:
# contents: write
# actions: write

# steps:
# - name: Trigger Cypress Tests in Another Repo
# run: |
# curl -X POST \
# -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
# -H "Accept: application/vnd.github.v3+json" \
# https://api.github.com/repos/vinicioscst/newsletter-tests/actions/workflows/cypress-tests.yml/dispatches \
# -d '{"ref":"main"}'
16 changes: 6 additions & 10 deletions components/ArticleCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,18 @@ export default {
},
computed: {
formattedDate() {
if (!this.articleData.publishedAt) return ''

const articleDate = new Date(this.articleData.publishedAt)
const articleDate = new Date(this.articleData.createdAt)
const today = new Date()
const millisecondsDiff = today.getTime() - articleDate.getTime()
const daysDiff = Math.round(millisecondsDiff / (24 * 60 * 60 * 1000))
const dateText = new Intl.RelativeTimeFormat('pt-br', {
style: 'short',
}).format(daysDiff * -1, 'day')

return new Intl.RelativeTimeFormat('pt-br', { style: 'short' }).format(
daysDiff * -1,
'day'
)
return `Gerado ${dateText}`
},
formattedDateTitle() {
if (!this.articleData.publishedAt) return ''

const articleDate = new Date(this.articleData.publishedAt)
const articleDate = new Date(this.articleData.createdAt)

return new Intl.DateTimeFormat('pt-BR').format(articleDate)
},
Expand Down
3 changes: 3 additions & 0 deletions components/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
name="email"
label="Email"
outlined
data-test="login-form-email"
/>
<v-text-field
v-model="password"
Expand All @@ -24,6 +25,7 @@
label="Senha"
@click:append="show = !show"
outlined
data-test="login-form-password"
/>
<v-btn
color="orange darken-3"
Expand All @@ -32,6 +34,7 @@
type="submit"
:loading="loading"
:disabled="!fieldIsValid || loading"
data-test="login-form-button"
>
Acessar
</v-btn>
Expand Down
8 changes: 6 additions & 2 deletions plugins/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ export default function ({ $axios, $toast }) {
'Ocorreu um erro inesperado. Por favor, tente novamente.'

if (process.client) {
$toast.error(message)
$toast.error(message, {
timeout: false,
})
} else {
$toast.error('Erro de rede ou servidor não está respondendo.')
$toast.error('Erro de rede ou servidor não está respondendo.', {
timeout: false,
})
}

return Promise.reject(error)
Expand Down
6 changes: 3 additions & 3 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const actions = {
},
})

toast.success('Notícias geradas com sucesso!')
toast.success('Notícias geradas com sucesso!', { timeout: false })

commit('setPage', 1)
commit('setPerPage', 4)
Expand Down Expand Up @@ -138,7 +138,7 @@ export const actions = {
},
})

toast.success('Notícia alterada com sucesso!')
toast.success('Notícia alterada com sucesso!', { timeout: false })

await dispatch('loadArticles')
await dispatch('loadTopics')
Expand All @@ -158,7 +158,7 @@ export const actions = {
},
})

toast.success('Notícia deletada com sucesso!')
toast.success('Notícia deletada com sucesso!', { timeout: false })

await dispatch('loadArticles')
await dispatch('loadTopics')
Expand Down
6 changes: 3 additions & 3 deletions store/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const actions = {

cookies.setAll(allCookies)

toast.success('Login realizado com sucesso!')
toast.success('Login realizado com sucesso!', { timeout: false })

router.push('/admin')
} catch (error) {
Expand Down Expand Up @@ -94,7 +94,7 @@ export const actions = {
},
})

toast.success('Usuário alterado com sucesso!')
toast.success('Usuário alterado com sucesso!', { timeout: false })

commit('setUser', data)
} catch (error) {
Expand All @@ -103,7 +103,7 @@ export const actions = {
},

logoutUser({ commit }, { cookies, toast, router }) {
toast.success('Logout realizado com sucesso!')
toast.success('Logout realizado com sucesso!', { timeout: false })

setTimeout(() => {
router.push('/login')
Expand Down