File size: 1,909 Bytes
cb5b71d
 
 
6a31b9a
cb5b71d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a31b9a
 
 
cb5b71d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a31b9a
 
 
cb5b71d
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/// <reference types="cypress" />

import 'cypress-file-upload';
import 'cypress-iframe';
import * as path from 'path';

describe('Editor loads Croissant without Error', () => {
  it('should allow uploading existing croissant files', () => {
    cy.visit('http://localhost:8501')

    cy.fixture('titanic.json').then((fileContent) => {
      const file = {
        fileContent,
        fileName: 'titanic.json', mimeType: 'text/json',
      }
      cy.get(
        "[data-testid='stFileUploadDropzone']",
      ).attachFile(file, {
        force: true,
        subjectType: "drag-n-drop",
        events: ["dragenter", "drop"],
      })
    })
    cy.enter('[title="components.tabs.tabs_component"]').then(getBody => {
      getBody().contains('Metadata').click()
    })

    cy
    .get("[data-testid='element-container']")
    .contains('Titanic')
    .should('exist')
    
  })
  it('should download as json', () => {
    cy.visit('http://localhost:8501')

    cy.fixture('titanic.json').then((fileContent) => {
      const file = {
        fileContent,
        fileName: 'titanic.json', mimeType: 'text/json',
      }
      cy.get(
        "[data-testid='stFileUploadDropzone']",
      ).attachFile(file, {
        force: true,
        subjectType: "drag-n-drop",
        events: ["dragenter", "drop"],
      })
    })
    
    cy.get('[data-testid="stException"]').should('not.exist')

    cy.enter('[title="components.tabs.tabs_component"]').then(getBody => {
      getBody().contains('Export').click()
    })
    cy.fixture('titanic.json').then((fileContent) => {
      const downloadsFolder = Cypress.config("downloadsFolder");
      cy.readFile(path.join(downloadsFolder, "croissant-titanic.json"))
      .then((downloadedFile) => {
        downloadedFile = JSON.stringify(downloadedFile)
        return downloadedFile
      })
      .should('deep.equal', JSON.stringify(fileContent))
    })
  })
})