JobsUnifiedTopCard.purs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. module Test.JobsUnifiedTopCard where
  2. import Prelude
  3. import Data.Either (Either(..))
  4. import Data.List (List(..), (:))
  5. import Data.List.NonEmpty (NonEmptyList(..))
  6. import Data.Maybe (Maybe(..))
  7. import Data.NonEmpty (NonEmpty(..))
  8. import LinkedIn.DetachedNode (DetachedNode(..))
  9. import LinkedIn.Jobs.JobOffer (JobOffer(..))
  10. import LinkedIn.Output.Types (Output(..))
  11. import LinkedIn.Page.JobOffer (JobOfferPage(..))
  12. import LinkedIn.UI.Basic.Types (JobFlexibility(..))
  13. import LinkedIn.UI.Components.JobsUnifiedTopCard (JobsUnifiedTopCardElement(..), TopCardAction(..), TopCardInsight(..), TopCardInsightContent(..), TopCardPrimaryDescription(..), TopCardSecondaryInsight(..))
  14. import Test.Spec (Spec, describe, it)
  15. import Test.Spec.Assertions (shouldEqual)
  16. import Test.Utils (detachFromFile, getOutputFromFile)
  17. import Type.Proxy (Proxy(..))
  18. type TestCase a = { detached ∷ a DetachedNode , filePath ∷ String , output ∷ Output }
  19. jobOfferPage_3786945580 ∷ TestCase JobOfferPage
  20. jobOfferPage_3786945580 = {
  21. filePath: "test/examples/job_offer_3786945580.html",
  22. detached: JobOfferPage (JobsUnifiedTopCardElement {
  23. actions: (Just (NonEmptyList (NonEmpty (TopCardActionButton
  24. (DetachedButton {
  25. classes: ("jobs-apply-button" : "artdeco-button" : "artdeco-button--3" : "artdeco-button--primary" : "ember-view" : Nil),
  26. content: "Candidature simplifiée",
  27. role: Nothing
  28. }))
  29. ((TopCardActionButton (DetachedButton {
  30. classes: ("jobs-save-button" : "artdeco-button" : "artdeco-button--3" : "artdeco-button--secondary" : Nil),
  31. content: "Enregistrer Enregistrer Data Engineer H/F - Secteur Energie chez LINCOLN",
  32. role: Nothing
  33. })) : Nil)
  34. ))),
  35. header: (DetachedElement {
  36. classes: ("t-24" : "t-bold" : "job-details-jobs-unified-top-card__job-title" : Nil),
  37. content: "Data Engineer H/F - Secteur Energie",
  38. id: Nothing,
  39. tag: "H1"
  40. }),
  41. insights: (Just (NonEmptyList (NonEmpty (TopCardInsight {
  42. content: (TopCardInsightContentSecondary {
  43. primary: (DetachedElement {classes: Nil, content: "Sur site", id: Nothing, tag: "SPAN"}),
  44. secondary: (NonEmptyList (NonEmpty (TopCardSecondaryInsightNested
  45. (DetachedElement {classes: Nil, content: "Temps plein", id: Nothing, tag: "SPAN"}))
  46. ((TopCardSecondaryInsightPlain
  47. (DetachedElement {classes: ("job-details-jobs-unified-top-card__job-insight-view-model-secondary" : Nil), content: "Confirmé", id: Nothing,tag: "SPAN" })) : Nil))
  48. )
  49. }),
  50. icon: DetachedLiIcon "job"
  51. }) ((TopCardInsight {
  52. content: (TopCardInsightContentSingle (
  53. DetachedElement {classes: Nil, content: "201-500 employés · Technologies et services de l’information", id: Nothing, tag: "SPAN" }
  54. )),
  55. icon: DetachedLiIcon "company"
  56. }) : (TopCardInsight {
  57. content: (TopCardInsightContentSingle (
  58. DetachedElement {classes: Nil, content: "2 anciens élèves travaillent ici", id: Nothing, tag: "SPAN" }
  59. )),
  60. icon: DetachedLiIcon "people"
  61. }) : (TopCardInsight {
  62. content: (TopCardInsightContentSingle (
  63. DetachedElement {classes: Nil, content: "Découvrez comment vous vous positionnez par rapport à 87 candidats. Essai Premium pour 0 EUR", id: Nothing, tag: "SPAN" })),
  64. icon: (DetachedSvgElement { dataTestIcon: (Just "lightbulb-medium"), id: Nothing, tag: "svg" })
  65. }) : (TopCardInsight {
  66. content: (TopCardInsightContentButton (
  67. DetachedButton {classes: ("job-details-jobs-unified-top-card__job-insight-text-button" : Nil), content: "9 compétences sur 11 correspondent à votre profil, vous pourriez bien convenir pour ce poste", role: Nothing}
  68. )),
  69. icon: (DetachedSvgElement { dataTestIcon: (Just "checklist-medium"), id: Nothing, tag: "svg" })
  70. }) : Nil)))),
  71. primaryDescription: (TopCardPrimaryDescription {
  72. link: (DetachedA { content: "LINCOLN", href: "https://www.linkedin.com/company/lincoln-/life" }),
  73. text: (DetachedText "· Boulogne-Billancourt, Île-de-France, France"),
  74. tvmText: (Just (NonEmptyList (NonEmpty (
  75. DetachedElement {classes: ("tvm__text" : "tvm__text--neutral" : Nil), content: "il y a 2 semaines", id: Nothing, tag: "SPAN"})
  76. ((DetachedElement {classes: ("tvm__text" : "tvm__text--neutral" : Nil), content: "·", id: Nothing, tag: "SPAN"})
  77. : (DetachedElement {classes: ("tvm__text" : "tvm__text--neutral" : Nil), content: "87 candidats", id: Nothing, tag: "SPAN"})
  78. : Nil
  79. ))
  80. ))
  81. })
  82. }),
  83. output: OutJobOffer (JobOffer {
  84. companyDomain: (Just "Technologies et services de l’information"),
  85. companyLink: "https://www.linkedin.com/company/lincoln-/life",
  86. companyName: "LINCOLN",
  87. companySize: (Just "201-500 employés"),
  88. hasSimplifiedApplicationProcess: true,
  89. location: (Just "Boulogne-Billancourt, Île-de-France, France"),
  90. flexibility: (Just JobFlexOnSite),
  91. title: "Data Engineer H/F - Secteur Energie"
  92. })
  93. }
  94. jobsUnifiedTopCardSpec :: Spec Unit
  95. jobsUnifiedTopCardSpec = do
  96. describe "Jobs top card parsing" do
  97. it "reads well as a JobOfferPage DetachedNode" do
  98. topCard <- detachFromFile (Proxy :: Proxy JobOfferPage) jobOfferPage_3786945580.filePath
  99. topCard `shouldEqual` Right(jobOfferPage_3786945580.detached)
  100. it "reads the JobOffer" do
  101. jobOffer <- getOutputFromFile (Proxy :: Proxy JobOfferPage) jobOfferPage_3786945580.filePath
  102. jobOffer `shouldEqual` Right (jobOfferPage_3786945580.output)