Skip to content
Draft
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- Added logs for debugging

## [1.11.0] - 2023-01-30

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('Updating product as unavailable', () => {
updateRetry(3),
() => {
cy.subscribeToProduct({ email, name })
cy.qe(`Verify email existance ${MESSAGES.EmailAlreadyExist}`)
cy.get(availabilityNotifySelectors.AvailabilityNotifyAlert).should(
'have.text',
MESSAGES.EmailAlreadyExist
Expand Down
34 changes: 20 additions & 14 deletions cypress/support/availability-notify.apis.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* eslint-disable */
import { updateProductStatusAPI, getProcessAllRequestAPI } from './product.api'
import { VTEX_AUTH_HEADER, FAIL_ON_STATUS_CODE } from './common/constants'
import {
VTEX_AUTH_HEADER,
FAIL_ON_STATUS_CODE,
FAIL_ON_STATUS_CODE_STRING,
} from './common/constants'
import { updateRetry } from './common/support'

const config = Cypress.env()
Expand Down Expand Up @@ -35,15 +39,16 @@ export function updateProductStatus({
unlimited = false,
}) {
it(`${prefix} - Update the product status`, updateRetry(3), () => {
cy.qe(`Updating the product status`)
cy.addDelayBetweenRetries(2000)
cy.getVtexItems().then(vtex => {
cy.request({
cy.addLogsForRestAPI({
method: 'PUT',
url: updateProductStatusAPI(warehouseId, skuId),
headers: VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken),
...FAIL_ON_STATUS_CODE,
body: { unlimitedQuantity: unlimited, quantity: 0 },
}).then(response => {
cy.qe('Verifying response.body to be true')
expect(response.body).to.be.true
})
})
Expand All @@ -55,12 +60,11 @@ export function notifySearch(prefix) {
cy.addDelayBetweenRetries(2000)

cy.getVtexItems().then(vtex => {
cy.request({
method: 'GET',
url: `https://${vtex.account}.myvtex.com/api/dataentities/notify/search?_schema=reviewsSchema&_fields=email,skuId,name,createdAt`,
headers: VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken),
...FAIL_ON_STATUS_CODE,
}).then(response => {
cy.getAPI(
`https://${vtex.account}.myvtex.com/api/dataentities/notify/search?_schema=reviewsSchema&_fields=email,skuId,name,createdAt`,
VTEX_AUTH_HEADER(vtex.apiKey, vtex.apiToken)
).then(response => {
cy.qe(`Verifying the status to be ${response.status} `)
expect(response.status).to.equal(200)
})
})
Expand All @@ -86,11 +90,13 @@ export function updateAppSettings(prefix, doShippingSim = false) {
version,
settings: `{\"doShippingSim\":${doShippingSim},\"notifyMarketplace\":\"productusqaseller\"}`,
}
cy.addGraphqlLogs({ query: GRAPHQL_MUTATION, QUERY_VARIABLES })

// Mutating it to the new workspace
cy.request({

cy.addLogsForRestAPI({
method: 'POST',
url: CUSTOM_URL,
...FAIL_ON_STATUS_CODE,
body: {
query: GRAPHQL_MUTATION,
variables: QUERY_VARIABLES,
Expand All @@ -106,6 +112,7 @@ export function configureBroadcasterAdapter(prefix, workspace = 'master') {
`${prefix} - Register target workspace as ${workspace} in ${BROADCASTER_APP}`,
updateRetry(2),
() => {
cy.qe(`Register target workspace as ${workspace} in ${BROADCASTER_APP}`)
cy.getVtexItems().then(vtex => {
// Define constants
const APP_NAME = 'vtex.apps-graphql'
Expand All @@ -123,12 +130,11 @@ export function configureBroadcasterAdapter(prefix, workspace = 'master') {
version: '0.x',
settings: `{"targetWorkspace":"${workspace}"}`,
}
cy.addGraphqlLogs({ query: GRAPHQL_MUTATION, QUERY_VARIABLES })

// Mutating it to the new workspace
cy.request({
cy.addLogsForRestAPI({
method: 'POST',
url: CUSTOM_URL,
...FAIL_ON_STATUS_CODE,
body: {
query: GRAPHQL_MUTATION,
variables: QUERY_VARIABLES,
Expand Down
19 changes: 19 additions & 0 deletions cypress/support/availability-notify.graphql.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export function version() {
cy.qe(`Get version via graphql`)
const query = 'query' + '{version}'

cy.addGraphqlLogs(query)

return {
query: 'query' + '{version}',
queryVariables: {},
Expand All @@ -8,6 +13,8 @@ export function version() {
export function deleteRequest(deleteId) {
const query = 'mutation' + '($id: String)' + '{deleteRequest(id: $id)}'

cy.addGraphqlLogs(query, deleteId)

return {
query,
queryVariables: {
Expand All @@ -17,6 +24,12 @@ export function deleteRequest(deleteId) {
}

export function listRequests() {
const query =
'query' +
'{listRequests{id,name,email,skuId, notificationSent, notificationSentAt}}'

cy.addGraphqlLogs(query)

return {
query:
'query' +
Expand All @@ -27,6 +40,10 @@ export function listRequests() {
}

export function processUnsentRequest() {
const query = 'mutation' + '{processUnsentRequests{email,skuId,sent}}'

cy.addGraphqlLogs(query)

return {
query: 'mutation' + '{processUnsentRequests{email,skuId,sent}}',
queryVariables: {},
Expand All @@ -49,6 +66,8 @@ export function availabilitySubscribe(availabilityData) {
'($name: String, $email: String, $skuId: String, $sellerObj: SellerObjInputType!)' +
'{availabilitySubscribe(name: $name, email: $email, skuId: $skuId, sellerObj: $sellerObj)}'

cy.addGraphqlLogs(query, data)

return {
query,
queryVariables: data,
Expand Down
1 change: 1 addition & 0 deletions cypress/support/availability-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AVAILABILITY_NOTIFY_APP } from './graphql_apps'

export function verifyEmail(prefix) {
it(`${prefix} - Verifying email`, updateRetry(5), () => {
cy.qe('Verifying email')
cy.addDelayBetweenRetries(30000)
cy.getEmailItems().then(e => {
graphql(AVAILABILITY_NOTIFY_APP, listRequests(), response => {
Expand Down
17 changes: 17 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,39 @@ Cypress.Commands.add('gotoProductDetailPage', () => {
})

Cypress.Commands.add('openStoreFront', (login = false) => {
cy.qe(`Adding intercept for events API before visiting the hompage`)
cy.intercept('**/rc.vtex.com.br/api/events').as('events')
cy.visit('/')
if (login === true) {
cy.qe(
'Verifying Profile label should be visible in the homepage and it should contain Hello'
)
cy.get(selectors.ProfileLabel, { timeout: 20000 })
.should('be.visible')
.should('have.contain', `Hello,`)
}

cy.qe(`Waiting for the events API to be complted`)
cy.wait('@events')
})

Cypress.Commands.add('openProduct', (product, detailPage = false) => {
// Search product in search bar
cy.qe(
`Verifying that search bar shouldn't be disabled and it should be visible`
)
cy.get(selectors.Search).should('be.not.disabled').should('be.visible')
cy.qe(`Searching the ${product} in search bar`)

cy.get(selectors.Search)
.should('be.visible')
.clear()
.type(product)
.type('{enter}')
// Page should load successfully now Filter should be visible
cy.qe(`Search result should have the text ${product.toLowerCase()}`)
cy.get(selectors.searchResult).should('have.text', product.toLowerCase())
cy.qe(`Verifying that FilterHeading should be visible before the timeout`)
cy.get(selectors.FilterHeading, { timeout: 30000 }).should('be.visible')

if (detailPage) {
Expand Down Expand Up @@ -67,9 +78,15 @@ Cypress.Commands.add('getEmailItems', () => {
})

Cypress.Commands.add('subscribeToProduct', data => {
cy.qe('Saving email')
cy.saveEmailId(data.email)
cy.qe('Entering the name')
cy.get(availabilityNotifySelectors.name).type(data.name)
cy.qe('Entering the email')
cy.get(availabilityNotifySelectors.email).type(data.email)
cy.qe(
`Verifying submit button should not be disabled and clicking on the submit button`
)
cy.get(availabilityNotifySelectors.AvailabilityNotifySubmitButton)
.should('not.be.disabled')
.click()
Expand Down