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

[ENGINEERS-1070] - Verifying Reviews are sorted By DateTime using Xls doc #240

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- verifying reviews are sorted by xls doc

### Added

- Added updateRetry to verify ratings and some messages


Expand Down
18 changes: 18 additions & 0 deletions cy-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ strategy:
- cypress/integration/2.4.2-signed_in_user.spec.js
dependency:
- cypress/integration/2.4.1-anonymous_user.spec.js
# Verify reviews are sorted in dateTime format
Reviews_sorting:
enabled: true
sendDashboard: true
hardTries: 1
stopOnFail: false
parallel: true
specs:
- 2.4.3-verify_date_search_sorting.spec.js
dependency:
- cypress/integration/2.1.1-anonymous_user.spec.js
- cypress/integration/2.2.1-ordering_the_product.spec.js
- cypress/integration/2.3.2-signed_in_user.spec.js
- cypress/integration/2.1.2-signed_in_user.spec.js
- cypress/integration/2.1.3-verify_review_with_signed_user.spec.js
- cypress/integration/2.3.2-signed_in_user.spec.js
- cypress/integration/2.4.1-anonymous_user.spec.js
- cypress/integration/2.4.2-signed_in_user.spec.js
rest_api_testcase:
enabled: true
sendDashboard: true
Expand Down
24 changes: 24 additions & 0 deletions cypress/integration/2.4.3-verify_date_search_sorting.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { loginViaCookies, updateRetry } from '../support/common/support.js'
import { selectDate, verifyExcelFile } from '../support/testcase.js'
// import rrselectors from '../support/selectors'

const fileName = 'cypress/downloads/reviews.xls'
const date = new Date()
const currentDate = date.getUTCDate()

describe('verify sorting for reviews', () => {
loginViaCookies({ storeFrontCookie: false })
it('Download reviews for some dates', updateRetry(2), () => {
cy.getVtexItems().then(vtex => {
cy.visit(`${vtex.baseUrl}/admin/app/reviews-ratings/download`)
cy.contains('Reviews')
selectDate({ day: currentDate, position: 1 })
cy.contains('Apply').click()
cy.get('.pa1 > .vtex-button').click()
// cy.get(rrselectors.Download).click()
// selectDate({day:'20',position:2})
})
})

verifyExcelFile(fileName)
})
24 changes: 5 additions & 19 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
const readXlsx = require('./read-xlsx')

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (_on, _config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
module.exports = on => {
on('task', {
readXlsx: readXlsx.read,
})
}
14 changes: 14 additions & 0 deletions cypress/plugins/read-xlsx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const fs = require('fs')

const XLSX = require('xlsx')

const read = ({ file, sheet }) => {
const buf = fs.readFileSync(file)
const workbook = XLSX.read(buf, { type: 'buffer' })

return XLSX.utils.sheet_to_json(workbook.Sheets[sheet])
}

module.exports = {
read,
}
7 changes: 7 additions & 0 deletions cypress/support/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ export default {
GetReviewByIndex: index => {
return `div[class*=reviewCommentsContainer] div[class*=reviewComment]:nth-child(${index}) div[class*=reviewCommentRating] span[class*=filled]`
},
Download: 'div[class*=pal] > .vtex-button]',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this selector(div[class*=pal] > .vtex-button]) working fine ? because it has close ] not open [

FromDate: position => {
return `:nth-child(${position}) > div[class*=wrapper] > div[class*=_input-container] > label[class*=input] > div[class*=input-prefix__group] > .vtex-styleguide-9-x-input`
},
SelectDate: day => {
return `div[class*=datepicker__day--0${day}]`
},
}
25 changes: 25 additions & 0 deletions cypress/support/testcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,28 @@ export function verifyAverageRatings(product, user) {
cy.getAverageRating(user, product)
})
}

export function selectDate({ day, position }) {
cy.get(rrselectors.FromDate(position)).click()
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000)
cy.get(rrselectors.SelectDate(day)).click()
}

export function verifyExcelFile(fileName) {
it('verify the data and extension', updateRetry(3), () => {
cy.task('readXlsx', {
file: fileName,
sheet: 'Sheet1',
}).then(rows => {
expect(rows.length).to.be.greaterThan(1)
// cy.wrap(rows).then(rows => {
// for (let i = 0; i < rows.length - 1; i++) {
// expect(new Date(rows[0].Time)).to.be.lessThan(
// new Date(rows[i + 1].Time)
// )
// }
// })
})
})
}
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
"husky": "^4.2.0",
"lint-staged": "^10.0.2",
"prettier": "^2.5.1",
"typescript": "^3.7.5"
"typescript": "^3.7.5",
"xlsx": "^0.18.5"
},
"dependencies": {
"xlsx": "^0.17.3"
}
}
"dependencies": {}
}
36 changes: 9 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,6 @@ acorn@^7.1.1:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==

adler-32@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/adler-32/-/adler-32-1.2.0.tgz#6a3e6bf0a63900ba15652808cb15c6813d1a5f25"
integrity sha1-aj5r8KY5ALoVZSgIyxXGgT0aXyU=
dependencies:
exit-on-epipe "~1.0.1"
printj "~1.1.0"

adler-32@~1.3.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/adler-32/-/adler-32-1.3.1.tgz#1dbf0b36dda0012189a32b3679061932df1821e2"
Expand Down Expand Up @@ -335,7 +327,7 @@ callsites@^3.0.0:
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==

cfb@^1.1.4:
cfb@~1.2.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/cfb/-/cfb-1.2.2.tgz#94e687628c700e5155436dac05f74e08df23bc44"
integrity sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==
Expand Down Expand Up @@ -465,7 +457,7 @@ cosmiconfig@^7.0.0:
path-type "^4.0.0"
yaml "^1.10.0"

crc-32@~1.2.0:
crc-32@~1.2.0, crc-32@~1.2.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff"
integrity sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==
Expand Down Expand Up @@ -910,11 +902,6 @@ execa@^4.1.0:
signal-exit "^3.0.2"
strip-final-newline "^2.0.0"

exit-on-epipe@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz#0bdd92e87d5285d267daa8171d0eb06159689692"
integrity sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==

external-editor@^3.0.3:
version "3.1.0"
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495"
Expand Down Expand Up @@ -1871,11 +1858,6 @@ prettier@^2.5.1:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032"
integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==

printj@~1.1.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/printj/-/printj-1.1.2.tgz#d90deb2975a8b9f600fb3a1c94e3f4c53c78a222"
integrity sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==

progress@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
Expand Down Expand Up @@ -2416,15 +2398,15 @@ [email protected]:
dependencies:
mkdirp "^0.5.1"

xlsx@^0.17.3:
version "0.17.5"
resolved "https://registry.yarnpkg.com/xlsx/-/xlsx-0.17.5.tgz#78b788fcfc0773d126cdcd7ea069cb7527c1ce81"
integrity sha512-lXNU0TuYsvElzvtI6O7WIVb9Zar1XYw7Xb3VAx2wn8N/n0whBYrCnHMxtFyIiUU1Wjf09WzmLALDfBO5PqTb1g==
xlsx@^0.18.5:
version "0.18.5"
resolved "https://registry.yarnpkg.com/xlsx/-/xlsx-0.18.5.tgz#16711b9113c848076b8a177022799ad356eba7d0"
integrity sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==
dependencies:
adler-32 "~1.2.0"
cfb "^1.1.4"
adler-32 "~1.3.0"
cfb "~1.2.1"
codepage "~1.15.0"
crc-32 "~1.2.0"
crc-32 "~1.2.1"
ssf "~0.11.2"
wmf "~1.0.1"
word "~0.3.0"
Expand Down