UnsupportedBrowserTests.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const { expect } = require('chai')
  2. const User = require('./helpers/User')
  3. describe('UnsupportedBrowsers', function () {
  4. beforeEach(function (done) {
  5. this.user = new User()
  6. this.user.login(done)
  7. })
  8. it('allows bots', function (done) {
  9. this.user.request(
  10. {
  11. url: '/project',
  12. headers: {
  13. // Googlebot user agent
  14. 'user-agent':
  15. 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
  16. },
  17. },
  18. (error, response) => {
  19. expect(error).to.not.exist
  20. expect(response.statusCode).to.equal(200)
  21. done()
  22. }
  23. )
  24. })
  25. it('allows supported browsers', function (done) {
  26. this.user.request(
  27. {
  28. url: '/project',
  29. headers: {
  30. // Chrome 90 user agent
  31. 'user-agent':
  32. 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36',
  33. },
  34. },
  35. (error, response) => {
  36. expect(error).to.not.exist
  37. expect(response.statusCode).to.equal(200)
  38. done()
  39. }
  40. )
  41. })
  42. it('redirects unsupported browsers to unsupported page', function (done) {
  43. this.user.request(
  44. {
  45. url: '/project',
  46. headers: {
  47. // IE11 user agent
  48. 'user-agent':
  49. 'Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko',
  50. },
  51. },
  52. (error, response) => {
  53. expect(error).to.not.exist
  54. expect(response.statusCode).to.equal(302)
  55. expect(response.headers.location).to.equal('/unsupported-browser')
  56. done()
  57. }
  58. )
  59. })
  60. })